Esempio n. 1
0
        public static void InitHandlers(IedServer iedServer, IedModel iedModel)
        {
            foreach (var itemDataObject in UpdateDataObj.UpdateListDestination)
            {
                var temp = (DataObject)iedModel.GetModelNodeByShortObjectReference(itemDataObject.NameDataObj);

                if (itemDataObject.BaseClass.GetType() == typeof(SpcClass))
                {
                    object tempParam = ((SpcClass)itemDataObject.BaseClass).ctlModel;

                    iedServer.SetCheckHandler(temp,
                                              (controlObject, parameter, ctlVal, test, interlockCheck, connection) =>
                    {
                        //controlObject
                        //iedServer.

                        //if(interlockCheck)

                        var result = CheckHandlerResult.ACCEPTED;
                        return(result);
                    },
                                              tempParam);

                    iedServer.SetWaitForExecutionHandler(temp,
                                                         (controlObject, parameter, ctlVal, test, synchroCheck) =>
                    {
                        //ControlHandlerResult.WAITING
                        var result = ControlHandlerResult.OK;
                        return(result);
                    },
                                                         tempParam);

                    iedServer.SetControlHandler(temp,
                                                (controlObject, parameter, ctlVal, test) =>
                    {
                        if (ctlVal.GetType() != MmsType.MMS_BOOLEAN)
                        {
                            return(ControlHandlerResult.FAILED);
                        }

                        if (!test)
                        {
                            var tempValue = new
                            {
                                Key   = "stVal",
                                Value = ctlVal.GetBoolean()
                            };
                            itemDataObject.WriteValue(tempValue);
                        }

                        return(ControlHandlerResult.OK);
                    },
                                                tempParam);
                }
                else if (itemDataObject.BaseClass.GetType() == typeof(IncClass))
                {
                    iedServer.SetWaitForExecutionHandler(temp, (controlObject, parameter, val, test, check) =>
                                                         test ? ControlHandlerResult.FAILED : ControlHandlerResult.OK, null);

                    iedServer.SetControlHandler(temp, (controlObject, parameter, ctlVal, test) =>
                    {
                        if (ctlVal.GetType() != MmsType.MMS_INTEGER)
                        {
                            return(ControlHandlerResult.FAILED);
                        }

                        itemDataObject.WriteValue(ctlVal.ToInt32());

                        return(ControlHandlerResult.OK);
                    }, null);
                }
            }
        }
Esempio n. 2
0
        private static void InitHandlersClass(IedServer iedServer, IedModel iedModel)
        {
            foreach (var itemDataObject in UpdateDataObj.UpdateListDestination)
            {
                var temp = (DataObject)iedModel.GetModelNodeByShortObjectReference(itemDataObject.NameDataObj);

                if (itemDataObject.BaseClass.GetType() == typeof(SpcClass))
                {
                    iedServer.SetWaitForExecutionHandler(temp, (controlObject, parameter, val, test, check) =>
                                                         test ? ControlHandlerResult.FAILED : ControlHandlerResult.OK, null);

                    iedServer.SetControlHandler(temp, (controlObject, parameter, ctlVal, test) =>
                    {
                        if (ctlVal.GetType() != MmsType.MMS_BOOLEAN)
                        {
                            return(ControlHandlerResult.FAILED);
                        }

                        itemDataObject.WriteValue(ctlVal.GetBoolean());

                        return(ControlHandlerResult.OK);
                    }, null);
                }
                else if (itemDataObject.BaseClass.GetType() == typeof(IncClass))
                {
                    iedServer.SetWaitForExecutionHandler(temp, (controlObject, parameter, val, test, check) =>
                                                         test ? ControlHandlerResult.FAILED : ControlHandlerResult.OK, null);

                    iedServer.SetControlHandler(temp, (controlObject, parameter, ctlVal, test) =>
                    {
                        if (ctlVal.GetType() != MmsType.MMS_INTEGER)
                        {
                            return(ControlHandlerResult.FAILED);
                        }

                        itemDataObject.WriteValue(ctlVal.ToInt32());

                        return(ControlHandlerResult.OK);
                    }, null);
                }
            }

            //foreach (var itemGetObjects in UpdateDataObj.ClassGetObjects)
            //{
            //	foreach (var itemDataClass in itemGetObjects.DataClass)
            //	{
            //		var temp = (DataObject)iedModel.GetModelNodeByShortObjectReference(itemDataClass.NameDataObj);

            //		if (itemDataClass.DataObj.GetType() == typeof(SpcClass))
            //		{
            //			//switch (((SpcClass) itemDataClass.DataObj).ctlModel.CtlModels)

            //			iedServer.SetWaitForExecutionHandler(temp, (controlObject, parameter, val, test, check) =>
            //				test ? ControlHandlerResult.FAILED : ControlHandlerResult.OK, null);

            //			iedServer.SetControlHandler(temp, (controlObject, parameter, ctlVal, test) =>
            //			{
            //				if (ctlVal.GetType() != MmsType.MMS_BOOLEAN )
            //					return ControlHandlerResult.FAILED;

            //				UpdateSPC(UpdateDataObj.ClassGetObjects.IndexOf(itemGetObjects), itemGetObjects.DataClass.IndexOf(itemDataClass), ctlVal.GetBoolean());

            //				return ControlHandlerResult.OK;
            //			}, null);
            //		}

            //		else if (itemDataClass.DataObj.GetType() == typeof(IncClass))
            //		{
            //			iedServer.SetWaitForExecutionHandler(temp, (controlObject, parameter, val, test, check) =>
            //				test ? ControlHandlerResult.FAILED : ControlHandlerResult.OK, null);

            //			iedServer.SetControlHandler(temp, (controlObject, parameter, ctlVal, test) =>
            //			{
            //				if (ctlVal.GetType() != MmsType.MMS_INTEGER)
            //					return ControlHandlerResult.FAILED;

            //				UpdateINC(UpdateDataObj.ClassGetObjects.IndexOf(itemGetObjects), ctlVal.ToInt32());
            //				return ControlHandlerResult.OK;
            //			}, null);
            //		}
            //	}
            //}

            foreach (var itemMod in UpdateDataObj.ModClass.PathModList)
            {
                var temp = (DataObject)iedModel.GetModelNodeByShortObjectReference(itemMod);

                iedServer.SetWaitForExecutionHandler(temp, (controlObject, parameter, val, test, check) =>
                                                     test ? ControlHandlerResult.FAILED : ControlHandlerResult.OK, null);

                iedServer.SetControlHandler(temp, (controlObject, parameter, ctlVal, test) =>
                {
                    if (ctlVal.GetType() != MmsType.MMS_INTEGER)
                    {
                        return(ControlHandlerResult.FAILED);
                    }

                    UpdateMod(ctlVal.ToInt32());
                    return(ControlHandlerResult.OK);
                }, null);
            }
        }