Пример #1
0
        private static void CrateCommand(List <STATIONNAME> StationNames, DEVICECATEGORY DeviceName, dynamic SetCommand, List <Type> Parameter, List <String> ParameterDescription)
        {
            TCSCommandStructure NewCommand = new TCSCommandStructure();

            NewCommand.StationOwner         = StationNames;
            NewCommand.DeviceCategory       = DeviceName;
            NewCommand.Command              = SetCommand;
            NewCommand.Parameter            = Parameter;
            NewCommand.ParameterDescription = ParameterDescription;
            CommandList.Add(NewCommand);
        }
Пример #2
0
        public static TCSCommandStructure GetCommandDefinition(dynamic CommandName)
        {
            try
            {
                TCSCommandStructure ThisCommand = CommandList.FirstOrDefault(Item => Item.Command == CommandName);
                if (ThisCommand.Parameter.Count > 0)
                {
                    String Temp = "";
                }

                return(ThisCommand);
            }
            catch { return(null); }
        }
Пример #3
0
        private static ReturnKnowType VerifyParameter(TCSCommandStructure ThisCommand, Object[] Value)
        {
            String ParameterFormat = "";

            if (ThisCommand.Parameter != null)
            {
                ParameterFormat = String.Join(", ", ThisCommand.Parameter);
            }

            if ((Value == null || Value.Count() == 0) && ThisCommand.Parameter != null)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD005) Missing parameter for Command name " + ThisCommand.Command + "(" + ParameterFormat + ")"));
            }
            else if ((Value == null || Value.Count() == 0) && ThisCommand.Parameter == null)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null));
            }
            else if ((Value == null || Value.Count() == 0) && ThisCommand.Parameter == null)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD006) Command name (" + ThisCommand.Command + ") has no parameter. Please check."));
            }

            if (ThisCommand.Parameter.Count() != Value.Count())
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD002) Command name (" + ThisCommand.Command + ") does not contain " + Value.Count() + " Parameters. Please cheange it to " + ThisCommand.Command + "(" + ParameterFormat + ")"));
            }
            else if (ThisCommand.Parameter.Count() == 0 && Value.Count() == 0)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null));
            }

            for (int i = 0; i < Value.Count(); i++)
            {
                Type ParaType = VerifyDataType(Value[i], ThisCommand.Parameter[i]);
                if (ThisCommand.Parameter[i] != ParaType)
                {
                    return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD003) Invalid parameter see. Command name " + ThisCommand.Command + "(" + ParameterFormat + ")"));
                }
            }

            return(ReturnKnowType.DefineReturn(ReturnStatus.SUCESSFUL, null));
        }
Пример #4
0
        public static ReturnKnowType VerifyCommand(STATIONNAME StationName, DEVICECATEGORY DeviceCategory, dynamic CommandName, Object[] Value)
        {
            if (CommandName == null)
            {
                return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD001) Failed to get command name from list see. (Command name was not avaliable.)"));
            }

            TCSCommandStructure ThisCommand = CommandList.FirstOrDefault(Item => Item.StationOwner.Contains(StationName) && Item.DeviceCategory == DeviceCategory && Item.Command.ToString() == CommandName.ToString());

            if (ThisCommand != null)
            {
                List <String> ValueStr = new List <String>();
                foreach (Object ThisValue in Value)
                {
                    ValueStr.Add(ThisValue.ToString());
                }

                Object[]       Values     = ValueConvertion(ValueStr.ToArray());
                ReturnKnowType ThisReturn = VerifyParameter(ThisCommand, Values);
                return(ThisReturn);
            }

            return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#CD004) Could not be found commmand (" + CommandName + ") that contain station name : (" + StationName + ") Device Name : (" + DeviceCategory + "). Please check station name or device name."));
        }