forked from MachineryScience/Rockhopper
-
Notifications
You must be signed in to change notification settings - Fork 6
/
generateRockhopperClientAPI.py
46 lines (38 loc) · 1.64 KB
/
generateRockhopperClientAPI.py
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
from LinuxCNCWebSktSvr import StatusItems, CommandItems
import json
statusItems = []
for name in StatusItems:
statusItem = StatusItems[name]
statusItems.append(statusItem)
statusItems.sort(key=lambda item: item.name)
commandItems = []
for name in CommandItems:
commandItem = CommandItems[name]
commandItems.append(commandItem)
commandItems.sort(key=lambda item: item.name)
print(
"""
//****************************************************************************************
//
// AUTOGENERATED by generateRockhopperClientAPI.py in Rockhopper repository, DO NOT EDIT.
// If changes were made to the StatusItems or CommandItems data structures, run
// generateRockhopperClientAPI.py again and replace this file with its output.
//
//*****************************************************************************************
""")
print("export const StatusItems = [")
numStatusItems = len(statusItems)
for (i,statusItem) in enumerate(statusItems):
isLast = i == numStatusItems-1
print(' { name: "%s", watchable: %s%s }%s' % (statusItem.name,
"true" if statusItem.watchable else "false",
(', requiresFeature: "%s"' % (statusItem.requiresFeature,) if statusItem.requiresFeature else ""),
"" if isLast else ","))
print("];")
print("")
print("export const CommandItems = [")
numCommandItems = len(commandItems)
for (i,item) in enumerate(commandItems):
isLast = i == numCommandItems-1
print(' { name: "%s", paramTypes: %s }%s' % (item.name, json.dumps(item.paramTypes), "" if isLast else ","))
print("];")