Update UaModeler project to add condition object StateCondition to controller
Figure 6.1:
Condition Object OffNormalAlarm is added to ControllerType
Create code update and XML export
- BAIdentifiers.cs
- buildingautomation.xml
Figure 6.2:
Add initialization of Alarm object
After controller object creation
- Create alarm data model object
- Link to alarm nodes
SetChildUserData(
new NodeId(block.Name, InstanceNamespaceIndex),
new QualifiedName(yourorganisation.BA.BrowseNames.StartWithSetPoint, TypeNamespaceIndex),
new SystemFunction() { Address = block.Address, Function = 3 });
NodeId alarmId =
new NodeId(block.Name +
"." + yourorganisation.BA.BrowseNames.StateCondition, InstanceNamespaceIndex);
OffNormalAlarmModel alarm = new OffNormalAlarmModel();
alarm.NodeId = alarmId;
alarm.EventType = ObjectTypeIds.OffNormalAlarmType;
alarm.SourceNode =
new NodeId(block.Name, InstanceNamespaceIndex);
alarm.SourceName = block.Name;
alarm.ConditionName = "StateCondition";
alarm.ConditionClassId = ObjectTypeIds.ProcessConditionClassType;
alarm.ConditionClassName = BrowseNames.ProcessConditionClassType;
alarm.Retain = false;
alarm.EnabledState.Value = ConditionStateNames.Enabled;
alarm.EnabledState.Id = true;
alarm.AckedState.Value = ConditionStateNames.Acknowledged;
alarm.AckedState.Id = true;
alarm.ActiveState.Value = ConditionStateNames.Inactive;
alarm.ActiveState.Id = false;
alarm.SuppressedOrShelved = false;
LinkModelToNode(alarmId, alarm, null, null, 500);
foreach (BlockProperty property in block.Properties)
Set Alarm Active State
Change alarm state when controller state changes
Set in BlockStateChanged event
NodeId alarmId =
new NodeId(blockName +
"." + yourorganisation.BA.BrowseNames.StateCondition, InstanceNamespaceIndex);
OffNormalAlarmModel alarm = (OffNormalAlarmModel)GetNodeUserData(alarmId);
lock (alarm)
{
alarm.LastSeverity.Value = alarm.Severity;
alarm.LastSeverity.SourceTimestamp = alarm.Time;
if (state == 0)
{
alarm.Retain = true;
alarm.AckedState.Value = ConditionStateNames.Unacknowledged;
alarm.AckedState.Id = false;
alarm.Activate(
Server.DefaultRequestContext,
true);
}
else
{
alarm.Activate(
Server.DefaultRequestContext,
false);
if (alarm.AckedState.Id == true)
{
alarm.Retain = false;
}
}
e = alarm.CreateEvent(
Server.FilterManager);
}
ReportEvent(alarm.SourceNode, e);
Add Acknowledge handling
Override Acknowledge
RequestContext context,
AcknowledgeableConditionModel model,
byte[] eventId,
LocalizedText comment)
{
GenericEvent e = null;
lock (model)
{
StatusCode error = model.Acknowledge(context, eventId, comment);
if (error.IsBad())
{
return error;
}
e = model.CreateEvent(
Server.FilterManager);
}
ReportEvent(model.SourceNode, e);
return StatusCodes.Good;
}
Alarm View in UaExpert
Figure 6.3:
Alarms view is part of the Event view Alarm condition changes can be triggered with methods Acknowledge can be called from Alarm view