-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCAPI_CtrlQueue.pas
164 lines (154 loc) · 5.46 KB
/
CAPI_CtrlQueue.pas
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
unit CAPI_CtrlQueue;
interface
uses
CAPI_Utils,
CAPI_Types,
Classes;
procedure CtrlQueue_ClearQueue(); CDECL;
procedure CtrlQueue_Delete(ActionHandle: Integer); CDECL;
function CtrlQueue_Get_ActionCode(): Integer; CDECL;
function CtrlQueue_Get_DeviceHandle(): Integer; CDECL;
function CtrlQueue_Get_NumActions(): Integer; CDECL;
function CtrlQueue_Push(Hour: Integer; Seconds: Double; ActionCode, DeviceHandle: Integer): Integer; CDECL;
procedure CtrlQueue_Show(); CDECL;
procedure CtrlQueue_ClearActions(); CDECL;
function CtrlQueue_Get_PopAction(): Integer; CDECL;
procedure CtrlQueue_Set_Action(Param1: Integer); CDECL;
function CtrlQueue_Get_QueueSize(): Integer; CDECL;
procedure CtrlQueue_DoAllQueue(); CDECL;
procedure CtrlQueue_Get_Queue(var ResultPtr: PPAnsiChar; ResultCount: PAPISize); CDECL;
procedure CtrlQueue_Get_Queue_GR(); CDECL;
implementation
uses
CAPI_Constants,
DSSGlobals,
ControlQueue,
ControlElem,
DSSClass,
sysutils,
Utilities,
DSSHelper;
{Define class for proxy control object}
procedure CtrlQueue_ClearQueue(); CDECL;
begin
if InvalidCircuit(DSSPrime) then
Exit;
DSSPrime.ActiveCircuit.ControlQueue.Clear();
end;
//------------------------------------------------------------------------------
procedure CtrlQueue_Delete(ActionHandle: Integer); CDECL;
begin
if InvalidCircuit(DSSPrime) then
Exit;
DSSPrime.ActiveCircuit.ControlQueue.Delete(ActionHandle);
end;
//------------------------------------------------------------------------------
function CtrlQueue_Get_ActionCode(): Integer; CDECL;
begin
Result := 0;
if InvalidCircuit(DSSPrime) or (DSSPrime.ActiveAction = NIL) then
Exit;
Result := DSSPrime.ActiveAction^.ActionCode;
end;
//------------------------------------------------------------------------------
function CtrlQueue_Get_DeviceHandle(): Integer; CDECL;
begin
Result := 0;
if InvalidCircuit(DSSPrime) or (DSSPrime.ActiveAction = NIL) then
Exit;
Result := DSSPrime.ActiveAction^.DeviceHandle;
end;
//------------------------------------------------------------------------------
function CtrlQueue_Get_NumActions(): Integer; CDECL;
begin
Result := 0;
if InvalidCircuit(DSSPrime) then
Exit;
Result := DSSPrime.ControlProxyObj.ActionList.Count;
end;
//------------------------------------------------------------------------------
function CtrlQueue_Push(Hour: Integer; Seconds: Double; ActionCode, DeviceHandle: Integer): Integer; CDECL;
// returns handle on control queue
begin
Result := 0;
if InvalidCircuit(DSSPrime) then
Exit;
Result := DSSPrime.ActiveCircuit.ControlQueue.push(Hour, Seconds, ActionCode, DeviceHandle, DSSPrime.ControlProxyObj);
end;
//------------------------------------------------------------------------------
procedure CtrlQueue_Show(); CDECL;
begin
if InvalidCircuit(DSSPrime) then
Exit;
DSSPrime.ActiveCircuit.ControlQueue.ShowQueue(DSSPrime.OutputDirectory + 'COMProxy_ControlQueue.csv');
end;
//------------------------------------------------------------------------------
procedure CtrlQueue_ClearActions(); CDECL;
begin
if InvalidCircuit(DSSPrime) then
Exit;
DSSPrime.ControlProxyObj.ClearActionList;
end;
//------------------------------------------------------------------------------
function CtrlQueue_Get_PopAction(): Integer; CDECL;
begin
Result := 0;
if InvalidCircuit(DSSPrime) then
Exit;
Result := DSSPrime.ControlProxyObj.ActionList.Count;
DSSPrime.ControlProxyObj.PopAction;
end;
//------------------------------------------------------------------------------
procedure CtrlQueue_Set_Action(Param1: Integer); CDECL;
begin
if InvalidCircuit(DSSPrime) then
Exit;
with DSSPrime.ControlProxyObj do
if Param1 < ActionList.Count then
DSSPrime.ActiveAction := ActionList.Items[Param1 - 1];
end;
//------------------------------------------------------------------------------
function CtrlQueue_Get_QueueSize(): Integer; CDECL;
begin
Result := 0;
if InvalidCircuit(DSSPrime) then
Exit;
Result := DSSPrime.ActiveCircuit.ControlQueue.QueueSize;
end;
//------------------------------------------------------------------------------
procedure CtrlQueue_DoAllQueue(); CDECL;
begin
if InvalidCircuit(DSSPrime) then
Exit;
DSSPrime.ActiveCircuit.ControlQueue.DoAllActions;
end;
//------------------------------------------------------------------------------
procedure CtrlQueue_Get_Queue(var ResultPtr: PPAnsiChar; ResultCount: PAPISize); CDECL;
// returns entire queue in CSV file format as a variant array of strings
var
Result: PPAnsiCharArray0;
i: Integer;
Qsize: Integer;
begin
if not InvalidCircuit(DSSPrime) then
begin
QSize := CtrlQueue_Get_QueueSize();
if QSize > 0 then
begin
DSS_RecreateArray_PPAnsiChar(Result, ResultPtr, ResultCount, QSize + 1);
Result[0] := DSS_CopyStringAsPChar('Handle, Hour, Sec, ActionCode, ProxyDevRef, Device');
for i := 0 to QSize - 1 do
begin
Result[i + 1] := DSS_CopyStringAsPChar(DSSPrime.ActiveCircuit.ControlQueue.QueueItem(i));
end;
Exit;
end;
end;
DefaultResult(ResultPtr, ResultCount, 'No events');
end;
procedure CtrlQueue_Get_Queue_GR(); CDECL;
// Same as CtrlQueue_Get_Queue but uses global result (GR) pointers
begin
CtrlQueue_Get_Queue(DSSPrime.GR_DataPtr_PPAnsiChar, @DSSPrime.GR_Counts_PPAnsiChar[0])
end;
end.