コード例 #1
0
        /// <summary>
        /// 显示数字
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bu_int_Click(object sender, EventArgs e)
        {
            TagClear();
            iNodeAddr                 = short.Parse(cb_ip.Text);
            iNumData                  = Convert.ToInt32(this.Cb_int.Text);
            this.Cb_int.ForeColor     = Color.Red;
            this.radioButton1.Checked = true;
            //this.Cb_int.Enabled = false;
            if (this.Cb_int.Text == string.Empty || this.Cb_int.Text == "")
            {
                MessageBox.Show("请选择数字!");
                return;
            }

            for (int i = 0; i < GWCount; i++)
            {
                if (iNodeAddr != 0)
                {
                    Dapapi.AB_LB_DspNum(GWID[i], iNodeAddr, iNumData, iDigitPoint, iLEDInterval);
                    Bigling(GWID[i], i);
                }
                else
                {
                    Dapapi.AB_LB_DspNum(GWID[i], -252, iNumData, iDigitPoint, iLEDInterval);
                    Dapapi.AB_LB_DspNum(GWID[i], 252, iNumData, iDigitPoint, iLEDInterval);
                }
            }
        }
コード例 #2
0
        //发送指令
        private void button1_Click(object sender, EventArgs e)
        {
            Dapapi.AB_API_Open();
            string ip = this.cb_ip.Text;

            string  [] list = ip.Split('-');
            //int[] a =Convert.ToInt32( list[0]);
            try
            {
                int a = Dapapi.AB_LB_DspNum(Convert.ToInt32(list[0]), Convert.ToInt32(list[1]), Convert.ToInt32(list[2]), 0, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #3
0
 /// <summary>
 /// 排灯
 /// </summary>
 /// <param name="iNodeAddr"></param>
 /// <param name="i"></param>
 public void Bigling(int iNodeAddr, int i)
 {
     if (iNodeAddr > 90)
     {
         Dapapi.AB_LB_DspNum(GWID[i], 120, iNumData, iDigitPoint, iLEDInterval);
     }
     else if (iNodeAddr > 60)
     {
         Dapapi.AB_LB_DspNum(GWID[i], 90, iNumData, iDigitPoint, iLEDInterval);
     }
     else if (iNodeAddr > 30)
     {
         Dapapi.AB_LB_DspNum(GWID[i], 60, iNumData, iDigitPoint, iLEDInterval);
     }
     else if (iNodeAddr > 0)
     {
         Dapapi.AB_LB_DspNum(GWID[i], 30, iNumData, iDigitPoint, iLEDInterval);
     }
 }
コード例 #4
0
        /// <summary>
        /// 熄灭所有标签
        /// </summary>
        private void TagClear()
        {
            for (int i = 0; i < GWCount; i++)
            {
                if (Dapapi.AB_GW_Status(GWID[i]) == 7)
                {
                    Dapapi.AB_LB_DspNum(GWID[i], -252, 0, 0, -3);
                    Dapapi.AB_LB_DspNum(GWID[i], 252, 0, 0, -3);
                    Dapapi.AB_LED_Dsp(GWID[i], -252, 0, 0);
                    Dapapi.AB_LED_Dsp(GWID[i], 252, 0, 0);
                    Dapapi.AB_BUZ_On(GWID[i], -252, 0);
                    Dapapi.AB_BUZ_On(GWID[i], 252, 0);
                    Dapapi.AB_LB_DspStr(GWID[i], -252, "", 0, -3);
                    Dapapi.AB_LB_DspStr(GWID[i], 252, "", 0, -3);

                    //12-digits Alphanumerical display
                    Dapapi.AB_AHA_ClrDsp(GWID[i], -252);
                    Dapapi.AB_AHA_ClrDsp(GWID[i], 252);
                    Dapapi.AB_AHA_BUZ_On(GWID[i], -252, 0);
                    Dapapi.AB_AHA_BUZ_On(GWID[i], 252, 0);
                }
            }
        }
コード例 #5
0
        private void bn_sendmessage_Click(object sender, EventArgs e)
        {
            TagClear();
            Dap_Close();


            MessageQueue mqQue = null;

            if (MessageQueue.Exists(sMessageConnectionString))
            {
                mqQue = new System.Messaging.MessageQueue(sMessageConnectionString);
            }
            if (mqQue == null)
            {
                MessageBox.Show("消息队列获取失败!");
                return;
            }
            //得到所有消息
            System.Messaging.Message[] messages = mqQue.GetAllMessages();
            if (messages.Length > 0)
            {
                foreach (System.Messaging.Message msgVal in messages)
                {
                    //根据ID得到消息(这个ID放在消息的label中)
                    if (msgVal.Label == tb_JID.Text)
                    {
                        //同步接收,直到得到一条消息为止,如果消息队列为空,会一直阻塞
                        System.Messaging.Message msg = mqQue.Receive();
                        msg.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(string) });
                        //消息的内容
                        tb_receive.Text = msg.Body.ToString();
                        string   tagID = msg.Body.ToString();
                        string[] ip    = tagID.Split('-');
                        string   a     = ip[0];
                        string   IPstr = "";
                        IPstr = GetIP(a);
                        string name = "";

                        //switch (a)
                        //{
                        //    case "1":
                        //        IPstr = "1 4660 10.0.50.111";
                        //        break;
                        //    case "2":
                        //        IPstr = "1 4660 10.0.50.112";
                        //        //name = "IPTWOINDEX";
                        //        break;
                        //    case "3":
                        //        IPstr = "1 4660 10.0.50.113";
                        //        //name = "IPTHREEINDEX";
                        //        break;
                        //    case "4":
                        //        IPstr = "1 4660 10.0.50.114";
                        //        //name = "IPFOURINDEX";
                        //        break;
                        //    default:
                        //        MessageBox.Show("控制器不存在!");
                        //        return;
                        //}
                        //Writejson(IPstr);
                        //name = "IPindex.json";
                        name = "IPindex.xml";
                        Dap_Open(name, IPstr);
                        GetGWStatus();
                        //string b = ip[1];
                        iNodeAddr = short.Parse(ip[1]);
                        iNumData  = Convert.ToInt32(ip[2]);
                        try
                        {
                            for (int i = 0; i < GWCount; i++)
                            {
                                if (iNodeAddr != 0)
                                {
                                    Dapapi.AB_LB_DspNum(GWID[i], iNodeAddr, iNumData, iDigitPoint, iLEDInterval);
                                    Bigling(iNodeAddr, i);
                                }
                                else
                                {
                                    Dapapi.AB_LB_DspNum(GWID[i], -252, iNumData, iDigitPoint, iLEDInterval);
                                    Dapapi.AB_LB_DspNum(GWID[i], 252, iNumData, iDigitPoint, iLEDInterval);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                        break;
                    }
                    else
                    {
                        tb_receive.Text = "没有找到指定ID的Message";
                    }
                }
            }
            else
            {
                tb_receive.Text = "没有读取到数据!";
            }
        }