summaryrefslogtreecommitdiff
path: root/src/emc/usr_intf/axis/scripts/lintini.py
blob: 011a335d917ed82628a8b67463c4ae11a2ee970e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
#!/usr/bin/python
#    This is a component of AXIS, a front-end for LinuxCNC
#    Copyright 2004, 2005, 2006 Jeff Epler <jepler@unpythonic.net> and
#    Chris Radek <chris@timeguy.com>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import sys, os
import linuxcnc

ini = linuxcnc.ini(sys.argv[1])

nproblems = 0
def report_problem(msg, *args):
    global nproblems
    nproblems += 1
    if args:
        print msg % args
    else:
        print msg


def get_int(section, key):
	return int(ini.find(section, key).split()[0])
def get_float(section, key):
	return float(ini.find(section, key).split()[0])

period = get_int("EMCMOT", "BASE_PERIOD")
naxes = get_int("TRAJ", "AXES")

is_stepper = ini.find("AXIS_0", "STEPGEN_MAXVEL") is not None
if is_stepper: print "Appears to be a stepper configuration"
else: print "Appears to be a servo configuration"

for i in range(naxes):
    axis = "AXIS_%d" % i
    scale = get_float(axis, "INPUT_SCALE") 
    if is_stepper:
        vel = get_float(axis, "STEPGEN_MAXVEL")
        cycles_per_step = 2
        required_period = 1000000000 / vel / scale / cycles_per_step
        if required_period < period:
            report_problem(
                "Max Velocity %g and scale %g require BASE_PERIOD below %d",
                vel, scale, int(required_period))

        vel = get_float(axis, "MAX_VELOCITY")
        headroom_vel = get_float(axis, "STEPGEN_MAXVEL")
        if headroom_vel < vel * 1.01:
            report_problem(
                "Less than 1%% velocity headroom from %g to %g",
                vel, headroom_vel)

        acc = get_float(axis, "MAX_ACCELERATION")
        headroom_acc = get_float(axis, "STEPGEN_MAXACCEL")
        if headroom_acc < acc * 1.01:
            report_problem(
                "Less than 1%% acceleration headroom from %g to %g",
                acc, headroom_acc)


if nproblems == 0:
    print "No problems found"
elif nproblems == 1:
    print "One problem found"
else:
    print "%d problems found" % nproblems

# vim:sw=4:sts=4:et