Ejemplo n.º 1
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices != null && listView1.SelectedIndices.Count > 0)
            {
                ListView.SelectedIndexCollection c = listView1.SelectedIndices;
                //textBoxId.Text = listView1.Items[c[0]].SubItems[3].Text;
                //textBoxPort.Text = listView1.Items[c[0]].SubItems[4].Text;

                chart1.Titles[0].Text = listView1.Items[c[0]].SubItems[0].Text;
                //chart1.Titles.Add(listView1.Items[c[0]].SubItems[0].Text);

                string key = listView1.Items[c[0]].SubItems[2].Text;

                if (deviceList.ContainsKey(key))
                {
                    //textBoxLog.AppendText("deviceList contains key:" + key + "\r\n");
                    if (vact == null)
                    {
                        vact = deviceList[key];
                        vact.SetUpdateChart(true);
                        //textBoxLog.AppendText("vact is null\r\n");
                    }
                    else
                    {
                        vact.SetUpdateChart(false);
                        vact = deviceList[key];
                        vact.SetUpdateChart(true);
                        //textBoxLog.AppendText("vact is not null\r\n");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void LoadDevices()
        {
            this.deviceList.Clear();
            using (SQLiteConnection connection = new SQLiteConnection(database))
            {
                connection.Open();
                //string deviceType = "ACT12816";
                string        strainStatement = "select RemoteIP,LocalPort,DeviceId,Type,Desc,Path from SensorInfo";
                SQLiteCommand command2        = new SQLiteCommand(strainStatement, connection);
                using (SQLiteDataReader reader = command2.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string remoteIP    = reader.GetString(0);
                        int    localPort   = reader.GetInt32(1);
                        string deviceId    = reader.GetString(2);
                        string type        = reader.GetString(3);
                        string description = reader.GetString(4);
                        string path        = reader.GetString(5);

                        //int index = this.dataGridView1.Rows.Add();

                        string[]     itemString = { description, type, deviceId, remoteIP, localPort.ToString(), path };
                        ListViewItem item       = new ListViewItem(itemString);

                        listView1.Items.Add(item);

                        //config = new SerialACT4238Config(portName, baudrate, timeout, deviceId, type);

                        VibrationACT12x device = null;

                        device = new VibrationACT12x(deviceId, remoteIP, localPort, chart1, type, path, this.database, textBoxLog);

                        if (device != null)
                        {
                            this.deviceList.Add(deviceId, device);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

            deviceList = new Dictionary <string, VibrationACT12x>();

            for (int x = 0; x < checkedListBoxChannel.Items.Count; x++)
            {
                this.checkedListBoxChannel.SetItemChecked(x, false);
            }

            dataQueue = new ConcurrentQueue <float[]>();
            uiQueue   = new ConcurrentQueue <float[]>();
            backgroundWorkerProcessData = new BackgroundWorker();
            backgroundWorkerReceiveData = new BackgroundWorker();
            backgroundWorkerUpdateUI    = new BackgroundWorker();
            signalBuffer = new float[WindowSize];
            backgroundWorkerProcessData.WorkerSupportsCancellation = true;
            backgroundWorkerProcessData.DoWork += BackgroundWorkerProcessData_DoWork;

            backgroundWorkerUpdateUI.WorkerSupportsCancellation = true;
            backgroundWorkerUpdateUI.DoWork += BackgroundWorkerUpdateUI_DoWork;

            backgroundWorkerReceiveData.WorkerSupportsCancellation = true;
            backgroundWorkerReceiveData.DoWork += BackgroundWorkerReceiveData_DoWork;

            window = RaisedCosineWindow.Hann(WindowSize);

            LoadDevices();

            vact = null;

            //Set series chart type
            //chart1.Series["Series1"].ChartType = SeriesChartType.Line;
            //chart2.Series["Series1"].ChartType = SeriesChartType.Line;
            //chart1.Series["Series1"].IsValueShownAsLabel = true;
        }