esi-ipc-event

esi-ipc-event This class describes an event type which is meant to represent In Process Control data. the content of this object includes the following fields:

Field Description

timestamp

the timestamp when the samples where taken. This shall be within start and end of the batch

batchId

the batch id of the related batch

sampleId

the sample id of the IPC

materialType

the target material of the related batch

materialTypeCode

the target material of the related batch

erpOrder

the erporder of the related batch

mesOrderId

order id of the mes

mesId

id of the mes

source

optional source of the event ( e.g. Generic Item )

streamPath

optional path of the eventstream, which managed this event

meta

metadata of this IPC

sections

an array of IPCSection objects, which represent the sections of the IPC report

version

version of the object, including its representation and serialisation

The IPCSection object istelf is an table of IPCProperty objects.

Format of the created Event:

Field Description

Message

always: "IPC Event for Batch %s, SampleId %s"

@class

always: "inmation.Event"

@subclass

always: "esi-ipc-event"

@topic

the batchId

@batchid

the batch id

@sample

the sampleId

@erporder

the erporder

@mesorderid

the mes order Id

@mesid

the mes id

@materialtype

the materialtype

@materialtypecode

the materialtypecode

@mode

always: "Production"

@encoding

always: "text/json"

@payload

the json serialisation of the object

Dependencies

library version inmation core library

rapidjson

5.3.0

yes

esi-string

1.0.0

yes

esi-tool

1.0.0

yes

esi-class

2.0.0

yes

Available functions

All functions have to be called according to the ESI standard, using colons, e.g. lib:FUNCTIONNAME(params)

Documentation

ADD_VALUE(value)

Add a new value to an IPC Property

Parameters

value

this value must have the form: \{v=, q=, t=, u=, n=, l=, o=, m=}; defaults are: q=0, t=now(), unit=<meta.u> or "", note="", label=<meta.l> or ""

Returns

true on success, false+error text on failure.

ADD_PROPERTY(name,template)

Add a new property to a section

Parameters

tremplate

template data for the property object

Returns

true on success, false+error text on failure.

ADD_SECTION(name,template)

Add a new section to the IPC event

Parameters

tremplate

template data for the section object

Returns

true on success, false+error text on failure.

ADD_TO_META(name,value)

Add a new meta info to the IPC event

Parameters

value

value to add

Returns

true on success, false+error text on failure.

TO_JSON()

Generate JSON from an IPCEvent object

Returns

json representaion of the object

Usage

local json= (IPC({batchId= "Batch1", timestamp = syslib.now()})):TO_JSON()

FROM_JSON(json)

Generate IPCEvent object from json

Parameters

json

the JSON input to generate an event from

Returns

obj an Object of class IPCEvent

Usage

local ipc = IPC:FROM_JSON({"batchId":"Batch1", "timestamp": 1633904379737})

FROM_EVENT(event)

Createn an IPCEvent object from an event

Parameters

event

the event from which an IPC object shall be created.

Returns

obj an object of type IPCEvent

FROM_ISA88_EVENT(event)

Createn an IPCEvent object from an isa88 event

Parameters

event

the isa88 event from which an IPC object shall be created.

Returns

obj an object of type IPCEvent

QUERY_EVENTS(path,startTime,endTime,filter)

Query Events from the database

should be called on a the IPCEvent class, not on an object…​

Parameters

path

path of the eventstream object

startTime

start of the timerange of the query

endTime

end of the timerange of the query

filter

an additional filter filter shall be a lua table which can contain: \{batchId= , sampleId= , erpOrder= , materialType= } \{batchId= , sampleId= , erpOrder= , materialType= }

Usage

local ipc = IPC:QUERY_EVENTS("/System/Core/ScriptEvents", 1633904139000, 1633904379000, {batchId="Batch1"})

SEND()

Send an IPCEvent object as event

Returns

true

Usage

IPC({batchId= "Batch1", timestamp = syslib.now()}):SEND()