Esempio n. 1
0
 /*********************************************公开方法*********************************************/
 //窗口初始化
 public AI8C(CT2.CIoNode DataList)
 {
     InitializeComponent();
     //数据绑定
     CH1ValText.SetBinding(Label.ContentProperty, new Binding("CH1Val")
     {
         Source = modelView
     });
     CH2ValText.SetBinding(Label.ContentProperty, new Binding("CH2Val")
     {
         Source = modelView
     });
     CH3ValText.SetBinding(Label.ContentProperty, new Binding("CH3Val")
     {
         Source = modelView
     });
     CH4ValText.SetBinding(Label.ContentProperty, new Binding("CH4Val")
     {
         Source = modelView
     });
     CH5ValText.SetBinding(Label.ContentProperty, new Binding("CH5Val")
     {
         Source = modelView
     });
     CH6ValText.SetBinding(Label.ContentProperty, new Binding("CH6Val")
     {
         Source = modelView
     });
     CH7ValText.SetBinding(Label.ContentProperty, new Binding("CH7Val")
     {
         Source = modelView
     });
     CH8ValText.SetBinding(Label.ContentProperty, new Binding("CH8Val")
     {
         Source = modelView
     });
     NodeIDText.SetBinding(TextBlock.TextProperty, new Binding("NodeID")
     {
         Source = modelView
     });
     AI8CTypeText.SetBinding(TextBlock.TextProperty, new Binding("FilterType")
     {
         Source = modelView
     });
     //IO节点信息先刷新
     modelView.IsNodeOnline = DataList.m_isOnline;
     modelView.NodeID       = DataList.m_nodeID.ToString();
     modelView.FilterType   = DataList.AI8C_FilterType;
     if (modelView.IsNodeOnline)
     {
         this.Opacity   = 1;
         this.IsEnabled = true;
     }
     else
     {
         this.Opacity   = 0.4;
         this.IsEnabled = false;
     }
     //IO数据信息在IO模型初始化之后刷新,所以此处尚没有IO的数据信息,不能直接刷新该IO内各通道的值
 }
Esempio n. 2
0
        /***********************************************方法***********************************************/

        //窗口初始化
        public AI8(CT2.CIoNode ioData)
        {
            InitializeComponent();

            UpdateInner(ioData);
            NID.Text = IOData.m_nodeID.ToString();
        }
Esempio n. 3
0
 //输入数据刷新
 public void UpdateInputData(CT2.CIoNode DataList)
 {
     UpdateInner(DataList);
     //找到数据结构中当前界面的模块的DO数据集合,找到之后退出循环
     if (DataList.m_nodeID == IOData.m_nodeID)
     {
         List <string> list = new List <string>();
         foreach (var item in DataList.m_DataDO)
         {
             list.Add(item.ToString());
         }
         int i = 0;
         foreach (var item in valList)
         {
             item.Val = list[i];
             if (item.Val == "True")
             {
                 item.Name = "white";
             }
             else if (item.Val == "False")
             {
                 item.Name = "#676A6C";
             }
             i++;
         }
     }
 }
Esempio n. 4
0
        //输入数据刷新
        public void UpdateInputData(CT2.CIoNode DataList)
        {
            UpdateInner(DataList);
            int index = 0;

            //找到数据结构中当前界面的模块的DO数据集合,找到之后退出循环
            if (DataList.m_nodeID == IOData.m_nodeID)
            {
                UIData.HexValue = DataList.m_DataDOVal.ToString();
                //找到单个DO的数据集合的元素
                foreach (var data in DataList.m_DataDO)
                {
                    //循环次数判断
                    if (VisualTreeHelper.GetChildrenCount(CHGroup) == index)
                    {
                        return;
                    }
                    Button CH = (Button)VisualTreeHelper.GetChild(CHGroup, index);
                    //DO某个点上的数据
                    if (data == true)
                    {
                        CH.Template = this.FindResource("GreenButton") as ControlTemplate;
                    }
                    else
                    {
                        CH.Template = this.FindResource("RedButton") as ControlTemplate;
                    }
                    index++;
                }
            }
        }
Esempio n. 5
0
        private bool IsClickAll = false; //按钮 content 用
        /***********************************************方法***********************************************/
        //窗口初始化
        public DO15(CT2.CIoNode ioData)
        {
            InitializeComponent();

            UpdateInner(ioData);
            NID.Text = IOData.m_nodeID.ToString();
            HexValue.SetBinding(TextBlock.TextProperty, new Binding("HexValue")
            {
                Source = UIData
            });
        }
Esempio n. 6
0
 private void UpdateInner(CT2.CIoNode DataList)
 {
     IOData = DataList;
     if (IOData.m_isOnline)
     {
         this.Opacity   = 1;
         this.IsEnabled = true;
     }
     else
     {
         this.Opacity   = 0.4;
         this.IsEnabled = false;
     }
 }
Esempio n. 7
0
        /***********************************************方法***********************************************/
        //窗口初始化
        public DO8R(CT2.CIoNode ioData)
        {
            InitializeComponent();

            UpdateInner(ioData);
            NID.Text = IOData.m_nodeID.ToString();


            for (int i = 1; i < 9; i++)
            {
                Data t = new Data();
                t.Index = i.ToString();
                t.Val   = "False";
                t.Name  = "#676A6C";
                valList.Add(t);
            }
            CHGroup.ItemsSource = valList;
        }
Esempio n. 8
0
        public string WriteIoData(CT2.CIoNode node)
        {
            ushort len;

            if (node.CheckIfExistDO())
            {
                len = (ushort)((node.m_DO_AddrEnd + 1 - node.m_DO_AddrStart) * 8);
                if (len != node.m_DataDO.Count)
                {
                    return("ERR_illegalDataLength_DO");
                }
                try
                {
                    Thread.Sleep(5);
                    ushort addrStart = (ushort)(CT2.ECT2Coils.RegionDO + node.m_DO_AddrStart * 8);
                    master.WriteMultipleCoils(addrStart, node.m_DataDO.ToArray());
                }
                catch (Exception e)
                {
                    return(e.Message);
                }
            }
            if (node.CheckIfExistAO())
            {
                len = (ushort)((node.m_AO_AddrEnd + 1 - node.m_AO_AddrStart) / 2);
                if (len != node.m_DataAO.Count)
                {
                    return("ERR_illegalDataLength_DO");
                }
                try
                {
                    Thread.Sleep(5);
                    ushort addrStart = (ushort)(CT2.ECT2HoldReg.RegionAO + (node.m_AO_AddrStart - 200) / 2);
                    master.WriteMultipleRegisters(addrStart, node.m_DataAO.ToArray());
                }
                catch (Exception e)
                {
                    return(e.Message);
                }
            }
            return("NO_ERR");
        }
Esempio n. 9
0
        //输入数据刷新,注册过且在线
        public void UpdateInputData(CT2.CIoNode DataList)
        {
            UpdateInner(DataList);

            int index = 1;

            if (DataList.m_nodeID == IOData.m_nodeID)
            {
                //循环得到单个AO各通道的数据
                foreach (var data in DataList.DataAIStr)//1 3 5 7 9 11 13 15 17 19
                {
                    //循环次数判断
                    if (17 == index)
                    {
                        return;
                    }
                    Label CH = (Label)VisualTreeHelper.GetChild(CHGroup, index);
                    CH.Content = data;
                    index     += 2;
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 获取IO节点地址
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public string GetIoNode(ref List <CT2.CIoNode> list)
        {
            list.Clear();
            for (int i = 0; i < 19; i++)
            {
                //5个节点上传一次
                ushort[] inputs5;
                try
                {
                    ushort addrStart = (ushort)(CT2.ECT2InputReg.nodeInfo +
                                                i * 5 * CT2.CIoNode.NODE_INFO_LENGTH);
                    Thread.Sleep(5);
                    inputs5 = master.ReadInputRegisters(
                        addrStart, CT2.CIoNode.NODE_INFO_LENGTH * 5);
                }
                catch (Exception e)
                {
                    return(e.Message);
                }

                for (int j = 0; j < 5; j++)
                {
                    ushort[] inputs = new ushort[CT2.CIoNode.NODE_INFO_LENGTH];
                    for (int k = j * CT2.CIoNode.NODE_INFO_LENGTH;
                         k < (j + 1) * CT2.CIoNode.NODE_INFO_LENGTH;
                         k++)
                    {
                        inputs[k - j * CT2.CIoNode.NODE_INFO_LENGTH] = inputs5[k];
                    }
                    CT2.CIoNode cIoNode = new CT2.CIoNode(inputs, (ushort)(i * 5 + j + 1));
                    if (cIoNode.CheckIfExist() == true)
                    {
                        list.Add(cIoNode);
                    }
                }
            }
            return("NO_ERR");
        }
Esempio n. 11
0
        //输入数据刷新,在线时才刷新
        public void UpdateInputData(CT2.CIoNode DataList)
        {
            modelView.IsNodeOnline = DataList.m_isOnline;
            if (modelView.IsNodeOnline)
            {
                this.Opacity   = 1;
                this.IsEnabled = true;
            }
            else
            {
                this.Opacity   = 0.4;
                this.IsEnabled = false;
                //return;
            }

            modelView.CH1Val = DataList.m_DataAI8C[0].ToString("#0.000");
            modelView.CH2Val = DataList.m_DataAI8C[1].ToString("#0.000");
            modelView.CH3Val = DataList.m_DataAI8C[2].ToString("#0.000");
            modelView.CH4Val = DataList.m_DataAI8C[3].ToString("#0.000");
            modelView.CH5Val = DataList.m_DataAI8C[4].ToString("#0.000");
            modelView.CH6Val = DataList.m_DataAI8C[5].ToString("#0.000");
            modelView.CH7Val = DataList.m_DataAI8C[6].ToString("#0.000");
            modelView.CH8Val = DataList.m_DataAI8C[7].ToString("#0.000");
        }
Esempio n. 12
0
        //输入数据刷新,注册过且在线
        public void UpdateInputData(CT2.CIoNode DataList)
        {
            UpdateInner(DataList);

            int index = 1;

            if (DataList.m_nodeID == IOData.m_nodeID)
            {
                //循环得到单个AO各通道的数据
                foreach (var data in DataList.m_DataAO) //1 3 5 7
                {
                    if (9 == index)                     //循环次数判断
                    {
                        return;
                    }
                    TextBox CH = (TextBox)VisualTreeHelper.GetChild(CHGroup, index);
                    if (!CH.IsFocused)//不在编辑状态才刷新,判断依据:有无焦点
                    {
                        CH.Text = data.ToString();
                    }
                    index += 2;
                }
            }
        }