Applies To:
  • CitectSCADA 6.1, 7.0
  • CitectHMI 6.1, 7.0
  • CitectFacilities 6.1, 7.0
  • CitectSCADA Batch 6.1, 7.0
  • CitectSCADA Pocket 6.1, 7.0

Summary:

How do I detect which IO server is the Active one for a particular I/O Device (or devices) at runtime.


Solution:
Some customers need to detect the active IO server at runtime to perform some activities such like data logging. With the introduction of ServerInfoEx () in 6.1, it is not hard to do so:

FUNCTION active_ioserver_detection_v2() 
STRING sLocalServerName 
    
sLocalServerName = ServerInfoEx ( "Server" , 0 , "IOServer" , "my_cluster" )
    
IF(IODeviceInfo("mydev" , 17) = sLocalServerName) THEN 
        
Message("Server Information", "This is the active IO server", 64);
                
//Place your code here 
    
END
END

NOTE: THE ARGUMENTS FOR ServerInfoEx ARE CASE SENSITIVE AT THE TIME OF WRITING.

Prior V6.1, some hard coding is needed:

FUNCTION active_ioserver_detection()
STRING sPrimary = "primaryioserver" ; //primary IO server name
STRING sStandby = "standbyioserver" ; //standby IO server name
STRING sLocalPCName;
STRING sLocalServerName; 

    
sLocalPCName = ServerInfo ( "client" , 0 ) ; // get the IO server's computer name 
    
IF(sLocalPCName = "SYD-D-XXXX") THEN //This part of the Cicode 
        
sLocalServerName = sPrimary;     //maps the computer name 
    
ELSE                                 //to IO server names 
        
sLocalServerName = sStandby;     // 
    
END                                  //

    IF(IODeviceInfo("mydev", 17) = sLocalServerName) THEN
        Message ( "Server Information" , "This is the active IO server" , 64 ) ; //Place your code here 
    
END
END

 

Keywords: