public void ControlWriteAccessComplexDAToServer() { IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile("../../model2.cfg"); IEC61850.Server.DataAttribute setAnVal_setMag = (IEC61850.Server.DataAttribute)iedModel.GetModelNodeByShortObjectReference("GenericIO/LLN0.SetAnVal.setMag"); IedServer iedServer = new IedServer(iedModel); int handlerCalled = 0; MmsValue receivedValue = null; iedServer.SetWriteAccessPolicy(FunctionalConstraint.SP, AccessPolicy.ACCESS_POLICY_DENY); iedServer.HandleWriteAccessForComplexAttribute(setAnVal_setMag, delegate(IEC61850.Server.DataAttribute dataAttr, MmsValue value, ClientConnection con, object parameter) { receivedValue = value; handlerCalled++; return(MmsDataAccessError.SUCCESS); }, null); iedServer.Start(10002); IedConnection connection = new IedConnection(); connection.Connect("localhost", 10002); MmsValue complexValue = MmsValue.NewEmptyStructure(1); complexValue.SetElement(0, new MmsValue((float)1.0)); connection.WriteValue("simpleIOGenericIO/LLN0.SetAnVal.setMag", FunctionalConstraint.SP, complexValue); Assert.NotNull(receivedValue); Assert.AreEqual(MmsType.MMS_STRUCTURE, receivedValue.GetType()); Assert.AreEqual(1.0, receivedValue.GetElement(0).ToFloat()); receivedValue.Dispose(); receivedValue = null; connection.WriteValue("simpleIOGenericIO/LLN0.SetAnVal.setMag.f", FunctionalConstraint.SP, new MmsValue((float)2.0)); Assert.NotNull(receivedValue); Assert.AreEqual(MmsType.MMS_FLOAT, receivedValue.GetType()); Assert.AreEqual(2.0, receivedValue.ToFloat()); connection.Abort(); iedServer.Stop(); iedServer.Dispose(); }
public void MmsValueClone() { MmsValue boolValue = new MmsValue(true); MmsValue boolClone = boolValue.Clone(); boolValue.Dispose(); boolClone.Dispose(); MmsValue structure = MmsValue.NewEmptyStructure(1); MmsValue structureClone = structure.Clone(); structure.Dispose(); structureClone.Dispose(); }
public void MmsValaueCreateStructureAndAddElement() { MmsValue structure1 = MmsValue.NewEmptyStructure(1); MmsValue structure2 = MmsValue.NewEmptyStructure(1); MmsValue element = MmsValue.NewEmptyStructure(1); structure1.SetElement(0, element); /* Clone is required when adding the value to another structure or element */ MmsValue elementClone = element.Clone(); structure2.SetElement(0, elementClone); element.Dispose(); structure1.Dispose(); structure2.Dispose(); Assert.AreEqual(true, true); }