private void ThListCount()
        {
            string sendMessage = "F8FA00000004230031CA";

            byte[] sendMessageByte = new byte[sendMessage.Length / 2];
            for (int i = 0; i < sendMessage.Length; i += 2)
            {
                sendMessageByte[i / 2] = Convert.ToByte(sendMessage.Substring(i, 2), 16);
            }
            string reciveMessage = cb.Connection(sendMessageByte, labelIp.Text);

            reciveMessage = reciveMessage.Replace(" ", "");
            string count = reciveMessage.Substring(12, 4);

            try
            {
                this.Invoke((MethodInvoker) delegate
                {
                    labelListCount.Text  = "◆名單總數:";
                    labelListCount.Text += count + "筆";
                });
            }
            catch { }
            nunberCount = count;
        }
        private void ThSetting()
        {
            CommunicationBase cb = new CommunicationBase();

            byte[] relockSendMsg   = new byte[] { 0xF8, 0xFA, 0x00, 0x07, 0x00, 0x07, 0x52, 0x65, 0x61, 0x64, 0x02, 0x1B, 0x45 };
            string relockReciveMsg = cb.Connection(relockSendMsg, Gip);

            if (relockReciveMsg != "")
            {
                relockReciveMsg = relockReciveMsg.Replace(" ", "");
                int          relockData = Convert.ToInt32(relockReciveMsg.Substring(12, 4), 16);
                StreamWriter sw         = new StreamWriter(ipSettingPath, true);
                sw.WriteLine(GmN);
                sw.WriteLine(Gip);
                sw.WriteLine(GgateWay);
                sw.WriteLine(Gmask);
                sw.WriteLine(Gmac);
                sw.Dispose();
                string[] ipArray = Gip.Split('.');
                ipSettingPath = Application.StartupPath + "\\DeviceInfo_Setting\\" + ipArray[0].PadLeft(3, '0') + "." + ipArray[1].PadLeft(3, '0') + "." + ipArray[2].PadLeft(3, '0') + "." + ipArray[3].PadLeft(3, '0') + ".ini";
                StreamWriter sw1 = new StreamWriter(ipSettingPath);
                sw1.WriteLine(relockData);
                sw1.Dispose();
            }
        }
        private void StartConnection()
        {
            Byte[] sendStopMsgByte = new Byte[] { 0xFA };

            //獲取 EPC/TID 號碼
            Byte[]            sandStartMsgByte = new Byte[] { 0xFA, 0xF8, 0x00, 0x05, 0x00, 0x06, 0xFF, 0x1D, 0x01, 0x01, 0xAE, 0x78 };
            CommunicationBase cb            = new CommunicationBase();
            string            reciveStopMsg = cb.Connection(sendStopMsgByte, labelP.Text);

            Thread.Sleep(50);
            string reciveStartMsg = cb.Connection(sandStartMsgByte, labelP.Text);

            this.Invoke((MethodInvoker) delegate
            {
                buttonConnect.Text      = "已開啟";
                buttonConnect.ForeColor = Color.Green;
            });
        }
Exemplo n.º 4
0
        private void ReadUserInfo(object Oip_mN)
        {
            string ip_mN = (string)Oip_mN;

            string[] ip_mNArray = ip_mN.Split('@');

            //取得Reader同卡間隔內不重複的Tag資料
            Byte[] _SensorData = new Byte[] { 0xF8, 0xFA, 0x00, 0x00, 0x00, 0x02, 0xCB, 0x54 };
            while (isRead)
            {
                string openDoor   = "";
                string reciveText = cb.Connection(_SensorData, ip_mNArray[0]);
                string cardN      = cb.GetCardNumber(reciveText);
                if (!cardN.Equals(""))
                {
                    while (isEnterValid)
                    {
                        Thread.Sleep(500);
                        // Do nothing.
                    }
                    isEnterValid = true;
                    string    sueecssString = Valid(cardN, ip_mNArray[0]);
                    DataTable dtMen         = new DataTable();
                    string[]  conditinInfo  = new string[] { "Card_number=" + cardN };
                    dtMen = sql.Query_Condition("Menbers_Table", conditinInfo, 0);
                    if (!sueecssString.Equals(""))
                    {
                        if (reciveText.Length > 3)
                        {
                            WriteLog("◆卡號:" + cardN + "      ◆時間:" + cb.GetTime(reciveText) + "      ◆車牌:" + dtMen.Rows[0][2].ToString() + "      ◆車主:" + dtMen.Rows[0][3].ToString() + "      ◆機碼:" + ip_mNArray[1] + "      ◆門禁狀態:" + sueecssString);
                        }
                    }
                    isEnterValid = false;
                }
            }
        }
        private void ReadUserInfo(object Oip_mN)
        {
            string ip_mN = (string)Oip_mN;

            string[] ip_mNArray = ip_mN.Split('@');
            //取得Reader同卡間隔內不重複的Tag資料
            Byte[] _SensorData = new Byte[] { 0xF8, 0xFA, 0x00, 0x00, 0x00, 0x02, 0xCB, 0x54 };

            while (toRead)
            {
                CommunicationBase cb         = new CommunicationBase();
                string            reciveText = cb.Connection(_SensorData, ip_mNArray[0]);
                if (reciveText.Length > 3)
                {
                    WriteLog("◆卡號:" + cb.GetCardNumber(reciveText) + "      ◆時間:" + cb.GetTime(reciveText) + "      ◆機碼:" + ip_mNArray[1]);
                }
            }
        }
Exemplo n.º 6
0
        private void Modify()
        {
            CollectionSettingInfo();
            ip = labelIP.Text.Split(':')[1];
            string[] ippArray = ip.Split('.');
            for (int i = 0; i < ippArray.Length; i++)
            {
                if (i == ippArray.Length - 1)
                {
                    ipp += ippArray[i].PadLeft(3, '0');
                }
                else
                {
                    ipp += ippArray[i].PadLeft(3, '0') + ".";
                }
            }
            settingPath += "\\" + ipp + "Location.ini";

            if (File.Exists(settingPath))
            {
                string backString = tool.ReadIPandLocation(ipp);
                File.Delete(settingPath);
                string   modifyIP = mN_Ip_Mask_Gateway.Split('|')[1];
                string[] mArray   = modifyIP.Split('.');
                ipp = "";
                for (int i = 0; i < mArray.Length; i++)
                {
                    if (i == mArray.Length - 1)
                    {
                        ipp += mArray[i].PadLeft(3, '0');
                    }
                    else
                    {
                        ipp += mArray[i].PadLeft(3, '0') + ".";
                    }
                }
                tool.WriteIPandLocation(ipp, backString.Split('_')[1]);
            }
            // Stop RF.
            Byte[] sandStopMsgByte    = new Byte[] { 0xFA };
            string reciveMsgForStopRF = cb.Connection(sandStopMsgByte, labelIP.Text.Split(':')[1]);

            // Search ip.
            //StreamReader sr = new StreamReader(ipSettingPath);
            //ip = sr.ReadLine();
            //ip = sr.ReadLine();
            //sr.Dispose();
            Thread.Sleep(300);
            //---------//
            // Set machine number.
            Byte[] mNModifySendMessage = mN_ToHex(textBoxmN.Text);
            string mNReciveMessage     = cb.Connection(mNModifySendMessage, ip);

            mNReciveMessage = mNReciveMessage.Replace(" ", "");
            string mNStatus    = mNReciveMessage.Substring(12, 2);
            string mwssageText = "";

            Thread.Sleep(300);
            // Set ip,mask,gateway
            Byte[] ipModifySendMessage = IP_Mask_Gateway_ToHex();
            string ipReciveMessage     = cb.Connection(ipModifySendMessage, ip);

            ipReciveMessage = ipReciveMessage.Replace(" ", "");
            string ipStatus = ipReciveMessage.Substring(12, 2);

            if (ipStatus.Equals("01") && mNStatus.Equals("01"))
            {
                mwssageText = "修改成功";
            }
            else
            {
                mwssageText += "(IP、遮罩、閘道)修改失敗";
            }
            MessageBox.Show(mwssageText, "提醒");
            this.Invoke((MethodInvoker) delegate
            {
                this.Cursor       = Cursors.Arrow;
                panelDown.Enabled = true;
                buttonModify.Text = "修改";
                this.ParentForm.Dispose();
            });
            settingPath += "\\" + ip + "Location.ini";
        }
        private void ThSetting()
        {
            // Read Record Time.
            byte[] recordTimeSendMsg   = new byte[] { 0xF8, 0xFA, 0x00, 0x07, 0x00, 0x07, 0x52, 0x65, 0x61, 0x64, 0x01, 0x2B, 0x26 };
            string recordTimeReciveMsg = cb.Connection(recordTimeSendMsg, ip);

            recordTimeReciveMsg = recordTimeReciveMsg.Replace(" ", "");
            int recordTimeData   = Convert.ToInt32(recordTimeReciveMsg.Substring(12, 2), 16);
            int recordTimeStatus = Convert.ToInt32(recordTimeReciveMsg.Substring(14, 2), 16);

            // Read Timeout Time
            byte[] timeoutSendMsg   = new byte[] { 0xF8, 0xFA, 0x00, 0x07, 0x00, 0x07, 0x52, 0x65, 0x61, 0x64, 0x07, 0x4B, 0xE0 };
            string timeoutReciveMsg = cb.Connection(timeoutSendMsg, ip);

            timeoutReciveMsg = timeoutReciveMsg.Replace(" ", "");
            int timeoutData  = Convert.ToInt32(timeoutReciveMsg.Substring(12, 4), 16);
            int timeouStatus = Convert.ToInt32(timeoutReciveMsg.Substring(16, 2), 16);

            // Read Relock Time
            byte[] relockSendMsg   = new byte[] { 0xF8, 0xFA, 0x00, 0x07, 0x00, 0x07, 0x52, 0x65, 0x61, 0x64, 0x02, 0x1B, 0x45 };
            string relockReciveMsg = cb.Connection(relockSendMsg, ip);

            relockReciveMsg = relockReciveMsg.Replace(" ", "");
            int relockData   = Convert.ToInt32(relockReciveMsg.Substring(12, 4), 16);
            int relockStatus = Convert.ToInt32(relockReciveMsg.Substring(16, 2), 16);

            // Read En Buzzer
            byte[] buzzerSendMsg   = new byte[] { 0xF8, 0xFA, 0x00, 0x07, 0x00, 0x07, 0x52, 0x65, 0x61, 0x64, 0x04, 0x7B, 0x83 };
            string buzzerReciveMsg = cb.Connection(buzzerSendMsg, ip);

            buzzerReciveMsg = buzzerReciveMsg.Replace(" ", "");
            int buzzerData   = Convert.ToInt32(buzzerReciveMsg.Substring(12, 2), 16);
            int buzzerStatus = Convert.ToInt32(buzzerReciveMsg.Substring(14, 2), 16);

            // Read DO Mode
            byte[] doSendMsg   = new byte[] { 0xF8, 0xFA, 0x00, 0x07, 0x00, 0x07, 0x52, 0x65, 0x61, 0x64, 0x06, 0x5B, 0xC1 };
            string doReciveMsg = cb.Connection(doSendMsg, ip);

            doReciveMsg = doReciveMsg.Replace(" ", "");
            string doData   = doReciveMsg.Substring(12, 8);
            int    doStatus = Convert.ToInt32(doReciveMsg.Substring(20, 2), 16);
            string DOActive = "";

            //if (doData.Equals("01010101"))
            //{
            //    DOActive = "開門";
            //}
            //else if (doData.Equals("03010101"))
            //{
            //    DOActive = "逾時";
            //}

            // Show
            try
            {
                this.Invoke((MethodInvoker) delegate
                {
                    if (recordTimeStatus == 1)
                    {
                        comboBoxSameCardIRecord.Text = recordTimeData.ToString();
                        recordTime = recordTimeData.ToString();
                    }
                    if (timeouStatus == 1)
                    {
                        textBoxITimeout.Text = timeoutData.ToString();
                        timeout = timeoutData.ToString();
                    }
                    if (relockStatus == 1)
                    {
                        textBoxDoorTime.Text = relockData.ToString();
                        relock = relockData.ToString();
                    }
                    if (buzzerStatus == 1)
                    {
                        if (buzzerData == 1)
                        {
                            checkBoxBuzzer.Checked = true;
                            buzzer = checkBoxBuzzer.Checked;
                        }
                        else
                        {
                            checkBoxBuzzer.Checked = false;
                            buzzer = checkBoxBuzzer.Checked;
                        }
                    }
                    if (doStatus == 1)
                    {
                        comboBoxDO.Text = DOActive;
                        GDOActive       = DOActive;
                    }
                    panelContainer.Enabled = true;
                    labelLoading.Text      = "就緒";
                    labelLoading.ForeColor = Color.Black;
                });
            }
            catch { }
        }