Example #1
0
        public void Add_Tag(Object obj, String type)
        {
            switch (type)
            {
            case "Analog Input":
                AnalogInput ai = (AnalogInput)obj;

                analogs_i.Add(ai);
                plcSimulatorManager.ainputs.TryAdd(ai.TagName, ai);
                plcSimulatorManager.addresses.TryAdd(ai.IO_address1, 0);

                break;

            case "Analog Output":
                analogs_o.Add((AnalogOutput)obj);
                plcSimulatorManager.addresses.TryAdd(analogs_o[analogs_o.Count - 1].IO_address1, 0);
                break;

            case "Digital Input":
                digitals_i.Add((DigitalInput)obj);
                plcSimulatorManager.addresses.TryAdd(digitals_i[digitals_i.Count - 1].IO_address1, 0);
                break;

            case "Digital Output":
                digitals_o.Add((DigitalOutput)obj);
                plcSimulatorManager.addresses.TryAdd(digitals_o[digitals_o.Count - 1].IO_address1, 0);
                break;

            default:
                break;
            }
        }
Example #2
0
        public void Remove_Tag(String tag_type, String tag)
        {
            switch (tag_type)
            {
            case "Analog Input":
                for (int i = 0;
                     i < analogs_i.Count; i++)
                {
                    if (tag.Equals(analogs_i[i].TagName))
                    {
                        AnalogInput ai = analogs_i[i];

                        if (plcSimulatorManager.ainputs.TryRemove(ai.IO_address1, out ai))
                        {
                            //pass
                        }

                        analogs_i.Remove(analogs_i[i]);

                        for (int j = 0; j < alarms.Count; j++)
                        {
                            if (alarms[j].Tag.Equals(ai.TagName))
                            {
                                Alarm al = alarms[j];

                                alarms.Remove(alarms[j]);
                                if (!plcSimulatorManager.flag_t5)
                                {
                                    plcSimulatorManager.alarms.TryRemove(al.Tag, out al);
                                }

                                bool tmp = true;

                                if (plcSimulatorManager.alarm_occured.TryRemove(al.Id, out tmp))
                                {
                                    //pass
                                }
                            }
                        }
                    }
                }
                break;

            case "Analog Output":
                for (int i = 0;
                     i < analogs_o.Count; i++)
                {
                    if (tag.Equals(analogs_o[i].TagName))
                    {
                        analogs_o.Remove(analogs_o[i]);
                    }
                }
                break;

            case "Digital Input":
                for (int i = 0;
                     i < digitals_i.Count; i++)
                {
                    if (tag.Equals(digitals_i[i].Tag_name))
                    {
                        digitals_i.Remove(digitals_i[i]);
                    }
                }
                break;

            case "Digital Output":
                for (int i = 0;
                     i < digitals_o.Count; i++)
                {
                    if (tag.Equals(digitals_o[i].Tag_name))
                    {
                        digitals_o.Remove(digitals_o[i]);
                    }
                }
                break;

            default:
                break;
            }
        }