Datapath FX4 and WD

Christie Widget Designer Version 6 - Q&A

Moderator: Moderator Group

Forum rules
When asking make sure to include the operating system and the revision of Widget Designer you are using.

Datapath FX4 and WD

Postby Daniel Kaminski » Sat Nov 03, 2018 3:13 pm

Hi everybody,
just in case you wondered how to control the more and more popular Datapath FX4 with WD.
Datapath has released a REST API which is pretty straight forward and easy to read.
https://www.datapath.co.uk/supportdownl ... r-rest-api

To be able to send Data from WD to FX4 you need to send HTTP POST Messages.
Those are not naively implemented in WD, but can easily be generated.

Here is an example on how to turn on / off an Output

Create a TCP Connection with the ID 1 and Port 80

Code: Select all
var L_ConnectionID = 1
// Length of the Strings in Byte, in this case 26 for true = ON or 27 for false = OFF
var L_C_length = 26
var L_Path = "/OutputEnable.cgx"
// Datapath counts the outputs from 0 to 3
var L_FX4Out = 0
var L_FX_State = "true"
var L_Command = '{"Output":' +L_FX4Out+ ',"Enable":'+L_FX_State+'}'

//TCP Packet that needs to be send.
var L_FX4_String = ""
L_FX4_String = "POST "+ L_Path + "HTTP/1.1[CR][LF]Connection: keep-alive[CR][LF]"
L_FX4_String += "Content-Length: " + L_C_length + "[CR][LF]User-Agent: Christie Widget Designer[CR][LF]"
L_FX4_String += "Content-Type: application/json[CR][LF][CR][LF]"
L_FX4_String += L_Command

TCPStart(L_ConnectionID)
WDWait(0.2)
TCPSend(L_ConnectionID,L_FX4_String)
WDWait(0.3)
TcpStop(L_ConnectionID)


Best way is to put the code into a function.
Other command work similar. Just adjust the Path, the length and the parameters.

You can also read out the responds in order to know if it worked.

Enjoy
Daniel
--
Daniel Kaminski
Pandras Box Expert
User avatar
Daniel Kaminski
 
Posts: 908
Joined: Tue Jul 22, 2008 10:55 am
Location: Herten, Germany

Return to Widget Designer V6

Who is online

Users browsing this forum: No registered users and 2 guests