Tag Only for the Citect Server and its Local Client

Hi,

Can we in Citect (ver 2018 R2->) create an tag that is "1" only on the server and for the local server client? Meaning any Remote Clients running outside the actual server hardware will read this tag as "0". 

Indicates if the server the application is running on is the server or a client. 

This can be used to start/stop/control local 3'rd party programs running on the server hardware and can only be operated/used directly on this hardware. 

Thanks,

Rune

  • You could create a local variable that you set/reset on startup using a cicode startup function.

    In that startup function you can figure out if the machine is the server by calling GetEnv("COMPUTERNAME") and comparing it to the known PC name. You could also set the [LAN]Node parameter to a meaningful value in the Citect.ini of the server and use ParameterGet("LAN", "Node", "") to check for that name.

    This startup function should be configured in the Computer Setup wizard for all Citect processes on all machines.
  • Hi Patrick,
    Thats great!
    Thanks a lot, I'll work on that and test it.

    Enjoy your weekend!

    Rune
  • Not sure if you still need this, but here's a Cicode function that returns 1 if called from any process on a server computer, and returns 0 on a client. I had used it to look up the network address name of the local server, so it was just a minor change to just return true/false. 

    INT mbComputerIsServer = -1;
    
    //Returns TRUE if this computer runs any server processes, otherwise FALSE
    //The calling process does not have to be a server process
    STRING FUNCTION ComputerIsServer()
    	INT		cRpcBlocking = 0;
    	INT		hServers;
    	STRING	sLocalComputer;
    	STRING	sServerComputer;
    	STRING	sServer;
    	STRING	sType;
    	STRING	sCluster;
    
    	ErrSet(1);
    	
    	IF mbComputerIsServer = -1 THEN
    		mbComputerIsServer = FALSE;
    		sLocalComputer = GetEnv("ComputerName");
    	
    		hServers = ServerBrowseOpen("", "NAME,TYPE,NETADDR,CLUSTER");
    		ServerBrowseFirst(hServers);
    		sServer = ServerBrowseGetField(hServers, "NAME");
    		
    		WHILE (sServer <> "") AND (mbComputerIsServer = FALSE) DO
    			sType = ServerBrowseGetField(hServers, "TYPE");
    			IF sType = "I/O" THEN
    				sType = "IOServer";	//Different abbreviation used for ProcessIsServer()
    			END
    			
    			sCluster = ServerBrowseGetField(hServers, "CLUSTER");
    			
    			sServerComputer = ServerRPC(sServer, "GetEnv", "^"ComputerName^"", cRpcBlocking, sCluster);
    			
    			IF sLocalComputer = sServerComputer THEN
    				mbComputerIsServer = TRUE;
    			END
    	
    			ServerBrowseNext(hServers);
    			sServer = ServerBrowseGetField(hServers, "NAME");
    		END
    		
    		ServerBrowseClose(hServers);
    	END
    	
    	RETURN mbComputerIsServer;
    END	
    
  • Thanks a lot Eric,
    I'll look into it.

    Regards,
    Rune