aboutsummaryrefslogtreecommitdiff
path: root/utilities/genkeys.py
blob: b157e811ef49e38870cf59c9116a3a4ff178cdce (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
'''--------------------------------------------------------------------------------------genkeys.py

Create keyword data from a single consistant datasource.

Note : .....HACK HACK this works but it wasnt designed....
mykeywords should be reformated so that test and other data can be created from the dictionary.
REPLACED WITH GO BASED GENERATOR. Need to link to repo.....
'''
mykeywords=[\
            "SYN[!  ]sync (hello)    |sync",
            "ACK[ : ]acknowlege(yes) |ack",
            "NAK[ : ]negative (no)   |nack",
            "SWV[ :?]Software Vers.  |softwareVersion",
            "HWV[ :?]Hardware Vers.  |hardwareVersion",
            "GIT[ :?]GIT Repo Vers.  |gitRepoVersion",
            "MEM[ :?]Avaliable Mem.  |memory",
            "SSN[ :?]Unit Serial No. |serialNumber",
            "HLP[ :?]help            |help",
            "FTL[!: ]Fatal Error     |generateFatalError",
            "ALT[!: ]Alert           |generateAlert",
            "WAR[!: ]Warning         |generateWarnig",
            "INF[!: ]Info            |generateInfo",
            "DBG[!: ]Debugging Info  |generateDebugData",
            "LOG[!: ]Log             |logData",
            "STC[!: ]State Change    |setState",
            "DVL[!:?]Display Level   |setgetDebugLevel",
            "LVL[!:?]Log Level       |setgetLogLevel",
            "RST[!  ]Reboot          |reset",
            "BLD[!  ]Reboot to loader|reset",
            "STP[!:?]Sim/Chk  E-Stop |stop",
            "LCS[!:?]Light Curt. Stop|lightCurtain",
            "LCR[!: ]Light Curt. Rst |lightCurtainReset",
            "NOW[!:?]Time as a  int  |setgetUnixTime",
            "TIM[!:?]Time for humans |setgetTime",
            "TS1[ :?]Temp Sensor 1   |temperature",
            "TS2[ :?]Temp Sensor 2   |temperature",
            "TMP[ :?]Temp Setting    |temperature",
            "AMT[ :?]Ambient Temp    |ambientTemp",
            "AMH[ :?]Ambient Humidity|ambientHumidity",
            "RED[!: ]Led (0-255)     |redLed",
            "HSW[!:?]Heaters (ON/OFF)|heater",
            "H1S[!:?]Heater 1(ON/OFF)|heater",
            "H1V[!:?]Heater 1 (0-255)|heater",
            "H1P[!:?]Heater 1 P value|setgetPids",
            "H1I[!:?]Heater 1 I value|setgetPids",
            "H1D[!:?]Heater 1 D value|setgetPids",
            "H2S[!:?]Heater 1(ON/OFF)|heater",
            "H2V[!:?]Heater 1 (0-255)|heater",
            "H2P[!:?]Heater 2 P value|setgetPids",
            "H2I[!:?]Heater 2 I value|setgetPids",
            "H2D[!:?]Heater 2 D value|setgetPids",
            "PMS[!:?]Pump Sw (ON/OFF)|pump",
            "PSP[ :?]Pressure P value|pressure",
            "PSI[ :?]Pressure I value|pressure",
            "PSD[ :?]Pressure D value|pressure",
            "PS1[ :?]Pressure Sensor |pressure",
            "MUP[!: ]Manual up       |pressure",
            "MDN[!: ]Manual down     |pressure",
            "TMS[!:?]Timer setting   |timer",
            "TMR[!:?]Timer Run(ON/OF)|timer",
            "TRM[ :?]Time Remaining  |timer",
            "SOL[!:?]Solenoid(ON/OFF)|pump",
            "HOM[ :?]Home Switch     |home",
            "CMD[!:?]Command Mode    |command",
            "MLD[!:?]Enable Multiline|multiline",
            "SOD[!: ]Start Multiline |multiline",
            "EOD[!: ]End Multiline   |multiline",
]
'''-------------------------------------------------------------------------------------------------
    Generate keywords.h file from data.
'''


print '''
/*--------------------------------------------------------------------------------------------------
 * !!!!!!!!!!!!!!!!!!!!!!!! ..... This may or may not be free software ..... !!!!!!!!!!!!!!!!!!!!!!!
 *
 * This file is autogenerated and while created by and needed for several open source modules the
 * vocabulary is specific to the project and the routines referenced will be liscenced on a per
 * project basis
 *--------------------------------------------------------------------------------------------------
 *
 *
 * The idea here is to create an automation freindly monitor protocol and debug interface.
 * because this needs to be efficient (and flexible) I have chosen a very simple interface
 * which will access and may manipulate the devices public variables.
 *
 * Basic Syntax for the monitor is
 * XXX[?!:] <variable stuff> <CR>
 * where:
 * XXX is a 3 letter command or variable.
 * ! execute command or store value
 * ? request a value
 * : value sent as a response or an update.
 * simple example 
 * (reboot device)
 * RST!
 * (set red led value)
 * RED!255
 * (request pressure sensor, recieve sensor value and unsolicited temperature sensorupdate )
 * PS1?
 * PS1:1240.2
 * TS1:150.5
 *
 */
#ifndef keywords_h
#define keywords_h

#define HELPTEXT \\'''

for l in mykeywords:
    
    print '"'+l[:24]+'"\\'
print '"NOP[!: ]Not implemented"'
print
print '\n\n#define KEYWORDS \\'

col=1

for l in mykeywords:
    if not col % 13 and col > 0 :
        print '"'+l[:3]+'" \\'
    else:
        print '"'+l[:3]+'" ',
    col += 1

if not col % 13 and col > 0 :
    print '\\'
print '"NOP"'
print

print 'enum keywordIndex {'

col=1

for l in mykeywords:
    if not col % 13 and col > 0 :
        print '_'+l[:3]+'_,'
    else:
        print '_'+l[:3]+'_,',
    col += 1
if not col % 13 and col > 0 :
    print
print '_NOP_};'

print '''// use enum to determine the size of the keyword arrays.
#define NKEYWORDS  _NOP_ + 1

#endif
'''