Skip to content

Commit

Permalink
fix: invalid structure in ISA95JobResponseDataType creation
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasHeine committed Nov 28, 2024
1 parent 76ac109 commit a20341c
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions src/machines/MyControledMachine/jobcontrol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
} from 'node-opcua'
import { ServerRolePermissionGroup } from '../../permissiongroups'
import { ISA95JobOrderDataType } from './interfaces'
import { ISA95_Method_ReturnCode, JobState } from './enums'
import { ISA95_Method_ReturnCode, JobState, JobStateNumber } from './enums'
import { green, yellow } from '../../utils/log'
import { randomUUID } from 'node:crypto'
import { Job } from './job'
Expand Down Expand Up @@ -160,11 +160,18 @@ export const createJobContolLogic = async (addressSpace: AddressSpace): Promise<
value: addressSpace.constructExtensionObject(ISA95JobResponseDataType, {
// https://reference.opcfoundation.org/ISA95JOBCONTROL/v200/docs/6.3.5
ID: `${randomUUID()}`,
Description: "", // TODO!
Description: coerceLocalizedText(null),
JobOrderID: JobOrderId,
StartTime: coerceDateTime(job!.startTime),
EndTime: coerceDateTime(job!.endTime),
JobState: [], // ISA95StateDataType[]
JobState: [
addressSpace.constructExtensionObject(ISA95StateDataType, {
// https://reference.opcfoundation.org/ISA95JOBCONTROL/v200/docs/6.3.2
BrowsePath: null,
StateText: new LocalizedText({locale: "en-EN", text: job!.state}),
StateNumber: job!.stateNumber
})
], // ISA95StateDataType[]
JobResponseData: [], // ISA95ParameterDataType[]
PersonnelActuals: [], // ISA95PersonnelDataType[]
EquipmentActuals: [], // ISA95EquipmentDataType[]
Expand All @@ -190,6 +197,17 @@ export const createJobContolLogic = async (addressSpace: AddressSpace): Promise<

const WorkMaster = JobOrderControl.getComponentByName("WorkMaster") as UAVariable

const JobOrderControlCurrentState = JobOrderControl.getComponentByName("CurrentState") as UAVariable
JobOrderControlCurrentState.setValueFromSource({
value: coerceLocalizedText(JobState.Running),
dataType: DataType.LocalizedText
})
const JobOrderControlCurrentStateId = JobOrderControlCurrentState.getPropertyByName("Id") as UAVariable
JobOrderControlCurrentStateId.setValueFromSource({
value: coerceNodeId(`ns=${ISA95Idx};i=5037`),
dataType: DataType.NodeId
})

const JobOrderMap = new Map<string, Job>()

function startJobOrder(JobOrderId: string, Comment: LocalizedText[]): ISA95_Method_ReturnCode {
Expand Down Expand Up @@ -855,6 +873,8 @@ export const createJobContolLogic = async (addressSpace: AddressSpace): Promise<

const job = JobOrderMap.get(JobOrderId)

console.log(job)

callback(null, {
// statusCode?: StatusCode;
statusCode: StatusCodes.Good,
Expand All @@ -866,21 +886,16 @@ export const createJobContolLogic = async (addressSpace: AddressSpace): Promise<
value: addressSpace.constructExtensionObject(ISA95JobResponseDataType, {
// https://reference.opcfoundation.org/ISA95JOBCONTROL/v200/docs/6.3.5
ID: `${randomUUID()}`,
Description: "", // TODO!
Description: coerceLocalizedText(null),
JobOrderID: JobOrderId,
StartTime: coerceDateTime(job!.startTime),
EndTime: coerceDateTime(job!.endTime),
JobState: [
new Variant({
value: [
addressSpace.constructExtensionObject(ISA95StateDataType, {
// https://reference.opcfoundation.org/ISA95JOBCONTROL/v200/docs/6.3.2
BrowsePath: null,
StateText: new LocalizedText({locale: "en-EN", text: job!.state}),
StateNumber: job!.stateNumber
})
],
dataType: DataType.ExtensionObject
addressSpace.constructExtensionObject(ISA95StateDataType, {
// https://reference.opcfoundation.org/ISA95JOBCONTROL/v200/docs/6.3.2
BrowsePath: null,
StateText: new LocalizedText({locale: "en-EN", text: job!.state}),
StateNumber: job!.stateNumber
})
], // ISA95StateDataType[]
JobResponseData: [], // ISA95ParameterDataType[]
Expand Down

0 comments on commit a20341c

Please sign in to comment.