示例#1
0
        public bool AddAOTag(string id, string desc, double initValue, string rtuId, double lowLimit, double highLimit, string units)
        {
            foreach (Tag iter in tags)
            {
                if (iter.ID.Equals(id))
                {
                    return(false);
                }
            }

            AnalogOutput tag = new AnalogOutput();

            tag.ID          = id;
            tag.Description = desc;
            tag.LowLimit    = lowLimit;
            tag.HighLimit   = highLimit;
            tag.Units       = units;
            tag.Driver      = false;
            tag.IOAddress   = rtuId;
            tag.TagValue    = initValue;

            tags.Add(tag);
            //Thread thread = new Thread(new ParameterizedThreadStart(helper));
            //simThreads[tag.ID] = thread;
            //object[] arr = { id, initValue };
            //simThreads[tag.ID].Start(arr);
            return(true);
        }
示例#2
0
 public void addAO(AnalogOutput el)
 {
     if (el != null && !tags.ContainsKey(el.TagName))
     {
         lock (tags)
         {
             tags.Add(el.TagName, el);
         }
         Console.WriteLine("AO Tag :" + el.TagName + " is added");
     }
 }
示例#3
0
        public bool ChangeInfo(string tagId, Tuple <string, string> newVal)
        {
            int  i;
            Tag  tag   = null;
            bool check = false;

            for (i = 0; i < tags.Count; i++)
            {
                if (tags[i].ID.Equals(tagId))
                {
                    check = true;
                    tag   = tags[i];
                    break;
                }
            }

            if (!check)
            {
                return(false);
            }

            if (!newVal.Item2.Equals(""))
            {
                if (newVal.Item1.Equals("Name"))
                {
                    tag.ID = newVal.Item2;
                }
                else if (newVal.Item1.Equals("Description"))
                {
                    tag.Description = newVal.Item2;
                }
                else if (newVal.Item1.Equals("Units"))
                {
                    if (tag.GetType() == typeof(AnalogInput))
                    {
                        AnalogInput temp = (AnalogInput)tag;
                        temp.Units = newVal.Item2;
                        tag        = temp;
                    }
                    else
                    {
                        AnalogOutput temp = (AnalogOutput)tag;
                        temp.Units = newVal.Item2;
                        tag        = temp;
                    }
                }
                else if (newVal.Item1.Equals("Low limit"))
                {
                    if (tag.GetType() == typeof(AnalogInput))
                    {
                        AnalogInput temp = (AnalogInput)tag;
                        temp.LowLimit = double.Parse(newVal.Item2);
                        tag           = temp;
                    }
                    else
                    {
                        AnalogOutput temp = (AnalogOutput)tag;
                        temp.LowLimit = double.Parse(newVal.Item2);
                        tag           = temp;
                    }
                }
                else if (newVal.Item1.Equals("High limit"))
                {
                    if (tag.GetType() == typeof(AnalogInput))
                    {
                        AnalogInput temp = (AnalogInput)tag;
                        temp.HighLimit = double.Parse(newVal.Item2);
                        tag            = temp;
                    }
                    else
                    {
                        AnalogOutput temp = (AnalogOutput)tag;
                        temp.HighLimit = double.Parse(newVal.Item2);
                        tag            = temp;
                    }
                }
                else if (newVal.Item1.Equals("Scan time"))
                {
                    if (tag.GetType() == typeof(AnalogInput))
                    {
                        AnalogInput temp = (AnalogInput)tag;
                        temp.ScanTime = int.Parse(newVal.Item2);
                        tag           = temp;
                    }
                    else
                    {
                        DigitalInput temp = (DigitalInput)tag;
                        temp.ScanTime = int.Parse(newVal.Item2);
                        tag           = temp;
                    }
                }
                else // Inital value
                {
                    if (tag.GetType() == typeof(AnalogInput))
                    {
                        DigitalOutput temp = (DigitalOutput)tag;
                        temp.InitialValue = double.Parse(newVal.Item2);
                        tag = temp;
                    }
                    else
                    {
                        AnalogOutput temp = (AnalogOutput)tag;
                        temp.InitialValue = double.Parse(newVal.Item2);
                        tag = temp;
                    }
                }
            }

            tags[i] = tag;
            Serialize();
            return(true);
        }
示例#4
0
        public Dictionary <string, string> GetTagInfo(string tagId)
        {
            Dictionary <string, string> retVal = new Dictionary <string, string>();

            foreach (Tag tag in tags)
            {
                if (tag.ID.Equals(tagId))
                {
                    if (tag.GetType() == typeof(DigitalInput))
                    {
                        DigitalInput temp = (DigitalInput)tag;
                        retVal["Name"]        = temp.ID;
                        retVal["Type"]        = "DigitalInput";
                        retVal["Description"] = temp.Description;
                        retVal["Driver"]      = temp.Driver ? "Real-Time" : "Simulation";
                        retVal["I/O Address"] = temp.IOAddress;
                        retVal["Scan time"]   = temp.ScanTime.ToString();

                        string alarms = "";
                        foreach (string s in temp.Alarms)
                        {
                            alarms += s + "\n";
                        }

                        retVal["Alarms"]      = alarms;
                        retVal["Scan"]        = temp.OnOffScan ? "ON" : "OFF";
                        retVal["Auto/Manual"] = temp.AutoManual ? "AUTO" : "MANUAL";

                        return(retVal);
                    }
                    else if (tag.GetType() == typeof(AnalogInput))
                    {
                        AnalogInput temp = (AnalogInput)tag;
                        retVal["Name"]        = temp.ID;
                        retVal["Type"]        = "AnalogInput";
                        retVal["Description"] = temp.Description;
                        retVal["Driver"]      = temp.Driver ? "Real-Time" : "Simulation";
                        retVal["I/O Address"] = temp.IOAddress;
                        retVal["Scan time"]   = temp.ScanTime.ToString();

                        string alarms = "";
                        foreach (string s in temp.Alarms)
                        {
                            alarms += s + "\n";
                        }

                        retVal["Alarms"]      = alarms;
                        retVal["Scan"]        = temp.OnOffScan ? "ON" : "OFF";
                        retVal["Auto/Manual"] = temp.AutoManual ? "AUTO" : "MANUAL";
                        retVal["Low limit"]   = temp.LowLimit.ToString();
                        retVal["High limit"]  = temp.HighLimit.ToString();
                        retVal["Units"]       = temp.Units;

                        return(retVal);
                    }
                    else if (tag.GetType() == typeof(DigitalOutput))
                    {
                        DigitalOutput temp = (DigitalOutput)tag;
                        retVal["Name"]          = temp.ID;
                        retVal["Type"]          = "DigitalOutput";
                        retVal["Description"]   = temp.Description;
                        retVal["Driver"]        = temp.Driver ? "Real-Time" : "Simulation";
                        retVal["I/O Address"]   = temp.IOAddress;
                        retVal["Initial value"] = temp.InitialValue.ToString();

                        return(retVal);
                    }
                    else
                    {
                        AnalogOutput temp = (AnalogOutput)tag;
                        retVal["Name"]          = temp.ID;
                        retVal["Type"]          = "AnalogOutput";
                        retVal["Description"]   = temp.Description;
                        retVal["Driver"]        = temp.Driver ? "Real-Time" : "Simulation";
                        retVal["I/O Address"]   = temp.IOAddress;
                        retVal["Low limit"]     = temp.LowLimit.ToString();
                        retVal["High limit"]    = temp.HighLimit.ToString();
                        retVal["Units"]         = temp.Units;
                        retVal["Initial value"] = temp.InitialValue.ToString();

                        return(retVal);
                    }
                }
            }

            return(null);
        }