esi-batch-data
Batch data document
Example
local BATCHCONFIG = require("esi-batch-config")
local BATCHDATA = require("esi-batch-data")
local function getCharacteristic(id)
local charac = {
{ active=true,
code= syslib.model.codes.BatchField.CUSTOMMEASUREMENT,
tag="Custom Measurement",
meaning="Meaning1",
proc=syslib.model.codes.BatchFieldProcessing.DIRECT,
input="inputBD1", -- path of tag, not needed here.
label="Batch_Data_1",
euoverride="",
coll= syslib.model.codes.BatchDataCollection.TIMESERIESDISTINCT,
fix=nil,
map="",
map_exclusive=false,
script="",
order = 20,
},
{ active=true,
code= syslib.model.codes.BatchField.CUSTOMMEASUREMENT,
tag="Custom Measurement",
meaning="Meaning2",
proc=syslib.model.codes.BatchFieldProcessing.DIRECT,
input="inputBD2", -- path of tag, not needed here.
label="Batch_Data_2",
euoverride="Unit2",
coll= syslib.model.codes.BatchDataCollection.TIMESERIESDISTINCT,
fix=nil,
map="",
map_exclusive=false,
script="",
order = 10,
},
}
return charac[id]
end
local function getBatchIdCharac()
local batchIdCharac = {
active=true,
code= syslib.model.codes.BatchField.BATCHID,
tag="Batch ID",
meaning="",
proc=syslib.model.codes.BatchFieldProcessing.DIRECT,
input="", -- path of tag, not needed here.
label="BatchId",
euoverride="",
coll= syslib.model.codes.BatchDataCollection.TIMESERIESDISTINCT,
fix=nil,
map="",
map_exclusive=false,
script="",
}
return batchIdCharac
end
local batchid = "MyBatch01"
local config= BATCHCONFIG:NEW(cfgVersion, objectpath, objecttype )
local equipment = ("/TestCompany/Plant1/Area51/BatchTest/TestUnit/TestEquipment%i"):format(1)
local partial_batch = true
config:SET_S95_EQ_ASSIGNMENT(equipment, partial_batch)
config:SET_UNIQUE_CRITERIA(syslib.model.flags.BatchUniqueCriteria.EQUIPMENT_ID)
-- second create batch obj...
local flags = {debug=false, log=false} -- debug and log disabled
local starttime = syslib.now()
local reason
reason = "Start condition met"
local batchdata, dataErr =BATCHDATA:NEW(config, flags, starttime, reason, true, batchid)
local time = starttime
local data = {v=batchid, q=0, t=time }
batchdata:WRITE_TO_BATCH(time, data, getBatchIdCharac() )
local def
for j=1,10 do
time = starttime + 1000
data = {v=("%i"):format(j), q=0, t=time } -- norml v,q,t values
def = getCharacteristic(1) -- channel configuration
batchdata:WRITE_TO_BATCH(time, data, def ) -- write value 1 after the other.
data = {v=("%i"):format(j*j), q=0, t=time } -- norml v,q,t values
def = getCharacteristic(2) -- channel configuration
batchdata:WRITE_TO_BATCH(time, data, def ) -- write value 1 after the other.
end
batchdata:END_BATCH(time, reason)
batchdata:FINALIZE()
-- send the batch to the database.
--batchdata:SEND_BATCH()
return batchdata:TO_JSON()
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)
Documentation
SET_BATCH_ACTIVE
SET_BATCH_EQUIPMENT_STATE
Description
SET_BATCH_ACTIVE
set the active state of a batch modifies self.batch sets the equipment state of a batch (must be consistent with OMAC/PackML) modifies self.batch.equipment.state, extends self.batch.equipment.state.transitions
ADD_EVENTS
ADD_TRENDS
CREATE_NEW_OPERATION
Parameters
| Name | Description |
|---|---|
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=..,…}}} |
CREATE_NEW_EQ_PHASE
Parameters
| Name | Description |
|---|---|
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=..,…}}} |
CREATE_NEW_PHASE
CREATE_NEW_EQ_STEP
Parameters
| Name | Description |
|---|---|
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=..,…}}} |
END_CURRENT_EQ_PHASE
END_CURRENT_PHASE
END_CURRENT_EQ_STEP
WRITE_TO_TARGET
Parameters
| Name | Description |
|---|---|
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 |
WRITE_TO_RECENT_OPERATION
WRITE_TO_RECENT_EQ_PHASE
WRITE_TO_RECENT_EQ_STEP
AGGREGATE_BATCH
AGGREGATE_RECENT_OPERATION
Description
AGGREGATE_RECENT_OPERATION
(re)calculate the aggregated value for characteristics of the recent operation
AGGREGATE_RECENT_EQ_PHASE
Description
AGGREGATE_RECENT_EQ_PHASE
(re)calculate the aggregated value for characteristics of the recent equipment phase
AGGREGATE_RECENT_EQ_STEP
Description
AGGREGATE_RECENT_EQ_STEP
(re)calculate the aggregated value for characteristics of the recent equipment step
NEW
TO_JSON
TO_SHORT_JSON
Description
TO_SHORT_JSON
serialize the BPR to JSON, exclude some characteristics data to provide a short version