Exemple #1
0
        public static void InitDrivers()
        {
            inputDrivers = new InputDrivers();
            foreach (KeyValuePair <string, IOData> item in docIO.dicInput)
            {
                InputDriver driver = new InputDriver();
                inputDrivers.dicDrivers.Add(item.Value.Name, driver);
            }
            foreach (KeyValuePair <string, InputDriver> item in inputDrivers.dicDrivers)
            {
                item.Value.Init(docIO.dicInput[item.Key]);
            }

            outputDrivers = new OutputDrivers();
            foreach (KeyValuePair <string, IOData> item in docIO.dicOutput)
            {
                OutputDriver driver = new OutputDriver();
                outputDrivers.dicDrivers.Add(item.Value.Name, driver);
            }
            foreach (KeyValuePair <string, OutputDriver> item in outputDrivers.dicDrivers)
            {
                item.Value.Init(docIO.dicOutput[item.Key]);
            }

            Thread threadScan = new Thread(ThreadScanIO);

            threadScan.IsBackground = true;
            threadScan.Start();
        }
Exemple #2
0
 public static InputDriver INPUT(string strName)
 {
     try
     {
         return(inputDrivers.dicDrivers[strName]);
     }
     catch
     {
         //不存在名为 strName 的输入
         InputDriver driver = new InputDriver();
         inputDrivers.dicDrivers.Add(strName, driver);
         return(inputDrivers.dicDrivers[strName]);
     }
 }
Exemple #3
0
        public static bool IORename(string strOldName, string strNewName, bool bInput)
        {
            try
            {
                if (string.IsNullOrEmpty(strOldName) || string.IsNullOrEmpty(strNewName) || docIO == null)
                {
                    return(false);
                }
                if (bInput)
                {
                    #region Input
                    if (!docIO.dicInput.ContainsKey(strOldName) || docIO.dicInput.ContainsKey(strNewName))
                    {
                        return(false);
                    }
                    foreach (IOData item in docIO.listInput)
                    {
                        if (item.Name.Equals(strOldName))
                        {
                            item.Name = strNewName;
                            docIO.dicInput.Remove(strOldName);
                            docIO.dicInput.Add(strNewName, item);

                            if (inputDrivers.dicDrivers.ContainsKey(strOldName))
                            {
                                InputDriver temp = inputDrivers.dicDrivers[strOldName];
                                inputDrivers.dicDrivers.Remove(strOldName);
                                temp.strDriverName = strNewName;
                                inputDrivers.dicDrivers.Add(strNewName, temp);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    #region Output
                    if (!docIO.dicOutput.ContainsKey(strOldName) || docIO.dicOutput.ContainsKey(strNewName))
                    {
                        return(false);
                    }
                    foreach (IOData item in docIO.listOutput)
                    {
                        if (item.Name.Equals(strOldName))
                        {
                            item.Name = strNewName;
                            docIO.dicOutput.Remove(strOldName);
                            docIO.dicOutput.Add(strNewName, item);

                            if (outputDrivers.dicDrivers.ContainsKey(strOldName))
                            {
                                OutputDriver temp = outputDrivers.dicDrivers[strOldName];
                                outputDrivers.dicDrivers.Remove(strOldName);
                                temp.strDriverName = strNewName;
                                outputDrivers.dicDrivers.Add(strNewName, temp);
                            }
                        }
                    }
                    #endregion
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }