<< Click to Display Table of Contents >> Navigation: Multi-Protocol MasterOPC Server > Lua 5.1 Reference Manual > Function library > The SERVER Library > Functions to Operate with Devices |
server.CheckUpdateCurrentDevice
server.CheckUpdateDeviceByName
server.GetCurrentDeviceAddress
server.SetCurrentDeviceAddress
server.CheckUpdateCurrentDevice
The function returns FALSE after polling a device. A function result can be used in order to reset a tag of forced poll (after usage of server.PollCurrentDevice ).
Example
––In a script after writing:
function OnWrite()
tag = server.ReadCurrentTag(); --read a tag value
if tag then
server.PollCurrentDevice(); --if the tag is TRUE then poll the device
end
end
––In a script after reading:
function OnRead()
local b = server.CheckUpdateCurrentDevice() –-contol poll execution
server.WriteCurrentTag(b,192); --reset the tag
end
server.CheckUpdateDeviceByName
The function returns FALSE after polling a device specified in the function argument. A function result can be used in order to reset a tag of forced poll (after usage of server.PollDeviceByName ).
Example
––In a script after writing:
function OnWrite()
tag = server.ReadTag("Node1.Device1.Tag1"); --read a tag value
if tag then
--if the tag is TRUE then poll the device:
server.PollDeviceByName("Node1.Device1");
end
end
––In a script after reading:
function OnRead()
–-contol poll execution:
local b = server.CheckUpdateCurrentDevice("Node1.Device1")
––reset the tag:
server.WriteTag("Node1.Device1.Tag1",b,192);
end
server.GetCurrentDeviceAddress
Returns a value of the Address parameter of the current device (see The Dialog of Device Parameters ).
Example
local Address = server.GetCurrentDeviceAddress( )
Returns a period of poll of current device by ms.
Returns true if an error is detected in the current device, and false, otherwise.
Example
local err = server.GetCurrentDeviceError( )
Returns number of on-error repeated requests defined in the current device. This function can be invoked from a script of a device, a sub-device or a tag.
Example
n=server.GetCurrentDeviceRetry();
Initiates forced (out of order) poll of the current device.
Example
server.PollCurrentDevice();
Initiates forced (out of order) poll of a device by a device name.
Example
server.PollDeviceByName("Node1.Device1");
Returns a value specified for an axtra property of the current device (see Setting Extra Properties ).
The function parameter is an extra property name.
Example
local IsCRC = server.ReadDeviceExtProperty("IsCRC");
server.SetCurrentDeviceAddress
Sets an address of a current device. This function is available only in unlimited versions.
Sets a period of poll of a current device by ms.
Sets number of on-error repeated requests to a current device. This function can be invoked from a script of a device, a sub-device or a tag.
The function is used to start or stop poll of a device.
This function can be invoked from a script of a tag.
Example
val,q=server.ReadCurrentTag(); --get a tag value
if val==true then --if the value is TRUE
server.SetDeviceToOnOff (true); --run poll of the device
else
server.SetDeviceToOnOff (false); --otherwise, stop the poll
end;
Also, the function may have a second argument - the path to the disconnected device (if the path is not specified, then the device to be turned off in which this script is executed)
server.SetDeviceToOnOff(true,"Node1.Device1"); --run poll of the device