Program Structure and Events |
Function |
Return Type |
Description |
Example |
setup() |
N/A |
Enables CIP on the device. |
CIP.setup(); |
setIdentity(identity) |
N/A |
Sets identity object of the device. |
var identity='{"vendor":939,"type":1,"code":9046,"revision":"1.1","status":"","serial":12346,"name":"pt cip1"}';
CIP.setIdentity(identity); |
addObject(classCode, instanceId, data) |
N/A |
Creates a new object type for the device. |
var ptObject = {};
ptObject.data = 0;
CIP.addObject(3000,1,JSON.stringify(ptObject)); |
removeObject(classCode, instanceId) |
N/A |
Removes an existing object type from the device. |
CIP.removeObject(3000,1); |
getObjectAttribute(classCode, instanceId, attributeId) |
attribute |
Gets object attribute value. |
CIP.getObjectAttribute(3000,1,2); |
listIdentityAll() |
N/A |
Finds all CIP enabled devices and lists their identities. |
CIP.listIdentityAll(); |
connect(ip) |
bool |
Connects to a CIP device. |
var client = new CIPClient();
client.connect("10.0.0.2"); |
close() |
N/A |
Closes a CIP connection. |
client.close(); |
listIdentity() |
N/A |
Retrieves identity of the device. |
client.listIdentity(); |
getAttributeSingle(classId, instanceId, attributeId) |
N/A |
Retrieves an attribute of an object based on the class, instance, and attribute. |
client.getAttributeSingle(1,1,7); |
getAttributesAll(classId, instanceId) |
N/A |
Retrieves all attributes of an object based on the class and instance. |
client.getAttributesAll(245,0); |
setAttributesAll(classId, instanceId, data) |
N/A |
Sets all attributes of an object based on the class and instance. |
var ptObject = {};
ptObject.data = 900;
client.setAttributesAll(3000,1,JSON.stringify(ptObject));
|
forwardOpen(ip, classId, instanceId, timer) |
bool |
Initiates communication with a device using the IP address, class, and instance. |
client.forwardOpen("10.0.0.2", 3000, 1, 5000); |
forwardClose() |
N/A |
Closes the connection opened by forwardOpen. |
client.forwardClose(); |
onConnectionChange(event) |
N/A |
Sets the callback that is invoked when TCP connection state changes. |
client.onConnectionChange = function(event) {}; |
onReceive(data) |
N/A |
Sets the callback that is invoked when data is received. |
client.onReceive = function(data) {}; |