GPS Event [12] – Coral8

Let’s see what does it take to send a message to Coral8. The latest available version on the website is 5.5 and I have 5.1 installed, so it is time for an upgrade.

The upgrade (installation) went smooth. There is a good "getting started guide" available too.  Coral8 Server is the engine of the application and Coral8 Studio is a developer’s GUI. I have installed both on a Windows Server 2003 for Small Business — 2.53GHz, 2.5GB RAM — which also runs a developer version of MS SQL Server 2005. The average CPU usage seems to be below 5% when idle, not bad.

Coral8 has quite a few adapters included, but none of them seems to fit my GPS example; I will have to find another way. There is a SDK for several languages — including Python — so this seems a way to go. Now I can sketch a road map:

  1. Create a simple Coral8 project;
  2. Study the Python SDK and figure out how to send a message to Coral8;
  3. Test;
  4. If it works, continue with the GPS example.

Step 1 – a simple Coral8 project

Coral8 CCL (Continuous Computation Language) is SQL like, so I have created two streams (think one-row tables) with just two columns: Entity and Val. Imagine a measurement device (Entity) sending a number (Val) each measurement. Streams are connected by a query which copies data from the input to the output.

-- Input
CREATE INPUT STREAM StreamIn
SCHEMA (
    Entity STRING
    ,Val INTEGER
);
 
-- Output
CREATE OUTPUT STREAM StreamOut
SCHEMA (
    Entity STRING
    ,Val INTEGER
);
 
-- Pass Through
INSERT INTO StreamOut
SELECT * FROM StreamIn;

This is how it looks in the Coral8 Flow View.

If I manage to insert data into the input stream, the same data should show up in the output stream.

Step 2 – the Python SDK

The SDK has an example which sends and receives data, and also includes Python multitasking. After some tinkering I have decided to simplify it a bit:

"""
c8_test_1.py
Test sending data to Coral8
"""
import time
from coral8 import Coral8
 
uri = 'ccl://damir5:6789/Stream/Default/'
uri += 'TestPythonInAdapter/StreamIn'
 
col_names = ['Entity','Val']
 
def send_to_c8(j):
    pb = Coral8.Publisher(uri)
    tp = Coral8.Tuple(col_names)  
    tp.setvalue('Entity', 'DS_1')
    tp.setvalue('Val', j)
    pb.write_tuple(tp)
 
if __name__ == '__main__':
    for j in range(10):
        send_to_c8(j)
        time.sleep(0.2)

The program is supposed to send ten numbers (0-9) to Coral8 Server. Note the uri variable, I got that one by inspecting the StreamIn properties and substituting “localhost” with the server name (damir5).

Step 3 – Test

Guess what, it works; just like that. Here is a screen capture of both stream viewers.

Step 4 – Continue

Now I can add service and template modules for Coral8 to my GPS Event example. I still have to figure out what to do with events inside the server. Maybe I can use it to write events to a database and send notifications when the GPS starts loosing satellite signals — we’ll see.

To be continued.

Disclosure:

Everything I write about Coral8 is my own opinion and experience.
There is no contract nor any kind of active business relationship between Coral8 and me (Damir Systems Inc).