Wednesday, July 1, 2009

Change Output pin state an Omnicast Map

Overview

I received an email from Doug who would like to raise all gates and lower all gates in a garage (basically hit the output pin on 6 to 20 different logical id’s (depending on which garage) through an Omnicast Map.

The map editor doesn't give this functionality right away but it's fairly easy to get this done with the SDK available in the Maps.

You can download the entire code for this article here:

Map SDK 101
The Omnicast Live Viewer instantiate Internet Explorer in the background and enable access to the GxUIProxyVB SDK. This allows maps to interact with the system in Javascript.

To access the SDK in JavaScript simply use:

window.external.SDK.anysdkfunction(....)
Since the Live Viewer is already authenticated to the Directory, SDK calls are executed in the user security context. Therefore if the user is denied access to a specific camera, the SDK will not have access as well.



How it works

The SDK functions to change output pin value are:
  • FlipIODefault( int OutputPinID )
  • FlipIOInverseDefault( int OutputPinID )

The default state of your output pin is configured in the Config Tool, depending on the attached device it can be configure as Low or High.
Ex:
window.external.SDK.FlipIOInverseDefault( 1 )
To change the state of multiple pins at once, you can simply declare a JavaScript array and iterate through it.


var outputLogicalIDGarage = new Array();
// List all output pin logical ID that you want to trigger at once

outputLogicalIDGarage[0] = 1;
outputLogicalIDGarage[1] = 3;
outputLogicalIDGarage[2] = 5;

// Change the state of Output pin with the logical ID: 1, 3, and 5
for (outputID in outputLogicalIDGarage)
{
window.external.SDK.FlipIOInverseDefault(outputLogicalIDGarage[outputID]);
} 
 


References
JavaScript reference

Jo

0 comments:

Post a Comment