esi-batch-data

Batch data document

Dependencies

library version inmation core library

dkjson

5.3.0

yes

esi-string

1.0.0

yes

esi-tool

1.0.0

yes

esi-subtype

1.0.0

yes

debug

5.3.0

yes

Available functions

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

NEW

Documentation

INIT()

INIT initialize this library

Returns

nil

IS_BATCH_ACTIVE()

Check if batch is active

Returns

true if batch is active

SET_BATCH_ACTIVE(active,reason)

SET_BATCH_ACTIVE set the active state of a batch

modifies self.batch

Parameters

active

Decides whether to set the batch active (true) or inactive (false)

reason

Allows to declare a reason which will be stored in the batch record

Returns

  1. true, if successful (2) optional error

Usage

local ret = SET_BATCH_ACTIVE(true, "batch active")

SET_BATCH_EQUIPMENT_STATE(state,time)

SET_BATCH_ACTIVE set the active state of a batch

modifies self.batch modifies self.batch.equipment.state, extends self.batch.equipment.state.transitions

Parameters

active

Decides whether to set the batch active (true) or inactive (false)

reason

Allows to declare a reason which will be stored in the batch record

state

state to set

time

timestamp of state change

Returns

    1. true, if successful (2) optional error

  • true, if successfull

Usage

local ret = SET_BATCH_ACTIVE(true, "batch active")

GET_BATCH_EQUIPMENT_STATE()

GET_BATCH_EQUIPMENT_STATE returns the current batch equipment state

Returns

state, time: returns equipment state (1-17 or 0/-1 in case the state does not adhere to S88) and timestamp

IS_BATCH_RECORD_OPEN()

IS_BATCH_RECORD_OPEN return the record open state ( if available )

Returns

true if the batch record is open (state from batch.system)

IS_BATCH_RECORD_CLOSED()

IS_BATCH_RECORD_CLOSED return the record closed state ( if available )

Returns

true if the batch record is closed (state from batch.system), nil and error otherwise

GET_BATCH_ID()

GET_BATCH_ID return the batch ID if availbale

Returns

  1. Batch ID as a string (2) optional error

GET_BATCH_DURATION()

GET_BATCH_DURATION retrieves the duration of the batch (if known)

Returns

  1. duration as a numeric ms value (2) nil

SEND_BATCH()

SEND_BATCH send the batch event to be stored in the database

Returns

  • true or false

  • true on success, false on error.

ADD_EVENTS(trackingScope,eventConfigs)

ADD_EVENTS adds an event to an events-section

Parameters

trackingScope

defined the part of the BPR where to add the events

eventConfigs

list of event configurations to add.

Returns

nil

ADD_TRENDS adds an trend to a trends-section

Parameters

trackingScope

defined the part of the BPR where to add the events

trendConfigs

list of event configurations to add.

Returns

true on success, false otherwise

CLEAR_EVENTS(trackingScope)

CLEAR_EVENTS clear all events in that trackingScope

Parameters

trackingScope

Section of the BPR where to remove the events.

Returns

true on success, false if not possible

CLEAR_TRENDS clear all trends in that trackingScope

Parameters

trackingScope

Section of the BPR where to remove the trends.

Returns

true on success, false if not possible

ADD_TREND_BATCH(trendCfg)

ADD_TREND_BATCH add one trend config to a batch

Parameters

trendCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_TREND_CURRENT_OPERATION(trendCfg)

ADD_TREND_CURRENT_OPERATION add one trend config to the current operation

Parameters

trendCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_TREND_CURRENT_EQ_PHASE(trendCfg)

ADD_TREND_CURRENT_EQ_PHASE add one trend config to the current eq. phase

Parameters

trendCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_TREND_CURRENT_EQ_STEP(trendCfg)

ADD_TREND_CURRENT_EQ_STEP add one trend config to the current eq. step

Parameters

trendCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_TREND_RECENT_OPERATION(trendCfg)

ADD_TREND_RECENT_OPERATION add one trend config to the recent closed operation

Parameters

trendCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_TREND_RECENT_EQ_PHASE(trendCfg)

ADD_TREND_RECENT_EQ_PHASE add one trend config to the recent closed eq. phase

Parameters

trendCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_TREND_RECENT_EQ_STEP(trendCfg)

ADD_TREND_RECENT_EQ_PHASE add one trend config to the recent closed eq. step

Parameters

trendCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_EVENT_BATCH(eventCfg)

ADD_EVENT_BATCH add one event config to a batch

Parameters

eventCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_EVENT_CURRENT_OPERATION(eventCfg)

ADD_EVENT_CURRENT_OPERATION add one event config to the current operation

Parameters

eventCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_EVENTS_CURRENT_EQ_PHASE(eventCfg)

ADD_EVENTS_CURRENT_EQ_PHASE add one event config to the current eq. phase

Parameters

eventCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_EVENTS_CURRENT_EQ_STEP(eventCfg)

ADD_EVENTS_CURRENT_EQ_STEP add one event config to the current eq. step

Parameters

eventCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_EVENTS_RECENT_OPERATION(eventCfg)

ADD_EVENTS_RECENT_OPERATION add one event config to the recent closed operation

Parameters

eventCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_EVENTS_RECENT_EQ_PHASE(eventCfg)

ADD_EVENTS_RECENT_EQ_PHASE add one event config to the recent closed eq. phase

Parameters

eventCfg

the configuration to add.

Returns

true on success, false if not possible.

ADD_EVENTS_RECENT_EQ_STEP(eventCfg)

ADD_EVENTS_RECENT_EQ_STEP add one event config to the recent closed eq. step

Parameters

eventCfg

the configuration to add.

Returns

true on success, false if not possible.

HAS_CURRENT_OPERATION()

HAS_CURRENT_OPERATION return true if a current operation exists.

Returns

  • returns true if operation exists.

  • true on success, false if not possible.

HAS_CURRENT_EQ_PHASE()

HAS_CURRENT_EQ_PHASE return true if a current eq. phase exists.

Returns

returns true if operation exists.

HAS_CURRENT_EQ_STEP()

HAS_CURRENT_EQ_STEP return true if a current eq. step exists.

Returns

returns true if operation exists.

GET_CURRENT_OPERATION()

GET_CURRENT_OPERATION returns the current operation or nil.

Returns

returns the current operation or nil.

GET_CURRENT_EQ_PHASE()

GET_CURRENT_EQ_PHASE returns the current eq. phase or nil.

Returns

returns the current eq. phase or nil.

GET_CURRENT_EQ_STEP()

GET_CURRENT_EQ_PHASE returns the current eq. phase or nil.

Returns

returns the current eq. step or nil.

GET_RECENT_OPERATION()

GET_RECENT_OPERATION returns the recent closed operation or nil.

Returns

returns the recent closed operation or nil.

GET_RECENT_EQ_PHASE()

GET_RECENT_EQ_PHASE returns the recent closed eq. phase or nil.

Returns

returns the recent closed eq. phase or nil.

GET_RECENT_EQ_STEP()

GET_RECENT_EQ_STEP returns the recent closed eq. step or nil.

Returns

returns the recent closed eq. step or nil.

CREATE_NEW_OPERATION(time,curopdata,reason,trendsCfgs,eventsCfgs)

CREATE_NEW_OPERATION creates a new operation

Parameters

time
     timestamp for the cration
curopdata
data of the operation to create
reason
   start reason for that operation
trendsCfgs

list of lists of trend configurations e.g. \{\{\{name="..", pens=\{…​},…​}}}

eventsCfgs

list of lists of event configurations e.g. \{\{\{name="..", type=..,…​}}}

Returns

  • opEnd, phaseEnd, stepEnd

  • opEnd==true if operation was ended.

  • phaseEnd==true if phase was ended.

  • stepEnd==true if step was eneded.

CREATE_NEW_EQ_PHASE(time,epdata,reason,trendsCfgs,eventsCfgs)

CREATE_NEW_EQ_PHASE creates a new eq. phase

Parameters

time
     timestamp for the cration
epdata
   data of the eq. phase to create
reason
   start reason for that operation
trendsCfgs

list of lists of trend configurations e.g. \{\{\{name="..", pens=\{…​},…​}}}

eventsCfgs

list of lists of event configurations e.g. \{\{\{name="..", type=..,…​}}}

Returns

  • true, phaseEnd, stepEnd

  • phaseEnd==true if phase was ended.

  • stepEnd==true if step was eneded.

CREATE_NEW_PHASE(time,phdata,reason)

CREATE_NEW_PHASE creates a new phase

Parameters

time
     timestamp for the cration
phdata
   data of the phase to create
reason
   start reason for that operation

Returns

true on success

CREATE_NEW_EQ_STEP(time,esdata,reason,trendsCfgs,eventsCfgs)

CREATE_NEW_EQ_STEP creates a new eq. step

Parameters

time
     timestamp for the cration
esdata
   data of the eq. step to create
reason
   start reason for that operation
trendsCfgs

list of lists of trend configurations e.g. \{\{\{name="..", pens=\{…​},…​}}}

eventsCfgs

list of lists of event configurations e.g. \{\{\{name="..", type=..,…​}}}

Returns

  • stepStart, stepEnd

  • stepStart==true if step started successfully.

  • stepEnd==true if previous step was eneded.

END_BATCH(time,reason)

END_BATCH ends the currently running BATCH

Parameters

time
 timestamp of batch end
reason

reason of the batch end.

Returns

  • opEnd, phaseEnd, stepEnd

  • opEnd==true if an operation was ended.

  • phaseEnd==true if an eq. phase was ended.

  • stepEnd==true if an eq. step was ended.

FINALIZE()

This function finalizes the batch record before it gets detached

CLOSE_BATCH_RECORD(time)

CLOSE_BATCH_RECORD closes a batch (data management-wise)

Modifies: self.batch.equipment.state

Returns

  1. true, if the structural integrity exists, (2) optional error

END_OPERATION(time,reason)

END_OPERATION ends the currently running operation

Parameters

time
 timestamp of batch end
reason

reason of the batch end.

Returns

  • opEnd, phaseEnd, stepEnd

  • opEnd==true if an operation was ended.

  • phaseEnd==true if an eq. phase was ended.

  • stepEnd==true if an eq. step was ended.

END_CURRENT_EQ_PHASE(time,opdata,reason)

END_CURRENT_EQ_PHASE ends the currently running eq. phase

Parameters

time
 timestamp of batch end
opdate

data of the operation, under which the eq. phase runs.

reason

reason of the batch end

Returns

  • phaseEnd, stepEnd

  • phaseEnd==true if an eq. phase was ended.

  • stepEnd==true if an eq. step was ended.

END_CURRENT_PHASE(time,opdata,reason)

END_CURRENT_PHASE ends the currently running eq. phase

Parameters

time
 timestamp of batch end
opdate

data of the operation, under which the phase runs.

reason

reason of the batch end

Returns

returns true, if phase wan ended.

END_CURRENT_EQ_STEP(time,opdata,epdata,reason)

END_CURRENT_EQ_STEP ends the currently running eq. step

Parameters

time
 timestamp of batch end
opdate

data of the operation, under which the eq. step runs.

epdate

data of the eq. phase, under which the eq. step runs.

reason

reason of the batch end

Returns

  • stepEnd

  • stepEnd==true if an eq. step was ended.

WRITE_TO_TARGET(time,data,batch,operation,phase,step,target)

WRITE_TO_TARGET write data to target

Parameters

time
     timestamp of the write operation
data
     data in the format: { {res={v, q, t, vorg, eu, error}, def=<characteristics definition>, suc=true/false} }
def
      the definition record from the characterisics map
batch
    whether the returned value shall be assigned to the batch
operation
whether the returned value shall be assigned to the current operation
recphase
 whether the returned value shall be assigned to the current recipe phase
eqphase
  whether the returned value shall be assigned to the current equipment phase
eqstep
   whether the returned value shall be assigned to the current equipment step
alt_target

an alternative target for the data

Returns

nil

WRITE_TO_BATCH(time,data,def)

WRITE_TO_BATCH write data to the batch

Parameters

time
     timestamp of the write operation
data
     data in the format: { {res={v, q, t, vorg, eu, error}, def=<characteristics definition>, suc=true/false} }
def
      the definition record from the characterisics map

WRITE_TO_CURRENT_OPERATION(time,data,def)

WRITE_TO_CURRENT_OPERATION write data to the current operation

Parameters

time
     timestamp of the write operation
data
     data in the format: { {res={v, q, t, vorg, eu, error}, def=<characteristics definition>, suc=true/false} }
def
      the definition record from the characterisics map

WRITE_TO_CURRENT_EQ_PHASE(time,data,def)

WRITE_TO_CURRENT_EQ_PHASE write data to the current eq. phase

Parameters

time
     timestamp of the write operation
data
     data in the format: { {res={v, q, t, vorg, eu, error}, def=<characteristics definition>, suc=true/false} }
def
      the definition record from the characterisics map

WRITE_TO_CURRENT_EQ_STEP(time,data,def)

WRITE_TO_CURRENT_EQ_STEP write data to the current eq. step

Parameters

time
     timestamp of the write operation
data
     data in the format: { {res={v, q, t, vorg, eu, error}, def=<characteristics definition>, suc=true/false} }
def
      the definition record from the characterisics map

WRITE_TO_RECENT_OPERATION(time,data,def)

WRITE_TO_RECENT_OPERATION write data to the recent closed operation

Parameters

time
     timestamp of the write operation
data
     data in the format: { {res={v, q, t, vorg, eu, error}, def=<characteristics definition>, suc=true/false} }
def
      the definition record from the characterisics map

Returns

returns true on success, and false on error

WRITE_TO_RECENT_EQ_PHASE(time,data,def)

WRITE_TO_RECENT_EQ_PHASE write data to the recent closed eq. phase

Parameters

time
     timestamp of the write operation
data
     data in the format: { {res={v, q, t, vorg, eu, error}, def=<characteristics definition>, suc=true/false} }
def
      the definition record from the characterisics map

Returns

returns true on success, and false on error

WRITE_TO_RECENT_EQ_STEP(time,data,def)

WRITE_TO_RECENT_EQ_STEP write data to the recent closed eq. step

Parameters

time
     timestamp of the write operation
data
     data in the format: { {res={v, q, t, vorg, eu, error}, def=<characteristics definition>, suc=true/false} }
def
      the definition record from the characterisics map

Returns

returns true on success, and false on error

AGGREGATE_BATCH(open_only)

AGGREGATE_RECENT_OPERATION(open_only)

AGGREGATE_RECENT_EQ_PHASE(open_only)

AGGREGATE_RECENT_EQ_STEP(open_only)

SET_PHASE_EQUIPMENT(equipment)

SET_PHASE_EQUIPMENT set equipment for the current equipment phase

Parameters

equipment

equipment configuration to add to the BPR

Returns

  • true if equipment was assigned

  • false if no current equipment phase exists.

SET_MATERIAL_TYPE(matType)

SET_MATERIAL_TYPE Set functions for the material type

Parameters

matType

material type

SET_MATERIAL_TYPE_CODE(matTypeCode)

SET_ERP_ORDER(erpOrder)

SET_MES_ORDER_ID(mesOrderId)

SET_MES_ID(mesId)

GET_MATERIAL_TYPE()

GET_MATERIAL_TYPE_CODE()

GET_ERP_ORDER()

GET_MES_ORDER_ID()

GET_MES_ID()

ADD_MESSAGE(text,batch,time)

GET_CONFIG()

GET_STATE()

ADD_MONITORING_SESSION(time,calls,regular,recover,cfgversion)

SET_SYSTEM_SETTINGS(config)

NEW(config,flags,time,reason,active,id)

TO_JSON(config,state)

TO_SHORT_JSON(config,state)