-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNAVFoundation.RmsUtils.axi
More file actions
381 lines (299 loc) · 15.4 KB
/
NAVFoundation.RmsUtils.axi
File metadata and controls
381 lines (299 loc) · 15.4 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
PROGRAM_NAME='NAVFoundation.RmsUtils'
/*
_ _ _ ___ __
| \ | | ___ _ __ __ _ __ _| |_ ___ / \ \ / /
| \| |/ _ \| '__/ _` |/ _` | __/ _ \ / _ \ \ / /
| |\ | (_) | | | (_| | (_| | || __// ___ \ V /
|_| \_|\___/|_| \__, |\__,_|\__\___/_/ \_\_/
|___/
MIT License
Copyright (c) 2010-2026 Norgate AV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#IF_NOT_DEFINED __NAV_FOUNDATION_RMSUTILS__
#DEFINE __NAV_FOUNDATION_RMSUTILS__ 'NAVFoundation.RmsUtils'
#include 'NAVFoundation.Core.axi'
#include 'NAVFoundation.ErrorLogUtils.axi'
DEFINE_CONSTANT
constant char NAV_RMS_CLIENT_EVENT_SERVER_INFO[] = 'SERVER.INFO'
constant char NAV_RMS_CLIENT_REINITIALIZE[] = 'REINIT'
DEFINE_TYPE
struct _NAVRmsServerInformation {
char AppVersion[NAV_MAX_CHARS]
char DatabaseVersion[NAV_MAX_CHARS]
integer MinPollTime
integer MaxPollTime
char TimesyncEnabled
char SmtpEnabled
} // Total: 106 bytes
struct _NAVRmsLocation {
char Id[NAV_MAX_CHARS] // 50 bytes
char Name[NAV_MAX_CHARS] // 50 bytes
char Owner[NAV_MAX_CHARS] // 50 bytes
char PhoneNumber[NAV_MAX_CHARS] // 50 bytes
char Occupancy[NAV_MAX_CHARS] // 50 bytes
char PrestigeName[NAV_MAX_CHARS] // 50 bytes
char Timezone[NAV_MAX_CHARS] // 50 bytes
char ClientDefaultLocation // 1 byte
char AssetLicensed // 1 byte
} // Total: 402 bytes (unchanged)
struct _NAVRmsAdapter {
char IsOnline
} // Total: 1 byte
struct _NAVRmsConnection {
char Name[NAV_MAX_CHARS]
char Url[255]
char Password[NAV_MAX_CHARS]
char Enabled[5] // 'true' or 'false'
} // Total: 360 bytes
struct _NAVRmsException {
char Message[255] // 255 bytes (reduced from 1024)
char ThrownByCommand[50] // 50 bytes (reduced from 1024)
} // Total: 305 bytes (was 2048, saved 1743 bytes)
struct _NAVRmsConnectionState {
char OldState[NAV_MAX_CHARS]
char NewState[NAV_MAX_CHARS]
} // Total: 100 bytes
struct _NAVRmsHotlist {
integer LocationId
integer Count
char ClientDefaultLocation
} // Total: 7 bytes
struct _NAVRmsMessage {
char Type[NAV_MAX_CHARS] // 50 bytes
integer TimeOutSeconds // 2 bytes
char Modal // 1 byte
char Title[50] // 50 bytes
char Body[255] // 255 bytes
char ResponseMessage[255] // 255 bytes
} // Total: 613 bytes
struct _NAVRmsClient {
dev Device // 6 bytes
char IsOnline // 1 byte
char IsRegistered // 1 byte
char ClientKey[NAV_MAX_CHARS] // 50 bytes
_NAVRmsServerInformation ServerInformation // 106 bytes
_NAVRmsLocation Location // 402 bytes
_NAVRmsConnection Connection // 360 bytes
_NAVRmsConnectionState ConnectionState // 100 bytes
_NAVKeyValuePair ConfigChange // 1074 bytes
_NAVRmsHotlist Hotlist // 7 bytes
_NAVRmsMessage Message // 613 bytes
_NAVRmsException Exception // 305 bytes
} // Total: 4,025 bytes (was ~10785, saved ~6740 bytes)
struct _NAVRmsMonitorAssetProperties {
char MonitorAssetName[NAV_MAX_CHARS] // 50 bytes
char MonitorAssetDescription[255] // 255 bytes
char MonitorAssetManufacturerName[NAV_MAX_CHARS] // 50 bytes
char MonitorAssetManufacturerURL[255] // 255 bytes
char MonitorAssetModelName[NAV_MAX_CHARS] // 50 bytes
char MonitorAssetModelURL[255] // 255 bytes
char MonitorAssetSerialNumber[NAV_MAX_CHARS] // 50 bytes
char MonitorAssetFirmwareVersion[NAV_MAX_CHARS] // 50 bytes
} // Total: 965 bytes
struct _NAVRmsSource {
dev Device // 6 bytes
char Name[NAV_MAX_CHARS] // 50 bytes
char Description[255] // 255 bytes
} // Total: 311 bytes
struct _NAVRmsRegisteredAsset {
dev Device // 6 bytes
char Key[NAV_MAX_CHARS] // 50 bytes
char Id[NAV_MAX_CHARS] // 50 bytes
char NewRegistration // 1 byte
} // Total: 107 bytes
struct _NAVRmsAssetMethodExecuteEvent {
char AssetKey[NAV_MAX_CHARS]
char Method[NAV_MAX_CHARS]
char Parameter[20][NAV_MAX_CHARS]
} // Total: 1,051 bytes
define_function NAVRmsClientInit(_NAVRmsClient client, tdata args) {
client.Device = args.device
}
define_function NAVRmsConnectionCopy(_NAVRmsConnection source, _NAVRmsConnection destination) {
destination.Name = source.Name
destination.Url = source.Url
destination.Password = source.Password
destination.Enabled = source.Enabled
}
define_function NAVRmsServerInformationCopy(_NAVRmsServerInformation source, _NAVRmsServerInformation destination) {
destination.AppVersion = source.AppVersion
destination.DatabaseVersion = source.DatabaseVersion
destination.TimesyncEnabled = source.TimesyncEnabled
destination.SmtpEnabled = source.SmtpEnabled
destination.MinPollTime = source.MinPollTime
destination.MaxPollTime = source.MaxPollTime
}
define_function NAVRmsLocationCopy(_NAVRmsLocation source, _NAVRmsLocation destination) {
destination.ClientDefaultLocation = source.ClientDefaultLocation
destination.Id = source.Id
destination.Name = source.Name
destination.Owner = source.Owner
destination.PhoneNumber = source.PhoneNumber
destination.Occupancy = source.Occupancy
destination.PrestigeName = source.PrestigeName
destination.Timezone = source.Timezone
destination.AssetLicensed = source.AssetLicensed
}
define_function NAVRmsMessageCopy(_NAVRmsMessage source, _NAVRmsMessage destination) {
destination.Type = source.Type
destination.Title = source.Title
destination.Body = source.Body
destination.TimeOutSeconds = source.TimeOutSeconds
destination.Modal = source.Modal
destination.ResponseMessage = source.ResponseMessage
}
define_function NAVRmsAdapterConnectionUpdate(dev device, _NAVRmsConnection connection) {
if (!device_id(device)) {
return
}
NAVCommand(device, "'CONFIG.CLIENT.NAME-', connection.Name")
NAVCommand(device, "'CONFIG.SERVER.URL-', connection.Url")
NAVCommand(device, "'CONFIG.SERVER.PASSWORD-', connection.Password")
NAVCommand(device, "'CONFIG.CLIENT.ENABLED-', connection.Enabled")
NAVCommand(device, NAV_RMS_CLIENT_REINITIALIZE)
}
define_function NAVRmsAdapterConnectionInit(_NAVRmsClient client) {
NAVRmsAdapterConnectionUpdate(client.Device, client.Connection)
}
define_function NAVRmsExceptionCopy(_NAVRmsException source, _NAVRmsException destination) {
destination.Message = source.Message
destination.ThrownByCommand = source.ThrownByCommand
}
define_function NAVRmsExceptionLog(_NAVRmsException exception, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_ERROR,
"'RMS Client [', NAVDeviceToString(args.device), '] Exception: ', exception.Message")
if (!length_array(exception.ThrownByCommand)) {
return
}
NAVErrorLog(NAV_LOG_LEVEL_ERROR,
"'RMS Client [', NAVDeviceToString(args.device), '] Thrown By Command: ', exception.ThrownByCommand")
}
define_function NAVRmsClientServerInformationLog(_NAVRmsServerInformation server, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Server Info: '")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] App Version: ', server.AppVersion")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Database Version: ', server.DatabaseVersion")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Timesync Enabled: ', NAVBooleanToString(server.TimesyncEnabled)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Smtp Enabled: ', NAVBooleanToString(server.SmtpEnabled)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Min Poll Time: ', itoa(server.MinPollTime)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Max Poll Time: ', itoa(server.MaxPollTime)")
}
define_function NAVRmsClientLocationLog(_NAVRmsLocation location, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Location: '")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Client Default Location: ', NAVBooleanToString(location.ClientDefaultLocation)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Id: ', location.Id")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Name: ', location.Name")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Owner: ', location.Owner")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Phone Number: ', location.PhoneNumber")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Occupancy: ', location.Occupancy")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Prestige Name: ', location.PrestigeName")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Timezone: ', location.Timezone")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Asset Licensed: ', NAVBooleanToString(location.AssetLicensed)")
}
define_function NAVRmsClientConnectionStateLog(_NAVRmsConnectionState state, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Connection State Transition: '")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Old State: ', state.OldState")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] New State: ', state.NewState")
}
define_function NAVRmsClientConfigChangeLog(_NAVKeyValuePair config, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Config Change: '")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Key: ', config.Key")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Value: ', config.Value")
}
define_function NAVRmsHotlistLog(_NAVRmsHotlist hotlist, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Hotlist: '")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Client Default Location: ', NAVBooleanToString(hotlist.ClientDefaultLocation)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Location ID: ', itoa(hotlist.LocationId)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Count: ', itoa(hotlist.Count)")
}
define_function NAVRmsMessageDisplayLog(_NAVRmsMessage message, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Message Display: '")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Type: ', message.Type")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Title: ', message.Title")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Body: ', message.Body")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Timeout seconds: ', itoa(message.TimeOutSeconds)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Modal: ', NAVBooleanToString(message.Modal)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Response Message: ', message.ResponseMessage")
}
define_function NAVRmsClientAssetRegisteredLog(_NAVRmsRegisteredAsset asset, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Asset Registered: '")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Asset Client Key: ', asset.Key")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Asset ID: ', asset.Id")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] New Registration: ', NAVBooleanToString(asset.NewRegistration)")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Asset DPS: ', NAVDeviceToString(asset.Device)")
}
define_function NAVRmsClientAssetMethodExecuteLog(_NAVRmsAssetMethodExecuteEvent event, tdata args) {
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Asset Method Execute: '")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Asset Client Key: ', event.AssetKey")
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Method Key: ', event.Method")
{
// Loop through the parameters
stack_var integer x
for (x = 3; x <= length_array(event.Parameter); x++) {
stack_var integer index
if (event.Parameter[x] == '') {
break
}
index = x - 2
NAVErrorLog(NAV_LOG_LEVEL_INFO,
"'RMS Client [', NAVDeviceToString(args.device), '] Method Argument ', itoa(index), ': ', event.Parameter[x]")
}
}
}
#END_IF // __NAV_FOUNDATION_RMSUTILS__