private void txtChannel_EditValueChanged(object sender, EventArgs e)
 {
     ch = objChannelManager.GetByChannelName(txtChannel.Text);
     txtDevice.Properties.DataSource    = ch.Devices.ToList();
     txtDevice.Properties.DisplayMember = "DeviceName";
     txtDevice.Properties.ValueMember   = "DeviceId";
 }
Exemple #2
0
        private void TreeList1_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e)
        {
            try
            {
                var       SelectebNodes = TreeList1.Selection;
                DataBlock dbCurrent     = null; //Node: DataBlock
                Device    dvCurrent     = null; //Node: Device
                Channel   chCurrent     = null; //Node: Channel

                switch (SelectebNodes[0].Level)
                {
                case 0:

                    break;

                case 1:
                    break;

                case 2:
                    var dbNode = SelectebNodes[0];     // Node:DataBlock
                    var dvNode = dbNode.ParentNode;    // Node:Device
                    var chNode = dvNode.ParentNode;    // Node:Channel


                    var channelName = chNode["Name"].ToString();
                    var DeviceName  = dvNode["Name"].ToString();
                    ;
                    var DataBlockName = dbNode["Name"].ToString();
                    ;
                    chCurrent = objChannelManager.GetByChannelName(channelName);
                    dvCurrent = objDeviceManager.GetByDeviceName(chCurrent, DeviceName);
                    dbCurrent = objDataBlockManager.GetByDataBlockName(dvCurrent, DataBlockName);
                    var db = new DataBlock
                    {
                        ChannelId   = Convert.ToInt16(chCurrent.ChannelId),
                        DeviceId    = Convert.ToInt16(dvCurrent.DeviceId),
                        DataBlockId = dbCurrent.DataBlockId
                    };
                    bS7Tags = new BindingList <Tag>(dbCurrent.Tags);
                    RealTimeSource1.DataSource = bS7Tags;
                    gridView1.Invalidate();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                txtHistory.Text += string.Format("+ ERROR: {0}" + Environment.NewLine, ex.Message);
            }
        }
Exemple #3
0
 private void TxtChannel_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         ch = objChannelManager.GetByChannelName(txtChannel.Text);
         txtDevice.DataSource    = ch.Devices.ToList();
         txtDevice.DisplayMember = "DeviceName";
         txtDevice.ValueMember   = "DeviceId";
     }
     catch (Exception ex)
     {
         EventscadaException?.Invoke(GetType().Name, ex.Message);
     }
 }
        private void TreeList1_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e)
        {
            try
            {
                var s = FullNameByNode(e.Node, 0);
                sp = s.Split('\\');
                var       SelectebNodes = TreeList1.Selection;
                DataBlock dbCurrent     = null; //Node: DataBlock
                Device    dvCurrent     = null; //Node: Device
                Channel   chCurrent     = null; //Node: Channel

                TreeListNode dbNode = null;
                TreeListNode dvNode = null;
                TreeListNode chNode = null;
                switch (SelectebNodes[0].Level)
                {
                case 0:
                    chCurrent = objChannelManager.GetByChannelName(TreeList1.FocusedNode.GetDisplayText(0));
                    switch (chCurrent.ConnectionType)
                    {
                    case "SerialPort":
                        vGridSerialPort.Visible = true;
                        bChannelEthernet        = new List <Channel>();
                        bDISerialPort           = new List <DISerialPort>();
                        var dis = (DISerialPort)chCurrent;

                        bChannelEthernet.Add(chCurrent);
                        bDISerialPort.Add(dis);
                        vGridSerialPort.DataSource = bDISerialPort;
                        vGridChannel.DataSource    = bChannelEthernet;
                        vGridEthernet.Visible      = false;
                        break;

                    case "Ethernet":
                        vGridEthernet.Visible = true;
                        bChannelEthernet      = new List <Channel>();
                        bDIEthernet           = new List <DIEthernet>();
                        var die = (DIEthernet)chCurrent;

                        bChannelEthernet.Add(chCurrent);
                        bDIEthernet.Add(die);
                        vGridEthernet.DataSource = bDIEthernet;
                        vGridChannel.DataSource  = bChannelEthernet;
                        vGridSerialPort.Visible  = false;
                        break;
                    }
                    break;

                case 1:
                    bvDevice  = new List <Device>();
                    chCurrent = objChannelManager.GetByChannelName(TreeList1.FocusedNode.ParentNode.GetDisplayText(0));
                    dvCurrent = objDeviceManager.GetByDeviceName(chCurrent, TreeList1.FocusedNode.GetDisplayText(0));

                    bvDevice.Add(dvCurrent);
                    vGridDevice.DataSource = bvDevice;
                    break;

                case 2:
                    dbNode = SelectebNodes[0];     // Node:DataBlock
                    dvNode = dbNode.ParentNode;    // Node:Device
                    chNode = dvNode.ParentNode;    // Node:Channel


                    var channelName   = chNode["Name"].ToString();
                    var DeviceName    = dvNode["Name"].ToString();
                    var DataBlockName = dbNode["Name"].ToString();

                    chCurrent = objChannelManager.GetByChannelName(channelName);
                    dvCurrent = objDeviceManager.GetByDeviceName(chCurrent, DeviceName);
                    dbCurrent = objDataBlockManager.GetByDataBlockName(dvCurrent, DataBlockName);

                    bvDataBlock = new List <DataBlock>();

                    bvDataBlock.Add(dbCurrent);
                    vGridDataBlock.DataSource = bvDataBlock;

                    _SelectedTag = new List <string>();

                    foreach (var tg in dbCurrent.Tags)
                    {
                        var tgName = $"{channelName}.{DeviceName}.{DataBlockName}.{tg.TagName}";

                        _SelectedTag.Add(tgName);
                    }

                    bS7Tags = new BindingList <Tag>(dbCurrent.Tags);
                    RealTimeSource1.DataSource = bS7Tags;
                    gridView1.Invalidate();
                    break;
                }
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke(this.GetType().Name, ex.Message);
            }
        }
Exemple #5
0
        private void treeViewSI_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                if (treeViewSI.SelectedNode == null)
                {
                    return;
                }

                int       Level        = treeViewSI.SelectedNode.Level;
                string    selectedNode = treeViewSI.SelectedNode.Text;
                DataBlock dbCurrent    = null; //Node: DataBlock
                Device    dvCurrent    = null; //Node: Device
                Channel   chCurrent    = null; //Node: Channel
                switch (Level)
                {
                case 0:
                    DGMonitorForm.Rows.Clear();
                    break;

                case 1:
                    DGMonitorForm.Rows.Clear();
                    break;

                case 2:
                    chCurrent = objChannelManager.GetByChannelName(treeViewSI.SelectedNode.Parent.Parent.Text);
                    dvCurrent = objDeviceManager.GetByDeviceName(chCurrent, treeViewSI.SelectedNode.Parent.Text);
                    dbCurrent = objDataBlockManager.GetByDataBlockName(dvCurrent, treeViewSI.SelectedNode.Text);
                    DGMonitorForm.Rows.Clear();
                    string[] row = new string[7];
                    foreach (Tag tg in dbCurrent.Tags)
                    {
                        if (tg.Value == null)
                        {
                            row[0] = string.Format("{0}", tg.TagId);
                            row[1] = tg.TagName;
                            row[2] = string.Format("{0}", tg.Address);
                            row[3] = string.Format("{0}", tg.DataType);
                            row[4] = "0";
                            row[5] = string.Format("{0}", tg.TimeSpan);
                            row[6] = tg.Description;

                            DGMonitorForm.Rows.Add(row);
                        }
                        else
                        {
                            string[] row1 = { string.Format("{0}", tg.TagId), tg.TagName, string.Format("{0}", tg.Address), string.Format("{0}", tg.DataType), string.Format("{0}", tg.Value), string.Format("{0}", tg.TimeSpan), tg.Description };

                            DGMonitorForm.Rows.Add(row1);
                        }
                    }
                    break;

                default:
                    DGMonitorForm.Rows.Clear();
                    break;
                }
                if (chCurrent == null)
                {
                    EventPvGridChannelGet?.Invoke(chCurrent, false);
                }
                else
                {
                    switch (chCurrent.ConnectionType)
                    {
                    case "SerialPort":

                        DISerialPort dis = (DISerialPort)chCurrent;
                        EventPvGridChannelGet?.Invoke(dis, true);

                        break;

                    case "Ethernet":

                        DIEthernet die = (DIEthernet)chCurrent;
                        EventPvGridChannelGet?.Invoke(die, true);

                        break;
                    }
                }
                if (dvCurrent != null)
                {
                    EventPvGridDeviceGet?.Invoke(dvCurrent, true);
                }
                else
                {
                    EventPvGridDeviceGet?.Invoke(dvCurrent, false);
                }
                if (dbCurrent != null)
                {
                    EventPvGridDataBlockGet?.Invoke(dbCurrent, true);
                }
                else
                {
                    EventPvGridDataBlockGet?.Invoke(dbCurrent, false);

                    lblSelectedTagName.Text = string.Format("Selected tag: {0}", "None");
                }
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke(GetType().Name, ex.Message);
            }
        }