示例#1
0
 public static void Main()
 {
     ServiceReference1.DatabaseManagerClient proxy = new ServiceReference1.DatabaseManagerClient();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1(proxy));
 }
示例#2
0
        public Form1(ServiceReference1.DatabaseManagerClient _proxy)
        {
            proxy = _proxy;
            InitializeComponent();
            function.SelectedIndex     = 0;
            tagType.SelectedIndex      = 0;
            driver.SelectedIndex       = 0;
            driverSubmit.SelectedIndex = 0;
            scan.Enabled = true;

            var            tags  = proxy.getTags();
            var            units = proxy.getUnits();
            Tag            t;
            SimulationUnit u;


            foreach (var tag in tags.Keys)
            {
                t = tags[tag];
                var item = new ListViewItem(t.tagId);
                item.SubItems.Add(t.description);
                item.SubItems.Add(t.driver.ToString());
                item.SubItems.Add(t.ioAddress.ToString());
                if (t is AITag)
                {
                    var ti = (AITag)t;
                    item.SubItems.Add(ti.scanTime.ToString());
                    item.SubItems.Add(ti.alarm.floor.ToString());
                    item.SubItems.Add(ti.alarm.ceiling.ToString());
                    item.SubItems.Add(ti.on ? "Yes":"No");
                    item.SubItems.Add(ti.auto ? "Yes":"No");
                    item.SubItems.Add("");
                    item.SubItems.Add(ti.low.ToString());
                    item.SubItems.Add(ti.high.ToString());
                    item.SubItems.Add(ti.units);
                }
                else if (t is AOTag)
                {
                    var ti = (AOTag)t;
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add(ti.initialValue.ToString());
                    item.SubItems.Add(ti.low.ToString());
                    item.SubItems.Add(ti.high.ToString());
                    item.SubItems.Add(ti.units);
                }
                else if (t is DITag)
                {
                    var ti = (DITag)t;
                    item.SubItems.Add(ti.scanTime.ToString());
                    item.SubItems.Add(ti.alarm.floor.ToString());
                    item.SubItems.Add(ti.alarm.ceiling.ToString());
                    item.SubItems.Add(ti.on ? "Yes" : "No");
                    item.SubItems.Add(ti.auto ? "Yes" : "No");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                }
                else if (t is DOTag)
                {
                    var ti = (DOTag)t;
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add(ti.initialValue.ToString());
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                }
                listViewTag.Items.Add(item);
            }

            foreach (var unit in units.Keys)
            {
                u = units[unit];
                ListViewItem item = new ListViewItem(u.id);
                item.SubItems.Add(u.address.ToString());
                item.SubItems.Add(u.fType.ToString());

                listViewUnit.Items.Add(item);
            }
        }