public void MmsValueStructure() { MmsValue val = MmsValue.NewEmptyStructure(2); val.SetElement(0, new MmsValue(true)); val.SetElement(1, MmsValue.NewBitString(10)); Assert.AreEqual(val.GetType(), MmsType.MMS_STRUCTURE); Assert.AreEqual(val.Size(), 2); MmsValue elem0 = val.GetElement(0); Assert.AreEqual(elem0.GetType(), MmsType.MMS_BOOLEAN); Assert.AreEqual(elem0.GetBoolean(), true); MmsValue elem1 = val.GetElement(1); Assert.AreEqual(elem1.GetType(), MmsType.MMS_BIT_STRING); }
public void MmsValueArray() { MmsValue val = MmsValue.NewEmptyArray(3); val.SetElement(0, new MmsValue(1)); val.SetElement(1, new MmsValue(2)); val.SetElement(2, new MmsValue(3)); Assert.AreEqual(val.GetType(), MmsType.MMS_ARRAY); Assert.AreEqual(val.Size(), 3); MmsValue elem0 = val.GetElement(0); Assert.AreEqual(elem0.GetType(), MmsType.MMS_INTEGER); Assert.AreEqual(elem0.ToInt32(), 1); MmsValue elem2 = val.GetElement(2); Assert.AreEqual(elem2.GetType(), MmsType.MMS_INTEGER); Assert.AreEqual(elem2.ToInt32(), 3); }
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 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); }