Devices dont respond to messages from Magix
Closed this issue · 2 comments
kapot65 commented
Reproduce:
- start device manager with magix
- start logger
- run FetchDeviceDescription or GetCos
The description.get
message gets into the loop but nothing happens. Same with property.get
logger output:
MagixMessage(format=controls-kt, payload={"type":"lifecycle","state":"STARTING","sourceDevice":"demo","time":"2024-02-02T08:59:23.437222511Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[1616871475], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"lifecycle","state":"STARTED","sourceDevice":"demo","time":"2024-02-02T08:59:23.437223460Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[-402158563], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"property.changed","property":"sin","value":0.7099805604346726,"sourceDevice":"demo","time":"2024-02-02T08:59:23.437568595Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[1711725801], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"property.changed","property":"cos","value":0.7040792833095443,"sourceDevice":"demo","time":"2024-02-02T08:59:23.437645812Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[-1133644023], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"property.changed","property":"sin","value":0.7101213718895655,"sourceDevice":"demo","time":"2024-02-02T08:59:23.437779469Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[882923948], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"property.changed","property":"coordinates","value":{"time":1706864363437,"y":0.7040792833095443,"x":0.7101213718895655},"sourceDevice":"demo","time":"2024-02-02T08:59:23.437861991Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[-752872221], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"property.changed","property":"sinScaleState","value":1.0,"sourceDevice":"demo","time":"2024-02-02T08:59:23.438393251Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[-1899672120], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"property.changed","property":"timeScaleState","value":5000.0,"sourceDevice":"demo","time":"2024-02-02T08:59:23.438482071Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[2068055503], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"property.changed","property":"cosScaleState","value":1.0,"sourceDevice":"demo","time":"2024-02-02T08:59:23.438443834Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=df[-1851583922], parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"description.get","time":"2024-02-02T09:00:06.780147903Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=null, parentId=null, user=null)
MagixMessage(format=controls-kt, payload={"type":"property.get","property":"cos","targetDevice":"demo","time":"2024-02-02T09:02:48.285863504Z"}, sourceEndpoint=controls-kt, targetEndpoint=null, id=null, parentId=null, user=null)
SPC-code commented
It actually works fine. See this commit for demonstration: https://github.com/SciProgCentre/controls-kt.git. Here is the proper code for listener:
val listenerEndpoint = MagixEndpoint.rSocketWithWebSockets("localhost")
listenerEndpoint.subscribe(DeviceManager.magixFormat).onEach { (_, deviceMessage)->
// print all messages that are not property change message
if(deviceMessage !is PropertyChangedMessage){
println(">> ${Json.encodeToString(DeviceMessage.serializer(), deviceMessage)}")
}
}.launchIn(this)
listenerEndpoint.send(DeviceManager.magixFormat, GetDescriptionMessage(), "listener", "controls-kt")
The only problem is that you need to declare the target for the message. The default target for controls-kt endpoint "controls-kt". Currently the behavior of device endpoint is to only accept messages that are targeted at that endpoint. I wonder if we should allow broadcasts by default.
SPC-code commented
Closing it as "as designed". In the latest update controls endpoint also works with "broadcast" messages without target. So ti could be easier to access them.