Learning DeadCL DeadCL Tutorials DeadCL Syntax DeadCL MBS

Walk throughs

Author Keys Conversations Libraries Arrays

  Network Status Community Hub Contact Us



Databases

DeadLetter Data Arrays

View tutorials overview

Introduction

Databases or more correctly DeadLetter Data Arrays are used to hold object information for Conversations.

Conversations can also be linked to conventional databases using API's or conversion toolsets.

The Library & Conversation used are linked below, for both comparison and ease of execution.


Everything shown in blue must be substituted with your own values.

This tutorial will not deal with the initial establishment of DeadLetter or your web server/web presence.

What you'll learn

- How to configure a basic Array
- How to automatically insert objects into an Array
- How to setup CHAD parameters for an Array

What you'll need

- A Github: in this example we're using Github (as host) but you could substitute any service or your own VPS
- html POST endpoint you'll somewhere to receive output from the 'database'
- Author Key: it goes without saying you'll need an Author Key - ideally setup with a Parcel endpoint

Step One - initial configuration

Before we go any further we need to setup an Array to familiarise yourself with Arrays read the walk through.

The Array Brokering Library shown below is what we'll be using to manage our database, in this example we're counting cars entering and leaving a parking facility (or more accurately colour/shape identifier).


_NAME [ //CALL CAR-PARK-MANAGEMENT -- BND /RW CLASS #0.00 ]
_USER [ ^FUSE ?DLD.KEYSET_ ]
_AUTHORITY [ //SET OB.D5 -- 00.000 //SET OB.D5_1 -- 00.500 //SET WING_STATE OB.D5_* -- 00.500 ] [ //SET OB.D6 -- 00.500 //SET WING_STATE OB.D6_* -- 00.500 ] [ //SET OB.D7 -- 00.500 //SET WING_STATE OB.D7_* -- 00.500 ] [ //SET OB.D8 -- 00.500 //SET WING_STATE OB.D7_* -- 00.500 ]
_REQUEST [ //CALL A: *$ ]
_POST [ //POST DLD.KEYSET-DO-ID: ]

Array Brokering - Name

The first step in brokering is setting your name Schemer, as one of the five fixed Array attributes - in this case _NAME

Here we're setting the Array name to CAR-PARK-MANAGEMENT & binding it's value to the Naming Class (in this case OB.D0 as set in the Object Management Library.

_NAME [ //CALL CAR-PARK-MANAGEMENT -- BND /RW CLASS #0.00 ]

Array Brokering - User

Next we need to set the Authors able to update/manage the Array, as one of the five fixed Array attributes - in this case _USER

Here we're locking the Array users to DLD.KEYSET or in other words the Author of the Brokering Library and in-turn the Array. This information is stored in OB.D1 as set in the Object Management Library.

_USER [ ^FUSE ?DLD.KEYSET_ ]

Array Brokering - Authority

Before we go any further we need to set our Authorities, as we're managing cars (Objects) entering and exiting a parking structure (base-frame) we'll need the following;

OB.D5 used this for 'new' objects
OB.D6 used this for 'moving' objects
OB.D7 used for 'removed' objects

As one of the five fixed Array attributes - in this case _AUTHORITY

Here we're informing deadCL which OB (Object Classes) we'll be using. We're using the default values 00.000 for the master class & 00.500 for each sub-class. This information is stored in OB.D2 as set in the Object Management Library.

_AUTHORITY [ //SET OB.D5 -- 00.000 //SET OB.D5_1 -- 00.500 //SET WING_STATE OB.D5_* -- 00.500 ] [ //SET OB.D6 -- 00.500 //SET WING_STATE OB.D6_* -- 00.500 ] [ //SET OB.D7 -- 00.500 //SET WING_STATE OB.D7_* -- 00.500 ]

Array Brokering - Request

in-order to make requests your Array requires instructions on how to treat requests. As one of the five fixed Array attributes - in this case _REQUEST

To maintain our requests within the Array, we can inform deadCL with *$ This information is stored in OB.D3 as set in the Object Management Library.

_REQUEST [ //CALL A: *$ ]

Array Brokering - Post

The last step for Brokering your new Array in setting the POST parameters. As one of the five fixed Array attributes - in this case _REQUEST

Your Broker should set the POST parameter (as your Author key) [ //POST DLD.KEYSET-DO-ID: ] This step is crucial to interact with your Array.

This information is stored in OB.D4 as set in the Object Management Library.

_POST [ //POST DLD.KEYSET-DO-ID: ]

Step Two - Defining our state changes

Okay, now it's time to build the Library. For the purposes of this example we're using a series of (very) basic rules.

Here our library is simply organising inbound Objects.

            

STATE; RECORD -- OB.D5 { STORE -- BASE = OB.D5_1 } { STORE -- STATE = OB.D5_* -N VAL_00-T.M-T.H-T.D } MOVED; RECORED -- OB.D6 { STORE -- MOVE = OB.D6_* -N VAL_00-T.M-T.H-T.D } REMOVED; RECORED -- OB.D7 { STORE -- REMOVE = OB.D7_* -N VAL_00-T.M-T.H-T.D }

Initial State

Our first KC handles both the base state (the state without changeable object variables) & the state when variable objects are present.

We're usingOB.D5_1 to record the base state. & OB.D5_* to record the variable objects, as in this instance we don't care which class they're recorded into - provided it's not OB.D5_1.

            

STATE; RECORD -- OB.D5 { STORE -- BASE = OB.D5_1 } { STORE -- STATE = OB.D5_* -N VAL_00-T.M-T.H-T.D }

Movement Record

The next stage within our Library records movement, in the context of this example we'll be using it for recall purpose (if & when required).

            

MOVED; RECORED -- OB.D6 { STORE -- MOVE = OB.D6_* -N VAL_00-T.M-T.H-T.D }

Remove Record

In the context of this database example we use REMOVED to indicate when an object as left the parking structure.

            

REMOVED; RECORED -- OB.D7 { STORE -- REMOVE = OB.D7_* -N VAL_00-T.M-T.H-T.D }

Step Three - Setting up

Next we need to setup supporting information in-order for the Conversation to run correctly.

            

OBSERVE; {watch (someone or something) carefully and attentively} CHANGE; {change in state, becomes different} {a change of place, position, or state} *INPUT; PARCEL - C {58EsDe} = CAMERA-000 PARCEL - C {57a2BH} = CAMERA-001 PARCEL - C {57a2BH} = MANAGE-000 CAMERAS; {CAMERA-000, CAMERA-001} PARAMETERS; 'BASE' = OB.D5_1 'STATE' = OB.D5_* 'MOVE' = OB.D6_* 'REMOVE' = OB.D7_* QUERIES{COLOUR, TIME} POST; PARCEL- C PARAMETERS -- API.DOMAIN.COM

Definitions

By default deadCL pulls all definitions from the Oxford English Dictionary however here we've defined a strict meaning for each key-word used within the Conversation.

In this case we're only concerned with;

Observe this allows us to reliably use MBS to watch the input(s)
Change this enables us to use MBS to interpret the presence of movement easily

            

OBSERVE; {watch (someone or something) carefully and attentively} CHANGE; {change in state, becomes different} {a change of place, position, or state}

Inputs

Next we need to setup the visual inputs, here we're setting up two camera inputs & one management input (we're use this one to make requests to the Array).

Our camera inputs will need to be configured within your AK with the appropriate values58EsDe & 57a2BH.

While our management input should be set to 0xr2BH

Finally we'll use a single KC (CAMERAS) to combined all our camera inputs, we'll need this later on within the Conversation.
            

*INPUT; PARCEL - C {58EsDe} = CAMERA-000 PARCEL - C {57a2BH} = CAMERA-001 PARCEL - C {0xr2BH} = MANAGE-000 CAMERAS; {CAMERA-000, CAMERA-001}

API configuration

To interact with the Array, you'll need to configure how deadCL handles request (inbound and outbound)

The Parameters we're defining are;
- BASE
- STATE
- BASE
- MOVE
- REMOVE


Theses, are used to define which Array Class you're trying to query, Coupled with a fixed query (in this example colour & time)

            

PARAMETERS; 'BASE' = OB.D5_1 'STATE' = OB.D5_* 'MOVE' = OB.D6_* 'REMOVE' = OB.D7_* QUERIES {COLOUR, TIME}

Set POST endpoint

Here we'll set the POST endpoint,

Theses, are used to define which Array Class you're trying to query, coupled with a fixed query (in this example colour, time as both have corresponding Libraries within DeadLetter's repository).

            

POST; PARCEL- C PARAMETERS -- API.DOMAIN.COM

Step Four - The Conversation

Unlike most Conversations we're only handling the organisation of objects observed over the input and their insertion into the Array.

            

dld.keyset('NAME_YOURNAME') *Catch-all - libs *input; [CAMERAS] DETECT; {observe = CHANGE IN, BASE} NO-DETECT; {observe = NO CHANGE, BASE} BASE; INPUT, NO-DETECT 'STORE' STATE; INPUT, DETECT 'STORE' MOVED; STATE, DETECT CHANGE 'STORE' REMOVED; MOVED, DETECT 'STORE' *END*

Setting your input

It goes without saying but you'll need to set an input address; remember in this example we're using a Key Command as our input in-order to combine multiple inputs.

  
 

 *input;
	[CAMERAS]



Detection

This tutorial makes use of two different detection states, based upon a principal of observe on the input against the 'base' (input without any variable objects).

      
 

 DETECT;
	{observe = CHANGE IN, BASE}

 NO-DETECT;
	{observe = NO CHANGE, BASE}	
	


Handling 'States'

In order to 'set' the BASE we use the input with the removal of any variable objects.

In order to 'set' the STATE we use the input when ever a variable objects is observed.

In order to 'set' the MOVED we use changes in the STATE value

In order to 'set' the REMOVED we use the MOVED value

As this library is designed to record when a 'object' changes we must handle each proposed state regardless of any overlap.

 

BASE; INPUT, NO-DETECT 'STORE' STATE; INPUT, DETECT 'STORE' MOVED; STATE, DETECT CHANGE 'STORE' REMOVED; MOVED, DETECT 'STORE'


You're Done!

By now you should have a (very) basic understanding of Arrays within DeadLetter (deadCL)


NOTE: This is not intended as a production ready Conversation, simply an example of deadCL.

This example requires your 'camera' feed(s) only submit information in a PARCEL compatible format - to insert a 'naked' visual stream you'll need to change the inputs to DRM.

As this code simply detects the colour and time the base changes to the 'base'.