Files
2025-12-11 16:19:19 +01:00

193 lines
5.8 KiB
Plaintext

#
# Commands to communicate with TOPAS API
# Tested with WinTOPAS 4 1.153.2.0
#PollPeriod = 4000; #readall on 5 second scan
ReplyTimeout = 500;
ReadTimeout = 500;
WriteTimeout = 500;
LockTimeout = 500;
OutTerminator= "";
InTerminator = "";
#InTerminator = LF;
ExtraInput = Ignore;
TestComms {
out "GET / HTTP/1.1\r\n\r\n"; #test read - should reply with 'Remote control REST app (Jun 3 2019).'
in "%#s";
}
#[saresb-cons-01 ~]$ curl -X PUT http://129.129.243.70:8004/16448/v0/PublicAPI/ShutterInterlock/OpenShutter --data ''
#[saresb-cons-01 ~]$ curl -X PUT http://129.129.243.70:8004/16448/v0/PublicAPI/ShutterInterlock/^Cutter --data ''
#[saresb-cons-01 ~]$ curl -X PUT http://129.129.243.70:8004/16448/v0/PublicAPI/ShutterInterlock/CloseShutter --data ''
#curl http://129.129.243.70:8000/18729/v0/PublicAPI/ShutterInterlock/IsInterlockOpen 5<0d><0a>false<00>
#paramerters passed from record $(SYSTEM),$(HOST),$(TOP_DEV),$(MOT)
#Shutter Control
GetShutterState { out "GET /\$3/v0/PublicAPI/ShutterInterlock/IsShutterOpen\r\n\r\n"; #Shutter state
InTerminator = "\r\n";
in "%*s";in "%{false|true}";
}
OpenShutter { OutTerminator = CR LF;
out "PUT /\$3/v0/PublicAPI/ShutterInterlock/OpenShutter HTTP/1.1";
out "Host: \$2";
# out "Accept: */*";
# out "Content-Type: application/x-www-form-urlencoded";
out "Content-Length: 4";
out "";
out "{''}\r\n";
wait 100;
}
CloseShutter { OutTerminator = CR LF;
out "PUT /\$3/v0/PublicAPI/ShutterInterlock/CloseShutter HTTP/1.1";
out "Host: \$2";
out "Content-Length: 4";
out "";
out "{''}\r\n";
wait 100;
}
#Wavelength control - curl http://129.129.243.70:8000/18729/v0/PublicAPI/Optical/WavelengthControl/Output/Wavelength
GetWavelength { out "GET /\$3/v0/PublicAPI/Optical/WavelengthControl/Output/Wavelength\r\n\r\n"; #Wavelength
InTerminator = "\r\n";
in "%*s";in "%f";
}
SetWavelength { OutTerminator = CR LF;
out "PUT /\$3/v0/PublicAPI/Optical/WavelengthControl/SetWavelength HTTP/1.1";
out "Host: \$2";
out "Content-Type: application/json";
out "Content-Length: 240";#233
out "";
out '{ "DontTouchShutterOnInteractionChange": false,"IgnoreSeparation": false, "SetForBackground": false, "Wavelength": %f,"Interaction": "*","Priorities":[{"Priority": 30,"Type": "art"},{"Priority": 63, "Type": "dreamcatcher" } ] } \r\n';
# 12345678901234567890123456789012345678901234567 501234567890123456789012345678901234567890123456 10012345678901234567890123456789012345678901234567 5012345678901234567890123456789012345678901234567 5012345678901234567890123456789012345
wait 100;
}
Interaction { out "GET /\$3/v0/PublicAPI/Optical/WavelengthControl/Output\r\n\r\n"; #Title
InTerminator = "\r\n";
in "%*s";
in "%*/" 0x22 "ActualInteraction" 0x22 ":" 0x22 "/%[^" 0x22 "]"; #Read chars while not an " for title
}
#Motors
MotorTitle { out "GET /\$3/v0/PublicAPI/Motors/?id=\$4\r\n\r\n"; #Title
InTerminator = "\r\n";
in "%*s";
in "%*/" 0x22 "Title" 0x22 ":" 0x22 "/%[^" 0x22 "]"; #Read chars while not an " for title
}
MotorTitleUnit { out "GET /\$3/v0/PublicAPI/Motors/?id=\$4\r\n\r\n"; #read both Title and unit
InTerminator = "\r\n";
in "%*s";
in "%*/" 0x22 "Title" 0x22 ":" 0x22 "/%[^" 0x22 "]" 0x22 "," 0x22 "UnitName" 0x22 ":" 0x22 "%(\$1:MOT\$4_UNIT)[^" 0x22 "]" ; #Read chars while not an " for title
}
#MotorUnit { out "GET /\$3/v0/PublicAPI/Motors/?id=\$4\r\n\r\n"; #UnitName
# InTerminator = "\r\n";
# in "%*s";
# in "%*/" 0x22 "Title" 0x22 ":" 0x22 "/%[^" 0x22 "]," 0x22 "UnitName" 0x22 ":" 0x22 "/%[^" 0x22 "]" ;
# #in "%*/" 0x22 "UnitName" 0x22 ":" 0x22 "/%[^" 0x22 "]"; #there are 2 "UnitNames" - problem is finding he second one...
# }
ActualPos { out "GET /\$3/v0/PublicAPI/Motors/?id=\$4\r\n\r\n"; #position in steps
InTerminator = "\r\n";
in "%*s";
in "%*/ActualPosition" 0x22 ":/%f"; #floating pt
}
ActualPosUnits { out "GET /\$3/v0/PublicAPI/Motors/?id=\$4\r\n\r\n"; #position in egu
InTerminator = "\r\n";
in "%*s";
in "%*/ActualPositionInUnits" 0x22 ":/%f"; #floating pt
}
# curl -X PUT http://129.129.243.70:8004/16448/v0/PublicAPI/Motors/TargetPosition?id=1 -H "Content-Type: application/json" -d "9796"
SetAbsSteps { OutTerminator = CR LF;
out "PUT /\$3/v0/PublicAPI/Motors/TargetPosition?id=\$4 HTTP/1.1";
out "Host: \$2";
out "Content-Type: application/json";
out "Content-Length: 8";
out "";
out "%d \r\n";
wait 100;
}
SetRelSteps { OutTerminator = CR LF;
out "PUT /\$3/v0/PublicAPI/Motors/TargetPositionRelative?id=\$4 HTTP/1.1";
out "Host: \$2";
out "Content-Type: application/json";
out "Content-Length: 6";
out "";
out "%d \r\n";
wait 100;
}
#Uri: http://129.129.243.70:8016/N05034/v0/PublicAPI/Motors/StopAll
#Home a motor
#Uri: http://129.129.243.70:8016/N05034/v0/PublicAPI/Motors/Home?id={motorIndex}
HomeMotor { OutTerminator = CR LF;
out "POST /\$3/v0/PublicAPI/Motors/Home?id=\$4 HTTP/1.1";
out "Host: \$2";
#out "Content-Type: application/json";
out "Content-Length: 4";
out "";
out "{''}\r\n";
wait 100;
}
StopAll { OutTerminator = CR LF;
out "POST /\$3/v0/PublicAPI/Motors/StopAll HTTP/1.1";
out "Host: \$2";
# out "Accept: */*";
# out "Content-Type: application/x-www-form-urlencoded";
out "Content-Length: 4";
out "";
out "{''}\r\n";
wait 100;
}