Example #1
0
        private void eISUCデータ吸い上げToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // 操作禁止
            operation_ban();
            button1.Enabled = true;

            richTextBox1.Clear();

            // 吸い上げモード、レンジ指定
            using (Form3 fm3 = new Form3())
            {
                this.AddOwnedForm(fm3);
                fm3.Show();

                while (fm3.IsDisposed == false)
                {
                    Application.DoEvents();
                    delay(100);
                }
            }

            cancel = 0;

            if (advance == true)
            {
                if (serialPortOpen() == false)
                {
                    richTextBox1.AppendText("ポートオープン失敗\r\n");
                    goto error_proc;
                }

                if (cancel != 0)
                {
                    richTextBox1.AppendText("中断\r\n");
                    goto error_proc;
                }

                // ブレーク信号送出
                sData[0] = 0x00;
                serialPort1.Write(sData, 0, 1);
                delay(50);

                // コマンド送出
                string[] command = { "EISUC:", "MODE=", "RANGE=" };

                command[1] += String.Format("{0,1:d1}", mode);
                command[2] += String.Format("{0,1:d1}", range);

                command_make(command);

                sendCommand();
                if (t_recvCommand() == false)
                {
                    richTextBox1.AppendText("受信異常\r\n");
                    goto error_proc;
                }

                extraction();   // パラメータ抽出

                string key = "SIZE=";
                int i = key_find(key);
                if (i > 0) i = System.Convert.ToInt32(Encoding.ASCII.GetString(rData, i + key.Length + 2, rData[i + key.Length] + (UInt16)rData[i + key.Length + 1]) + "\r\n");
                richTextBox1.AppendText(String.Format("転送バイト数 : {0:d}\r\n", i));

                for (int j = 1; j < i; j += 0)
                {
                    command[0] = "EISUC:";
                    command[1] = "MODE=9";
                    command[2] = "";

                    command_make(command);

                    sendCommand();
                    if (t_recvCommand() == false) goto error_proc;

                    extraction();   // パラメータ抽出

                    j += 1024;

                    delay(50);
                }
            }

            error_proc:;

            richTextBox1.AppendText("終了\r\n");
            serialPort1.Close();

            // 操作禁止解除
            operation_lift_ban();
        }
Example #2
0
        private void eWSUC子機のデータ吸い上げToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // 操作禁止
            operation_ban();
            button1.Enabled = true;

            richTextBox1.Clear();

            // 吸い上げモード、レンジ指定
            using (Form3 fm3 = new Form3())
            {
                this.AddOwnedForm(fm3);
                fm3.Show();

                while (fm3.IsDisposed == false)
                {
                    Application.DoEvents();
                    delay(100);
                }
            }

            cancel = 0;

            if (advance == true)
            {
                if (serialPortOpen() == false)
                {
                    richTextBox1.AppendText("ポートオープン失敗\r\n");
                    goto error_proc;
                }

                // ブレーク信号送出
                sData[0] = 0x00;
                serialPort1.Write(sData, 0, 1);
                delay(50);

                // コマンド送出
                string[] command = { "EWSUC:", "ACT=", "NUM=", "ID=", "CH=", "ROUTE=", "RELAY=", "MODE=", "RANGE=" };

                command[1] += "0";

                command[2] += String.Format("{0,1:d1}", Unique_Numb);                           // 子機番号
                for (int n = 0; n < 8; n++) command[3] += hex((Byte)(Unique_ID >> (n * 8)));    // グループID
                command[4] += String.Format("{0,1:d1}", Unique_Freq);                           // 周波数

                route = 1;

                command[5] += hex((Byte)(route));                   // ルート 0:自動 1:RELAYパラメータによる

                command[6] += hex((Byte)0x00);                      // ここは必ず0x00
                if (Relay0 > 0) command[6] += hex((Byte)Relay1);    // 1番目の中継機
                if (Relay0 > 1) command[6] += hex((Byte)Relay2);    // 2番目の中継機
                if (Relay0 > 2) command[6] += hex((Byte)Relay3);    // 3番目の中継機

                command[7] += String.Format("{0,1:d1}", mode);
                command[8] += String.Format("{0,1:d1}", range);

                command_make(command);

                sendCommand();
                if (t_recvCommand() == false)
                {
                    richTextBox1.AppendText("受信異常\r\n");
                    goto error_proc;
                }

                extraction();   // パラメータ抽出

                while (true)
                {
                    if (cancel != 0)
                    {
                        richTextBox1.AppendText("中断\r\n");
                        goto error_proc;
                    }

                    delay(1100);
                    Application.DoEvents();

                    string[] act1 = { "EWSUC:", "ACT=3"};

                    command_make(act1);

                    sendCommand();
                    t_recvCommand();

                    //extraction();   // パラメータ抽出

                    string key = "SIZE=";
                    int s = key_find(key);

                    key_find("TIME=");
                    key_find("LAST=");
                    int i = status_find();

                    string status = Encoding.ASCII.GetString(rData, i + 9, rData[i + 7] + (UInt16)rData[i + 8] * 256);
                    if (status.Substring(0, 4) == "0004" && status.Substring(5, 4) == "0000")
                    {
                        if (s > 0) s = System.Convert.ToInt32(Encoding.ASCII.GetString(rData, s + key.Length + 2, rData[s + key.Length] + (UInt16)rData[s + key.Length + 1]) + "\r\n");
                        if (s == 0) break;
                    }
                    else if (status.Substring(0, 4) != "0004" || status.Substring(5, 4) != "0001") break;
                }
            }

            error_proc: ;
            richTextBox1.AppendText("終了\r\n");
            serialPort1.Close();

            // 操作禁止解除
            operation_lift_ban();
        }