-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpythoncalculator.usp
78 lines (54 loc) · 1.14 KB
/
pythoncalculator.usp
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
//#CATEGORY "0"
//#ENABLE_TRACE
#CRESTRON_SIMPLSHARP_LIBRARY "SimplPlusPythonAdapter"
digital_input Divide, Multiply, Add, Subtract, Power;
String_Input Values[2][256];
String_Output From_Python;
string Mode[64];
PythonModule PythonCalc;
string g_ID[250];
callback function DataReceivedHandler(PythonModule sender, PythonAdapterDataReceivedEventArgs e)
{
From_Python = e.Data;
}
function SendToPython (string Mode)
{
integer i;
StringList args;
args.Add(Mode);
for(i = 1 to 2)
args.Add(Values[i]);
// Overload to pass arguments
PythonInterface.RunWithArgs(g_ID, "PythonCalc.py", PythonCalc, args);
}
push Divide
{
SendToPython("Divide");
}
push Multiply
{
SendToPython("Multiply");
}
push Add
{
SendToPython("Add");
}
push Subtract
{
SendToPython("Subtract");
}
push Power
{
SendToPython("Power");
}
function RegisterDelegates()
{
// Register to receive data sent by python modules
RegisterDelegate(PythonInterface, DataReceived, DataReceivedHandler);
}
function Main()
{
g_ID = PythonAdapterUtils.NewGuid;
RegisterDelegates();
WaitForInitializationComplete();
}