SOCKET COMMANDS

HASE SOCKET SUPPORT

The Home Automation Scripting Engine supports two verbs for use over a standard socket connection. The default port is 12112, and can be changed via a command line argument. HASE CONFIGURATION

Verb Description Example
WS_SS_CMD Sends commands to a specific socket server 101 WS_SS_CMD slinkx sendex cdj:echo[hi!]
WS_HASE_CMD Puts commands on the HASE event stream - useful for triggering a script event - in the example to the right, the mydev_testsub subroutine would be executed if found in the script file. 102 WS_HASE_CMD mydev:testsub

This is an example script used while testing the HASE socket support:

101 ws_ss_cmd slinkx sendex cdj:echo[1,2,three]
102 slinkx numdevices
103 ws_ss_cmd slinkx Adddevice my_amp_send,\\syrinx\slinke\device files\sony\ampsls.cde, 0, 0, 2
104 ws_ss_cmd slinkx numdevices
105 WS_ss_cmd SLINKX GetDeviceName 4
106 ws_ss_cmd slinkx GetNumCodes my_amp_send
107 ws_ss_cmd slinkx getcodename my_amp_send,1
108 ws_ss_cmd text2speech speak hello, this is a test

 

SLINKE SOCKET SERVER

The Slinke Socket Server (SSS) acts as a gateway between slinkeserv and socket-based applications. The protocol is VERY simple and the commands map directly to the slinkx properties and methods, plus there are some additional functions that slinkx does not provide.

SLINKX COMMANDS

Verb Description
ADDDEVICE See the Nirvis Slinkx documentation for these calls - http://www.nirvis.com/help/help.htm
ADDDEVICETEXT  
CONNECT  
DELETEDEVICE  
DISCONNECT  
GETCODENAME  
GETDEVICENAME  
GETNUMCODES  
LASTERROR  
NUMCM11AS  
NUMDEVICES  
NUMDXSS  
NUMSLINKES  
REPORTNOMATCH  
SEND  
SENDEX  

CDJ Persisted Inforormation

Verb Description Example
PLAYING_ARTIST    
PLAYING_ALBUM    
PLAYING_TRACK    
PLAYING_TOTALTIME    
PLAYING_COVERFILENAME    
PLAYING_CDJID    
PLAYING_LOCATION    
PLAYING_CURRENTTIME    
PLAYING_TRACKNUM    
PLAYING_REFRESH    
     
CDJ_STATE    
CDJ_INFO_REFRESH    
     
PLAYLIST_FILENAME    
PLAYLIST_POINTER    
PLAYLIST_SIZE    
PLAYLIST_STATE    
PLAYLIST_REFRESH    

Socket Server Statistics

STAT_CALLS Returns the number of calls (winsock commands) since SSS was started  
STAT_CLIENTS Returns the IP addresses of the current clients  
STAT_CONNECTIONS Returns the current number of socket connections  
STAT_EVENTS Returns the number of events since SSS was started  

Database Commands

DB_NUMTRACKS WhereClause Returns the number of tracks returned by the WhereClause
DB_NUMALBUMS WhereClause Returns the number of albums  returned by the WhereClause
DB_GETTRACK Tracks.ID Returns the track info in a comma delimited string WITH fieldnames
DB_GETTRACKS WhereClause, FieldList Returns comma delimited fields indicated in FieldList with CR+LF line termination between each record
DB_GETTRACK_BY_CDJ_ID Tracks.CDJID, Tracks.Track Returns the track info in a comma delimited string WITH fieldnames
DB_GETALBUM Albums.ID Returns the album info in a comma delimited string WITH fieldnames
DB_GETALBUMS WhereClause, FieldList Returns comma delimited fields indicated in FieldList with CR+LF line termination between each record
DB_GETALBUM_BY_CDJID Albums.CDJID Returns the album info in a comma delimited string WITH fieldnames
DB_XML_GETTRACKS WhereClause Returns the info from all tracks returned by the WhereClause. Information is returned in the ADO XML persisted recordset format.
DB_XML_GETALBUMS WhereClause Returns the info from all albums returned by the WhereClause. Information is returned in the ADO XML persisted recordset format.
DB_XML_GETALBUMS_FULL WhereClause Returns the info from all albums returned by the WhereClause, and includes the related track info for each album. Information is returned in the ADO XML persisted recordset format.
DB_XML_SQLSTATEMENT SQLStatement Returns the info from executing the SQL statement  against the CDJ database. Information is returned in the ADO XML persisted recordset format.
DB_RPL_SQLSTATEMENT SQLStatement Returns the info from executing the SQL statement  against the CDJ database. 

Output is comma delimited fields indicated with CR+LF line termination between each record - fields include fieldname.

  

ADDITIONAL COMMANDS

Verb Description Example
DELETEALLDEVICES Deletes all devices  
NUMPLAYLISTS Returns number of playlists in the directory specified in the command-line options or detected from the CDJ registry  
GETPLAYLISTS Returns all playlists in the directory specified in the command-line options or detected from the CDJ registry (Does not have path information)  
LOADPLAYLIST Loads a playlist from the directory specified in the command-line options or detected from the CDJ registry (Does not require path information)  
SERIALNUMBER Returns the serial number of the slink-e  
SLINKE_VERSION Returns the version number of the slink-e  

 

This is an example script that was used while testing the SSS.

100 Connect
101 Adddevicetext x10,type=cm11a,1,1,0
102 adddevicetext cdjr, type = devrx,1,1,0
103 adddevicetext cdj,type=devtx, 1,1,0
104 send cdj, notify_playing_item[off]
105 sendex cdj:notify_playing_timecode[off]
106 numdevices
107 numcm11as
108 numslinkes
109 numdxss
110 reportnomatch
111 reportnomatch 1
112 reportnomatch
113 reportnomatch 0
114 reportnomatch
115 numdevices
116 Adddevice my_amp_send,\\syrinx\slinke\device files\sony\ampsls.cde, 0, 0, 2
117 numdevices
118 GetDeviceName 4
119 GetNumCodes my_amp_send
120 getcodename my_amp_send,1
121 Disconnect
122 lasterror
123 Numdevices
124 LastError
125 Connect
126 LastError
127 NumDevice

The first part of each line is a "command identifier". This can be any combination of letters or numbers. The response from this command will carry this same id. In a socket environment, the responses may come out of order due to multi-threaded processing. By sending unique identifiers, you can't confuse responses.

The second part of each line is the slinkx command separated from the command identifier by a single space.

All parameters follow the slinkx command and are separated by a comma. The parameters are separated from the slinkx command by a single space. Please note that text is NOT in quotes and all parameters are required.

The following table shows the responses for the above commands:

COMMAND RESPONSE
101 Adddevicetext x10,type=cm11a,1,1,0 RESP 101 ADDDEVICETEXT 0
102 adddevicetext cdjr, type = devrx,1,1,0 RESP 102 ADDDEVICETEXT 0
103 adddevicetext cdj,type=devtx, 1,1,0 RESP 103 ADDDEVICETEXT 0
104 send cdj, notify_playing_item[off] RESP 104 SEND 0
105 sendex cdj:notify_playing_timecode[off] RESP 105 SENDEX 0
106 numdevices RESP 106 NUMDEVICES 3
107 numcm11as RESP 107 NUMCM11AS 1
108 numslinkes RESP 108 NUMSLINKES 1
109 numdxss RESP 109 NUMDXSS 0
110 reportnomatch RESP 110 REPORTNOMATCH FALSE
111 reportnomatch 1 RESP 111 REPORTNOMATCH TRUE
112 reportnomatch RESP 112 REPORTNOMATCH TRUE
113 reportnomatch 0 RESP 113 REPORTNOMATCH FALSE
114 reportnomatch RESP 114 REPORTNOMATCH FALSE
115 numdevices RESP 115 NUMDEVICES 3
116 Adddevice my_amp_send,\\syrinx\slinke\device files\sony\ampsls.cde, 0, 0, 2 RESP 116 ADDDEVICE 0
117 numdevices RESP 117 NUMDEVICES 4
118 GetDeviceName 4 RESP 118 GETDEVICENAME my_amp_send
119 GetNumCodes my_amp_send RESP 119 GETNUMCODES 13
120 getcodename my_amp_send,1 RESP 120 GETCODENAME test
121 Disconnect RESP 121 DISCONNECT 0
122 lasterror RESP 122 LASTERROR Error: Control is not connected to a server.
123 Numdevices RESP 123 NUMDEVICES 7777
124 LastError RESP 124 LASTERROR Error: Control is not connected to a server.
125 Connect RESP 125 CONNECT 0
126 LastError RESP 126 LASTERROR Error: Control is not connected to a server.
127 NumDevice RESP 127 NUMDEVICES 0

 If you are writing an application, but don't want to handle the socket connection, the HASEx activex control duplicates the slinkx functionality, but sends the commands via the Slinke Socket Server, eliminating the need to use DCOM.