4 ms·
Instead of trying to directly integrate for example Prolog and Python I set up services in whatever language/hardware and communicate between then using JSON me
by sprior 5y ago
Instead of trying to directly integrate for example Prolog and Python I set up services in whatever language/hardware and communicate between then using JSON messages transported via MQTT. With this method I've got Docker containers running Java, Python, and Prolog code interoperating with ESP8266 and ESP32 devices I programmed in C++ and anyone can talk to anyone. I also wrote a Java server that interfaces with an Insteon gateway so my little MQTT cluster can respond to devices turning on/off or send a MQTT message to control a device. The pieces don't know or care what language the other pieces are written in.
On the Prolog side of things with not that much framework code here is a trivial example:
message(['Smarthome','Notify','brain','ping'],_):-
publish(['Smarthome', 'Notify', 'brain', 'ping_response']).
This code receives a MQTT message with a topic of Smarthome/Notify/brain/ping ignoring the message body and then publishes a return message on topic
Smarthome/Notify/brain/ping_response
I even have a container that runs nothing but cron with a mqtt client installed that sends mqtt messages at various times of the day and all Prolog has to do is subscribe to those topics and handle those messages.