-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRmsEpsonProjectorMonitor.axs
664 lines (553 loc) · 30 KB
/
RmsEpsonProjectorMonitor.axs
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
MODULE_NAME='RmsEpsonProjectorMonitor'(dev vdvRMS, dev vdvDeviceModule, dev dvMonitoredDevice, dev vdvSNMP)
(***********************************************************)
(* FILE_LAST_MODIFIED_ON: 10/03/2016 AT: 21:14:34 *)
(***********************************************************)
(***********************************************************)
(* System Type : NetLinx *)
(***********************************************************)
(*
RmsEpsonProjectorMonitor.axs
SNMP RMS Monitor Module for Epson Projectors
Author: niek.groot@amxaustralia.com.au
No rights or warranties implied
This module implements the following for various Epson projectors models;
- Projector Name
- Firmware Version
- Lamp Hours
- Error Status
- Power Status and Control
- Input Status and Control
This SNMP device monitor module retreives the current status of a device
via SNMP GET requests, and/or receives unsolicited SNMP TRAP updates sent
by the device as changes occur.
This monitor module can optionally provide control of a device by linking
RMS Control Methods to SNMP SET requests.
Devices are identified by by .iso.org.dod.internet.mgmt.mib-2.system.sysObjectID,
which is matched to a manufacturer, model, and asset type through lookup
tables defined in the DEFINE_CONSTANTS section of this module.
The SnmpMonitorCommon.axi include provides required SNMP API functions and
caches status parameter values, ensuring that only changs are sent to RMS.
Whilst tested for broad compatibilty, this code should be considered a
technology demo and should by carefully evaluated before using in a
production environment.
This module uses a seperately included SNMP Manager (snmp-manager.axs)
module for ease of adoption and customisation.
Debug information has been included for clarity, but when enabled can
significantly affect performance. Only enable debug output when necessary.
Please consider contributing by submitting bug fixes and improvements.
Usage:
DEFINE_MODULE 'RmsGenericSnmpDeviceMonitor' mdlSnmpDeviceMonitor(dev <rms virtual device>, dev <monitor module virtual device>, dev <monitor module virtual device>, dev <snmp manager virtual device>);
Configuration:
The SNMP agent address, port, and community must be configured. The
listener port is configured globally for the SNMP manager module.
Set an update interval if actively polling a device via SNMP GET. Disable
the update interval if the device will send SNMP TRAPs as changes occur.
send_command vdvDeviceModule, "'DEBUG-', itoa(<AMX_ERROR|AMX_WARNING|AMX_INFO|AMX_DEBUG>)"; // Sets the debug message filter level via the set_log_level() function.
send_command vdvDeviceModule, "'PROPERTY-IP_ADDRESS,', '<address>'"; // Device IP address. This will be used to filter SNMP TRAP and GET responses.
send_command vdvDeviceModule, "'PROPERTY-PORT,', itoa(<agent port>)"; // Device SNMP port. Default: 161.
send_command vdvDeviceModule, "'PROPERTY-COMMUNITY,', '<community>'"; // Device SNMP community name. Default: public.
send_command vdvDeviceModule, "'PROPERTY-ASSET_NAME', '<name>'"; // Override the asset name, which is otherwise retrieved from iso.org.dod.internet.mgmt.mib-2.system.sysName
send_command vdvDeviceModule, "'PROPERTY-CONTACT_TIMEOUT', itoa(<seconds>)"; // Time in seconds after which, if no status updates have been received from the device, to mark the device as offline. This value must be greater than the POLL_INTERVAL. Default: 190 seconds.
send_command vdvDeviceModule, "'POLL_INTERVAL', itoa(<seconds>)|DISABLE`"; // Time in seconds between requests for device status updates. Set this to 0 (disable) if the device will send SNMP TRAPs as changes occur. Default: 60 aeconds.
send_command vdvDeviceModule, "'REINIT'"; // Re-initialise the module and start the polling interval process.
*)
(***********************************************************)
(* CONSTANT DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_CONSTANT
char MONITOR_NAME[] = 'RMS Epson Projector Monitor';
char MONITOR_DEBUG_NAME[] = 'RmsEpsonProjectorMonitor';
char MONITOR_VERSION[] = '4.5.3';
char ENTERPRISE_NUMBERS[][2][15] = { // RMS Asset manufacturer name. https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers
{'9', 'Cisco'},
{'11', 'HP'},
{'311', 'Microsoft'},
{'2636', 'Juniper'},
{'8942', 'AMX'},
{'14823', 'Aruba'},
{'25053', 'Ruckus'},
{'41639', 'SVSI'},
{'1248', 'Epson'}
}
char ENTERPRISE_MODELS[][2][15] = { // RMS Asset model name. http://www.dpstele.com/snmp/what-does-oid-network-elements.php
{'311.1.1.3.1.1', 'Workstation'},
{'311.1.1.3.1.2', 'Server'}
}
char ENTERPRISE_TYPES[][2][15] = { // RMS Asset type key. These must exist in RMS database for successful asset registration!
{'311.1.1.3.1.1', 'Utility'},
{'311.1.1.3.1.2', 'Utility'},
{'1248.4.1', 'VideoProjector'}
}
char LAMP_LIFE[][2][15] = { // RMS Asset type key. These must exist in RMS database for successful asset registration!
{'1248.4.1', '3000'}
}
char OID_Epson_LampHours[] = '1.3.6.1.4.1.1248.4.1.1.1.1.0'; // EPSON.epVDDivision.epProjector.epIMPrivate.epIMInformation.epIMLampTimer
char OID_Epson_FirmwareVersion[] = '1.3.6.1.4.1.1248.4.1.1.1.8.0'; // EPSON.epVDDivision.epProjector.epIMPrivate.epIMInformation.epIMFirmwareVersion
char OID_Epson_PWStatus[] = '1.3.6.1.4.1.1248.4.1.1.1.9.0'; // EPSON.epVDDivision.epProjector.epIMPrivate.epIMInformation.epIMPwStatus
char OID_Epson_Power[] = '1.3.6.1.4.1.1248.4.1.1.2.1.0'; // EPSON.epVDDivision.epProjector.epIMPrivate.epIMControl.epIMPowerControl
char OID_Epson_InputSource[] = '1.3.6.1.4.1.1248.4.1.1.2.2.0'; // EPSON.epVDDivision.epProjector.epIMPrivate.epIMControl.epIMInputSourceChange
char OID_Epson_Name[] = '1.3.6.1.4.1.1248.4.1.1.2.7.0'; // EPSON.epVDDivision.epProjector.epIMPrivate.epIMControl.epIMPnameControl
char INPUT_SOURCES[][2][19] = {
{'10', 'INPUT1 (D-Sub)'},
{'11', 'INPUT1 (RGB)'},
{'14', 'INPUT1 (Component)'},
{'20', 'INPUT2 (D-Sub)'},
{'21', 'INPUT2 (RGB)'},
{'24', 'INPUT2 (Component)'},
{'30', 'INPUT3 (DVI)'},
{'31', 'INPUT3 (D-RGB)'},
{'33', 'INPUT3 (RGB-Video)'},
{'34', 'INPUT3 (YCbCr)'},
{'35', 'INPUT3 (YPbPr)'},
{'40', 'VIDEO'},
{'42', 'VIDEO (S)'},
{'45', 'VIDEO1 (BNC)'},
{'41', 'VIDEO2 (RCA)'}
}
char PROJECTOR_STATUS[][2][9] = {
{'01', 'Standby'},
{'02', 'Warmup'},
{'03', 'Normal'},
{'04', 'Cool down'},
{'FF', 'Abnormal'}
}
char WARNING_TYPES[][2][22] = {
{'0000', 'OK'},
{'0001', 'Lamp life'},
{'0002', 'OK No signal'},
{'0003', 'OK Unsupported signal'},
{'0004', 'Air filter'},
{'0005', 'High temperature'}
}
char ALARM_TYPES[][2][27] = {
{'0000', 'OK'},
{'0001', 'Lamp ON failure'},
{'0002', 'Lamp lid'},
{'0003', 'Lamp burnout (ON, then OFF)'},
{'0004', 'Fan'},
{'0005', 'Temperature sensor'},
{'0006', 'High temperature'},
{'0007', 'Interior (system)'}
}
(***********************************************************)
(* DATA TYPE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_TYPE
(***********************************************************)
(* VARIABLE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_VARIABLE
volatile char MONITOR_ASSET_NAME[50] = ''; // This is usually declared as a constant in the RMS SDK monitor modules
volatile char MONITOR_ASSET_GLOBALKEY[150] = '';
volatile integer METADATA_PROPERTY_SOURCE_INPUT_COUNT = 0; // Populated with with source count in varbind_updated_callback()
volatile char METADATA_PROPERTY_SOURCE_INPUT[255] = ''; // Populated with with source list in varbind_updated_callback()
volatile integer METADATA_PROPERTY_LAMP_THRESHOLD = 2000; // Populated with with model-specific value in varbind_updated_callback()
volatile integer METADATA_PROPERTY_LAMP_WARMUP_TIME = 30;
volatile integer METADATA_PROPERTY_LAMP_COOLDOWN_TIME = 30;
(***********************************************************)
(* INCLUDE DEFINITIONS GO BELOW *)
(***********************************************************)
/*
CAVEAT: RegisterAssetParametersSnapiComponents() will register an source.input
parameter as per HAS_SOURCE_SELECT with an enumerated list of sources
limited to DUET_MAX_PARAM_LEN (100 characters). Define an larger
DUET_MAX_PARAM_LEN if the device has a large source list.
*/
#DEFINE DUET_MAX_PARAM_LEN 255
#INCLUDE 'SNAPI';
#DEFINE SNAPI_MONITOR_MODULE;
#DEFINE EXCLUDE_RMS_SYSTEM_POWER_CHANGE_CALLBACK
#DEFINE EXCLUDE_RMS_SYSTEM_MODE_CHANGE_CALLBACK
#INCLUDE 'RmsMonitorCommon';
/*
CAVEAT: RegisterAssetParametersSnapiComponents() will register a lamp.consumption
parameter as per HAS_LAMP with a hard-coded 2000 hour upper limit.
This example addresses this by re-registering the lamp.consumption paramter
with an adjusted value range.
*/
#DEFINE HAS_POWER
#DEFINE HAS_LAMP
#DEFINE HAS_SOURCE_SELECT
#INCLUDE 'RmsNlSnapiComponents';
#DEFINE MAX_NUM_VARBINDS 25 // Number of parameter varbinds to cache. Default: 25.
#DEFINE MAX_LEN_VARBIND_VALUE 50 // Maximum length of cached parameter varbind value. Default: 50 as per RmsAssetParameter.initialValue in RmsApi
#DEFINE INCLUDE_VARBIND_UPDATED_CALLBACK
#DEFINE INCLUDE_DEVICE_INFO_POLL_CALLBACK
#DEFINE INCLUDE_DEVICE_STATUS_POLL_CALLBACK
#INCLUDE 'SnmpMonitorCommon';
(***********************************************************)
(* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *)
(***********************************************************)
(***********************************************************)
(* Name: RegisterAsset *)
(* Args: RmsAsset asset data object to be registered . *)
(* *)
(* Desc: This is a callback method that is invoked by *)
(* RMS to notify this module that it is time to *)
(* register this asset. *)
(* *)
(* This method should not be invoked/called *)
(* by any user implementation code. *)
(***********************************************************)
DEFINE_FUNCTION RegisterAsset(RmsAsset asset)
{
asset.clientKey = RmsDevToString(dvMonitoredDevice);
asset.name = array_get(varbinds, OID_Epson_Name);
asset.assetType = array_get(ENTERPRISE_TYPES, sysObjectID_to_model(array_get(varbinds, OID_sysObjectID)));
asset.description = array_get(varbinds, OID_sysDescr);
asset.manufacturerName = array_get(ENTERPRISE_NUMBERS, sysObjectID_to_enterprise(array_get(varbinds, OID_sysObjectID)));
asset.modelName = array_get(ENTERPRISE_MODELS, sysObjectID_to_model(array_get(varbinds, OID_sysObjectID)));
asset.serialNumber = '';
asset.firmwareVersion = array_get(varbinds, OID_Epson_FirmwareVersion);
if (length_string(asset.manufacturerName) && length_string(asset.modelName) && length_string(asset.serialNumber)) {
MONITOR_ASSET_GLOBALKEY = "plain_string(asset.serialNumber), '-', plain_string(asset.modelname), '-', plain_string(asset.manufacturerName)";
asset.globalKey = MONITOR_ASSET_GLOBALKEY;
}
// Override asset name with friendly name if specified
if (length_string(MONITOR_ASSET_NAME)) {
asset.name = MONITOR_ASSET_NAME;
}
if (!length_string(asset.name)) asset.name = 'Unknown';
if (!length_string(asset.assetType)) asset.assetType = RMS_ASSET_TYPE_UNKNOWN;
if (!length_string(asset.manufacturerName)) asset.manufacturerName = 'Unknown';
if (!length_string(asset.modelName)) asset.modelName = 'Unknown';
RmsAssetRegister(dvMonitoredDevice, asset);
}
(***********************************************************)
(* Name: RegisterAssetParameters *)
(* Args: -none- *)
(* *)
(* Desc: This is a callback method that is invoked by *)
(* RMS to notify this module that it is time to *)
(* register this asset's parameters to be monitored *)
(* by RMS. *)
(* *)
(* This method should not be invoked/called *)
(* by any user implementation code. *)
(***********************************************************)
DEFINE_FUNCTION RegisterAssetParameters()
{
// Register all snapi HAS_xyz components
RegisterAssetParametersSnapiComponents(assetClientKey);
// Override the lamp consumption range set in RegisterAssetParametersSnapiComponents(), which is statically defined as 0-2000 hours.
RmsAssetParameterEnqueueDecimalWithBargraph(assetClientKey,
'lamp.consumption',
'Lamp Consumption',
'Current usage of the lamp life',
RMS_ASSET_PARAM_TYPE_LAMP_USAGE,
0,
0,
METADATA_PROPERTY_LAMP_THRESHOLD + 1000, // As an exception to the rule (editable fields are not overwritten by code), these values /do/ overwrite values changed via the RMS dashboard.
'Hours',
RMS_ALLOW_RESET_YES,
0,
RMS_TRACK_CHANGES_YES,
'lamp.consumption');
RmsAssetParameterEnqueueString(assetClientKey,
'uptime',
'Uptime', 'Time elapsed since the SNMP agent on the host was started',
RMS_ASSET_PARAM_TYPE_NONE,
'', '',
RMS_ALLOW_RESET_NO, '',
RMS_TRACK_CHANGES_NO);
RmsAssetParameterEnqueueString(assetClientKey,
'status.projector',
'Projector Status', 'Operational status',
RMS_ASSET_PARAM_TYPE_NONE,
array_get(PROJECTOR_STATUS, '03'), '', // For parameters with thresholds, set a default value that does not trigger the threshold as to avoid erronous alerts
RMS_ALLOW_RESET_NO, '',
RMS_TRACK_CHANGES_NO);
RmsAssetParameterThresholdEnqueue(assetClientKey,
'status.projector',
'Error',
RMS_STATUS_TYPE_MAINTENANCE,
RMS_ASSET_PARAM_THRESHOLD_COMPARISON_EQUAL,
array_get(PROJECTOR_STATUS, 'FF'));
RmsAssetParameterEnqueueString(assetClientKey,
'status.warning',
'Warning Status', 'Warning status',
RMS_ASSET_PARAM_TYPE_NONE,
array_get(WARNING_TYPES, '0000'), '',
RMS_ALLOW_RESET_NO, '',
RMS_TRACK_CHANGES_YES);
RmsAssetParameterThresholdEnqueue(assetClientKey,
'status.warning',
'Warning',
RMS_STATUS_TYPE_MAINTENANCE,
RMS_ASSET_PARAM_THRESHOLD_COMPARISON_DOES_NOT_CONTAIN,
array_get(WARNING_TYPES, '0000'));
RmsAssetParameterEnqueueString(assetClientKey,
'status.alarm',
'Alarm Status', 'Alarm status',
RMS_ASSET_PARAM_TYPE_NONE,
array_get(ALARM_TYPES, '0000'), '',
RMS_ALLOW_RESET_NO, '',
RMS_TRACK_CHANGES_YES);
RmsAssetParameterThresholdEnqueue(assetClientKey,
'status.alarm',
'Alarm',
RMS_STATUS_TYPE_MAINTENANCE,
RMS_ASSET_PARAM_THRESHOLD_COMPARISON_DOES_NOT_CONTAIN,
array_get(ALARM_TYPES, '0000'));
// submit all parameter registrations
RmsAssetParameterSubmit(assetClientKey);
}
(***********************************************************)
(* Name: SynchronizeAssetParameters *)
(* Args: -none- *)
(* *)
(* Desc: This is a callback method that is invoked by *)
(* RMS to notify this module that it is time to *)
(* update/synchronize this asset parameter values *)
(* with RMS. *)
(* *)
(* This method should not be invoked/called *)
(* by any user implementation code. *)
(***********************************************************)
DEFINE_FUNCTION SynchronizeAssetParameters()
{
// This callback method is invoked when either the RMS server connection
// has been offline or this monitored device has been offline from some
// amount of time. Since the monitored parameter state values could
// be out of sync with the RMS server, we must perform asset parameter
// value updates for all monitored parameters so they will be in sync.
// Update only asset monitoring parameters that may have changed in value.
/*
CAVEAT: keyLookup() in RmsNlSnapiComponents does not correctly cache
values, and keyFind() does not correctly recall them, preventing
SynchronizeAssetParametersSnapiComponents() from updating cached values
when the connection to RMS becomes online.
Immediate parameter updates /are/ sent correctly when the connection to
RMS is online (because caching is not necessary).
Fix for RmsNlSnapiComponents.axi from RMS SDK 4.5.3 (and probably others):
112a113
> uKeys[nKeyCount].cName = cKey
*/
// Synchronize all snapi HAS_xyz components
SynchronizeAssetParametersSnapiComponents(assetClientKey);
RmsAssetParameterEnqueueSetValue(assetClientKey, 'uptime', timeticks_to_time(atol_unsigned(array_get(varbinds, OID_sysUpTime))));
RmsAssetParameterEnqueueSetValue(assetClientKey, 'status.projector', array_get(PROJECTOR_STATUS, mid_string(array_get(varbinds, OID_Epson_PWStatus), 1, 2)));
RmsAssetParameterEnqueueSetValue(assetClientKey, 'status.warning', array_get(WARNING_TYPES, mid_string(array_get(varbinds, OID_Epson_PWStatus), 4, 4)));
RmsAssetParameterEnqueueSetValue(assetClientKey, 'status.alarm', array_get(ALARM_TYPES, mid_string(array_get(varbinds, OID_Epson_PWStatus), 9, 4)));
RmsAssetParameterUpdatesSubmit(assetClientKey); // Corrected. Monitor modules included with the RMS SDK incorrectly call RmsAssetParameterSubmit() here
}
(***********************************************************)
(* Name: ResetAssetParameterValue *)
(* Args: parameterKey - unique parameter key identifier *)
(* parameterValue - new parameter value after reset *)
(* *)
(* Desc: This is a callback method that is invoked by *)
(* RMS to notify this module that an asset *)
(* parameter value has been reset by the RMS server *)
(* *)
(* This method should not be invoked/called *)
(* by any user implementation code. *)
(***********************************************************)
DEFINE_FUNCTION ResetAssetParameterValue(CHAR parameterKey[],CHAR parameterValue[])
{
// if your monitoring module performs any parameter
// value tracking, then you may want to update the
// tracking value based on the new reset value
// received from the RMS server.
}
(***********************************************************)
(* Name: RegisterAssetMetadata *)
(* Args: -none- *)
(* *)
(* Desc: This is a callback method that is invoked by *)
(* RMS to notify this module that it is time to *)
(* register this asset's metadata properties with *)
(* RMS. *)
(* *)
(* This method should not be invoked/called *)
(* by any user implementation code. *)
(***********************************************************)
DEFINE_FUNCTION RegisterAssetMetadata()
{
// Exclude registration of warmup/cooldown metadata. Remove this as required.
RmsAssetMetadataExclude(assetClientKey, 'projector.lamp.warmup.time');
RmsAssetMetadataExclude(assetClientKey, 'projector.lamp.cooldown.time');
// Register all snapi HAS_xyz components
RegisterAssetMetadataSnapiComponents(assetClientKey);
if (length_string(MONITOR_ASSET_GLOBALKEY)) {
RmsAssetMetadataEnqueueString(assetClientKey, 'asset.globalKey', 'Asset Global Key', MONITOR_ASSET_GLOBALKEY);
} else {
RmsAssetMetadataEnqueueString(assetClientKey, 'asset.globalKey', 'Asset Global Key', 'Not specified (auto-generated)');
}
RmsAssetMetadataEnqueueString(assetClientKey, 'sysObjectID', 'sysObjectID', array_get(varbinds, OID_sysObjectID)); // NOTE: MetadataName is limited to 50 characters by the RMS Server
RmsAssetMetadataEnqueueString(assetClientKey, 'hostname', 'Host Name', array_get(varbinds, OID_sysName));
RmsAssetMetadataEnqueueString(assetClientKey, 'host-ip-address', 'Host IP Address', snmp_agent.address);
RmsAssetMetadataEnqueueHyperlink(assetClientKey, 'link-web-config', 'Web Configuration', "'http://', snmp_agent.address, '/'", "'http://', snmp_agent.address, '/'");
RmsAssetMetadataEnqueueString(assetClientKey, 'snmp.community', 'SNMP Community', snmp_agent.community);
RmsAssetMetadataEnqueueString(assetClientKey, 'snmp.port', 'SNMP Port', itoa(snmp_agent.port));
if (STATUS_POLL_TIMES[2] > 0) {
RmsAssetMetadataEnqueueString(assetClientKey, 'poll.interval', 'Poll Interval (seconds)', itoa(STATUS_POLL_TIMES[2] / 1000));
} else {
RmsAssetMetadataEnqueueString(assetClientKey, 'poll.interval', 'Poll Interval', 'DISABLED');
}
RmsAssetMetadataEnqueueString(assetClientKey, 'contact.timeout', 'Contact Timeout (seconds)', itoa(CONTACT_TIMEOUT_TIMES[1] / 1000));
RmsAssetMetadataEnqueueString(assetClientKey, 'projector.name', 'Projector Name', array_get(varbinds, OID_Epson_Name));
RmsAssetMetadataSubmit(assetClientKey);
}
(***********************************************************)
(* Name: SynchronizeAssetMetadata *)
(* Args: -none- *)
(* *)
(* Desc: This is a callback method that is invoked by *)
(* RMS to notify this module that it is time to *)
(* update/synchronize this asset metadata properties *)
(* with RMS if needed. *)
(* *)
(* This method should not be invoked/called *)
(* by any user implementation code. *)
(***********************************************************)
DEFINE_FUNCTION SynchronizeAssetMetadata()
{
/*
This module does not synchronise any of the previously registered metadata
here, beacuse updates (i.e. because the device has been replaced) would
also trigger a re-registration of the asset.
*/
// Synchronize all snapi HAS_xyz components
if (SynchronizeAssetMetadataSnapiComponents(assetClientKey)) {
RmsAssetMetadataSubmit(assetClientKey);
}
}
(***********************************************************)
(* Name: RegisterAssetControlMethods *)
(* Args: -none- *)
(* *)
(* Desc: This is a callback method that is invoked by *)
(* RMS to notify this module that it is time to *)
(* register this asset's control methods with RMS. *)
(* *)
(* This method should not be invoked/called *)
(* by any user implementation code. *)
(***********************************************************)
DEFINE_FUNCTION RegisterAssetControlMethods()
{
//Register all snapi HAS_xyz components
RegisterAssetControlMethodsSnapiComponents(assetClientKey);
// when done enqueuing all asset control methods and
// arguments for this asset, we just need to submit
// them to finalize and register them with the RMS server
RmsAssetControlMethodsSubmit(assetClientKey);
}
(***********************************************************)
(* Name: ExecuteAssetControlMethod *)
(* Args: methodKey - unique method key that was executed *)
(* arguments - array of argument values invoked *)
(* with the execution of this method. *)
(* *)
(* Desc: This is a callback method that is invoked by *)
(* RMS to notify this module that it should *)
(* fullfill the execution of one of this asset's *)
(* control methods. *)
(* *)
(* This method should not be invoked/called *)
(* by any user implementation code. *)
(***********************************************************)
DEFINE_FUNCTION ExecuteAssetControlMethod(CHAR methodKey[], CHAR arguments[])
{
debug("'<<< EXECUTE CONTROL METHOD : [', methodKey, '] args=', arguments, ' >>>'");
switch (methodKey) {
case 'projector.lamp.power': {
snmp_set(OID_Epson_Power, "ASN1_TAG_INTEGER", itoa(RmsBooleanValue(arguments)));
}
case 'source.input': {
snmp_set(OID_Epson_InputSource, "ASN1_TAG_OCTET_STRING", INPUT_SOURCES[array_find_value(INPUT_SOURCES, arguments)][ARRAY_KEY]);
}
}
}
// #DEFINE INCLUDE_DEVICE_INFO_POLL_CALLBACK
define_function device_info_poll_callback() {
/*
SnmpMonitorCommon will automatically poll the following
OIDs when the device becomes reachable.
snmp_get(OID_sysDescr);
snmp_get(OID_sysObjectID);
snmp_get(OID_sysName);
Add additional device-specific OIDs to poll here.
*/
snmp_get(OID_Epson_Name);
snmp_get(OID_Epson_FirmwareVersion);
}
// #DEFINE INCLUDE_DEVICE_STATUS_POLL_CALLBACK
define_function device_status_poll_callback() {
/*
SnmpMonitorCommon will automatically poll the following
OIDs at regular intervals:
snmp_get(OID_sysUpTime);
Add additional device-specific OIDs to automatically poll
when the device is communicating and data is initialized here:
*/
snmp_get(OID_Epson_LampHours);
snmp_get(OID_Epson_Power);
snmp_get(OID_Epson_PWStatus);
if ([vdvDeviceModule, POWER_FB]) { // Only available when device is powered on
snmp_get(OID_Epson_InputSource);
}
}
// #DEFINE INCLUDE_VARBIND_UPDATED_CALLBACK
define_function varbind_updated_callback(char oid[], char value[]) {
if (![vdvDeviceModule, DATA_INITIALIZED]) {
if (
length_string(array_get(varbinds, OID_sysDescr)) &&
length_string(array_get(varbinds, OID_sysObjectID)) &&
length_string(array_get(varbinds, OID_sysName)) &&
length_string(array_get(varbinds, OID_Epson_Name)) &&
length_string(array_get(varbinds, OID_Epson_FirmwareVersion))
) {
stack_var volatile integer i;
// INPUTCOUNT-<count>
send_command vdvDeviceModule, "'INPUTCOUNT-', itoa(length_array(INPUT_SOURCES))";
for (i = 1; i <= length_array(INPUT_SOURCES); i++) {
// INPUTPROPERTIES-<index>,<inputGroup>,<signalType>,<deviceLabel>,<displayName>
send_command vdvDeviceModule, "'INPUTPROPERTIES-"', itoa(i), ',', itoa(i), ',', INPUT_SOURCES[i][ARRAY_VALUE], ',', INPUT_SOURCES[i][ARRAY_VALUE], ',', INPUT_SOURCES[i][ARRAY_VALUE], '"'";
}
METADATA_PROPERTY_LAMP_THRESHOLD = atoi(array_get(LAMP_LIFE, sysObjectID_to_model(array_get(varbinds, OID_sysObjectID))));
if (!METADATA_PROPERTY_LAMP_THRESHOLD) METADATA_PROPERTY_LAMP_THRESHOLD = 2000;
on[vdvDeviceModule, DATA_INITIALIZED];
}
}
if (parametersRegistered) {
switch (oid) {
case OID_sysUpTime: RmsAssetParameterSetValue(assetClientKey, 'uptime', timeticks_to_time(atol_unsigned(value)));
case OID_Epson_PWStatus: {
RmsAssetParameterSetValue(assetClientKey, 'status.projector', array_get(PROJECTOR_STATUS, mid_string(value, 1, 2)));
RmsAssetParameterSetValue(assetClientKey, 'status.warning', array_get(WARNING_TYPES, mid_string(value, 4, 4)));
RmsAssetParameterSetValue(assetClientKey, 'status.alarm', array_get(ALARM_TYPES, mid_string(value, 9, 4)));
}
}
}
// SNAPI redirect (for handling by RmsNlSnapiComponents)
switch (oid) {
case OID_Epson_Power: {
[vdvDeviceModule, POWER_FB] = atoi(value);
}
case OID_Epson_LampHours: {
// LAMPTIME-<hours>
send_command vdvDeviceModule, "'LAMPTIME-', value";
}
case OID_Epson_InputSource: {
// INPUTSELECT-<index>
send_command vdvDeviceModule, "'INPUTSELECT-', itoa(array_find(INPUT_SOURCES, value))";
}
}
}
(***********************************************************)
(* STARTUP CODE GOES BELOW *)
(***********************************************************)
DEFINE_START
(***********************************************************)
(* THE EVENTS GO BELOW *)
(***********************************************************)
DEFINE_EVENT
(***********************************************************)
(* THE ACTUAL PROGRAM GOES BELOW *)
(***********************************************************)
DEFINE_PROGRAM
(***********************************************************)
(* END OF PROGRAM *)
(* DO NOT PUT ANY CODE BELOW THIS COMMENT *)
(***********************************************************)