コード例 #1
0
        private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            if (!serialPort.IsOpen)
            {
                return;
            }

            try{
                string receivedData = serialPort.ReadExisting();
                switch (_connectionState)
                {
                case Connection.STATE_NONE:
                    if (receivedData.Equals("**B0100000023be50\r\n"))
                    {
                        SetStatusToBar("Sending metadata...");
                        _connection.SendFileData();
                        _connectionState = Connection.STATE_CONNECTING_FILEDATA;
                    }
                    break;

                case Connection.STATE_CONNECTING_FILEDATA:
                    SetStatusToBar("Sending file contents...");
                    _connection.SendFileContent();
                    _connectionState = Connection.STATE_CONNECTING_FILECONTENT;
                    Thread.Sleep(2000);
                    break;

                case Connection.STATE_CONNECTING_FILECONTENT:
                    SetStatusToBar("Sending footer...");
                    _connection.SendFin();
                    _connectionState = Connection.STATE_CONNECTING_FIN;
                    break;

                case Connection.STATE_CONNECTING_FIN:
                    SetStatusToBar("Receiving...");
                    BeginInvoke(
                        new Delegate_AddTabOnOutSideTabControl(outsideTabControl.AddTabPage),
                        new Object[] { _connection.ConnectingSection, _mode, true });
                    BeginInvoke(
                        new Delegate_ShowSendControl(this.ShowSendControl),
                        new Object[] { });
                    _connectionState = Connection.STATE_CONNECTED;
                    break;

                case Connection.STATE_CONNECTED:
                    OutsideTabPage tabpage = (OutsideTabPage)outsideTabControl.TabPages[outsideTabControl.ReceivedIndex];
                    if (_connection.IsReceive)
                    {
                        BeginInvoke(
                            new Delegate_RecievedData(tabpage.RecordData),
                            new Object[] { receivedData });
                    }
                    break;
                }
            }catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void SaveActiveSection(int index)
        {
            if (index < 0 || outsideTabControl.TabPages.Count - 1 < index)
            {
                return;
            }
            OutsideTabPage tabpage = (OutsideTabPage)outsideTabControl.TabPages[index];

            if (tabpage != null)
            {
                SetStatusToBar("Saving log data...");
                Model.IO.FileStream fs = new Model.IO.FileStream(tabpage.Section);
                fs.SaveFiles();
                SetStatusToBar("[Finish] Save");
            }
        }
コード例 #3
0
        private void CreateOutTabPageOnReading(string[] fileNames)
        {
            SetStatusToBar("Reading log data...");
            ProgressDialog dialog = new ProgressDialog("ファイルを読込中...");

            dialog.Maximum = fileNames.Length;
            dialog.Show(this);

            foreach (string fileName in fileNames)
            {
                if (outsideTabControl.isOpen(fileName))
                {
                    outsideTabControl.SelectedIndex = outsideTabControl.GetIndexForFileName(fileName);
                    continue;
                }

                Section             section        = Section.CreateReadSection(fileName);
                Model.IO.FileStream readFileStream = new Model.IO.FileStream(section);
                string[]            readedData     = readFileStream.AccessFile();
                if (readedData == null)
                {
                    continue;
                }

                outsideTabControl.AddTabPage(section, _mode, isReceived: false);
                OutsideTabPage tabpage = (OutsideTabPage)outsideTabControl.TabPages[outsideTabControl.SelectedIndex];

                List <string> LogData = new List <string>();
                for (int readIndex = 0; readIndex < readedData.Length - 1; ++readIndex)
                {
                    LogData.Add(readedData[readIndex]);
                }
                tabpage.RecordRowData(LogData.ToArray());
                tabpage.RecordMemo(readedData[readedData.Length - 1]);

                ++dialog.Value;
            }

            SetStatusToBar("[Finish] Read");
            dialog.Close();
        }