Home AMXForums Archive Threads AMX Applications and Solutions

Extron IPL T PCS4i

I am having trouble getting an Extron IPL T PCS4i to work with my code. This is the first time I have done any controls over IP and I am sure that is the main cause of my problems. Could someone look at the code below and tell me what I am doing wrong?
PROGRAM_NAME='Levels'

DEFINE_DEVICE

#IF_NOT_DEFINED dvPWR_Cntrl_Rack
dvPWR_Cntrl_Rack	=	0:2:0
#END_IF

#IF_NOT_DEFINED dvPWR_Cntrl_WS
dvPWR_Cntrl_WS		=	0:3:0
#END_IF

#IF_NOT_DEFINED dvPWR_Cntrl_Table
dvPWR_Cntrl_Table	=	0:4:0
#END_IF

DEFINE_CONSTANT
NON_VOLATILE INTEGER nIPPort = 23
DEFINE_VARIABLE

IP_ADDRESS_STRUCT ipPWR_CNTRL_Rack
IP_ADDRESS_STRUCT ipPWR_CNTRL_WS
IP_ADDRESS_STRUCT ipPWR_CNTRL_Table

NON_VOLATILE INTEGER nLVL_BTNS[] = 
{
    300,		//
    301,		//
    302,		//
    303,		//
    304,		//
    305,		//lvl 1
    306,		//lvl 2
    307			//lvl 3
}
DEFINE_START

ipPWR_CNTRL_Rack.IPADDRESS  = '192.168.1.122'
ipPWR_CNTRL_Rack.SUBNETMASK = '255.255.255.0'
ipPWR_CNTRL_Table.IPADDRESS = '192.168.1.123'
ipPWR_CNTRL_Table.SUBNETMASK= '255.255.255.0'
ipPWR_CNTRL_WS.IPADDRESS    = '192.168.1.124'
ipPWR_CNTRL_WS.SUBNETMASK   = '255.255.255.0'


IP_CLIENT_OPEN(dvPWR_Cntrl_Rack.Port,ipPWR_CNTRL_Rack.IPAddress,nIPPort,IP_TCP)
IP_CLIENT_OPEN(dvPWR_Cntrl_Table.Port,ipPWR_CNTRL_Table.IPAddress,nIPPort,IP_TCP)
IP_CLIENT_OPEN(dvPWR_Cntrl_WS.Port,ipPWR_CNTRL_WS.IPAddress,nIPPort,IP_TCP)

DEFINE_EVENT

BUTTON_EVENT [dvTP, nLVL_BTNS]
{
    PUSH:
    {
	  
	SWITCH(GET_LAST(nLVL_BTNS))
	{

	    }
	    CASE 6:	//Set level to 1
	    {
		seclevel = 1
		nChange_Flag = 1
	    }
	    CASE 7:	//Set level to 2
	    {
		seclevel = 2
		nChange_Flag = 1
	    }
	    CASE 8:	//Set level to 3
	    {
		level = 3
		nChange_Flag = 1
	    }
	    DEFAULT:	
	    {

		level = 0
	    }
	}
    }
}
DEFINE_PROGRAM


IF (nChange_Flag)
{
    SWITCH (level)
    {
	CASE 1:
	{

	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '2*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '4*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '2*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '4*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '2*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '4*0PC', $0D"
	}
	CASE 2: 
	{

	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '2*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '4*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '2*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '4*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '2*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '4*0PC', $0D"
	}
	CASE 3: 
	{
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '2*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '3*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '4*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '2*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '3*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '4*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '1*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '2*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '3*1PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '4*0PC', $0D"
	}
	DEFAULT: 
	{

	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '1*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '2*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Rack, "$1B, '4*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '1*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '2*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_WS, "$1B, '4*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '1*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '2*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '3*0PC', $0D"
	    SEND_STRING dvPWR_Cntrl_Table, "$1B, '4*0PC', $0D"
	}
    }
    nChange_Flag = 0
}

Comments

  • JonathondwJonathondw Junior Member Posts: 23
    Dwatson8791,

    I can tell you that all of the extron equpiment will close the telnet port after 20seconds of no activaity.

    also you should have a DATA_EVENT for each device so you can monitor each device for when it should fall offline then you can reconnect it.

    DEFINE_CONSTANT

    CONNECTED = 11

    DEFINE_VARIABLE

    integer nTry2Connect


    DEFINE_FUNCTION CloseConnection()
    {
    IP_CLIENT_CLOSE(devDevice.PORT);
    }

    DEFINE_START

    IP_CLIENT_OPEN(devDevice.PORT,192.168.0.0,23,tcp);


    DATA_EVENT[devDevice]
    {
    ONLINE:
    {
    ON[devDevice,CONNECTED]
    CANCEL_WAIT 'make connection'
    }
    OFFLINE:
    {
    OFF[devDevice,CONNECTED]

    WAIT 20 'make connection'
    IF(![devDevice,CONNECTED])
    {
    IP_CLIENT_OPEN(devDevice.PORT,192.168.0.0,23,tcp);
    }
    }
    ONERROR:
    {
    nCONNECTION_ERROR = Data.Number


    IF(nCONNECTION_ERROR = 0)
    {

    }
    ELSE
    {
    IF([devDevice,CONNECTED])
    CloseConnection()
    OFF[devDevice,CONNECTED]
    WAIT 30 'make connection'
    EstablishConnection()
    }
    (*
    IF(nCONNECTION_ERROR <> 0 && nCONNECTION_ERROR <> 9)
    {
    OFF[devDevice,CONNECTED]

    }
    *)
    }
    }
Sign In or Register to comment.