Which server am I connected to?

I have seen a lot of functions that give information on the servers, but the one i am looking for is elusive.

ServerIsOnline wil give me the status of the servers - both the primary and standby.

However, I am only communicating to one of them at a time.

How would I find out which one I am talking to?

Parents
  • Hi Michael,

    MsgRPC calls can only return information when set to blocking. To be able to display this information, you could run a cicode function on the I/O server that writes the information to a Variable Tag at certain intervals:

    FUNCTION MyIODeviceInfoLoop(STRING sIODevice, STRING sTagName)

    STRING sActiveServer;

    STRING sNumberOfErrors;

    WHILE TRUE DO

    sActiveServer = IODeviceInfo(sIODevice, 17);

    IF ProcessIsServer("IOServer", "", sActiveServer) THEN

    // We are the active I/O server for this I/O device

    sNumberOfErrors = IODeviceInfo(sIODevice, 20);

    TagWrite(sTagName, sNumberOfErrors);

    END

    SleepMS(1000);  // Update the info every second

    END

    END

     

    You can start this function on both I/O servers using:

    TaskNew("MyIODeviceInfoLoop", "^"Device^", ^"DeviceInfoTag^"", 8);

    assuming your I/O device is called "Device" and the tag you like to display is called "DeviceInfoTag".

     

    Best regards,

    Patrick

Reply
  • Hi Michael,

    MsgRPC calls can only return information when set to blocking. To be able to display this information, you could run a cicode function on the I/O server that writes the information to a Variable Tag at certain intervals:

    FUNCTION MyIODeviceInfoLoop(STRING sIODevice, STRING sTagName)

    STRING sActiveServer;

    STRING sNumberOfErrors;

    WHILE TRUE DO

    sActiveServer = IODeviceInfo(sIODevice, 17);

    IF ProcessIsServer("IOServer", "", sActiveServer) THEN

    // We are the active I/O server for this I/O device

    sNumberOfErrors = IODeviceInfo(sIODevice, 20);

    TagWrite(sTagName, sNumberOfErrors);

    END

    SleepMS(1000);  // Update the info every second

    END

    END

     

    You can start this function on both I/O servers using:

    TaskNew("MyIODeviceInfoLoop", "^"Device^", ^"DeviceInfoTag^"", 8);

    assuming your I/O device is called "Device" and the tag you like to display is called "DeviceInfoTag".

     

    Best regards,

    Patrick

Children
No Data