示例#1
0
        public Form1()
        {
            InitializeComponent();
            COMport                 = new CommunicationDriver();
            COMport.PortName        = "COM10";
            COMport.BaudRate        = 19200;// 2400;
            COMport.DataBits        = 8;
            COMport.Parity          = Parity.Even;
            COMport.StopBits        = StopBits.One;
            COMport.OnTimeOutEvent += DoReceivedTimeOut;
            COMport.OnReceived     += DoReceivedData;

            Common.GetPortList(lbPortList);

            dataGridView1.ColumnCount     = 4;
            dataGridView1.RowCount        = 1;
            dataGridView1.Columns[0].Name = "Nr";
            dataGridView1.Columns[1].Name = "Parametras";
            dataGridView1.Columns[2].Name = "Reikšmė";
            dataGridView1.Columns[3].Name = "Matavimo vienetai";

            comboBox1.SelectedIndex = 0;

            DatabaseClass.GetDeviceList(cbDeviceList);
            if (cbDeviceList.Items.Count > 0)
            {
                cbDeviceList.SelectedIndex = 0;
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (databaseClass != null)
            {
                DeviceRecord deviceRecord = new DeviceRecord();
                deviceRecord.DeviceID   = string.Format("{0}", rnd.Next(1, 5));
                deviceRecord.DeviceName = "Prietaiso pavadinimas";
                deviceRecord.Location   = "Kazkur";

                deviceRecord.AddValue(new DeviceValue(DateTime.Now, "DeviceTime", "", ""));
                deviceRecord.AddValue(new DeviceValue(rnd.NextDouble() * 1000.0, "Energy", "MWh", ""));
                deviceRecord.AddValue(new DeviceValue(rnd.NextDouble() * 100000.0, "Volume", "m3", ""));
                deviceRecord.AddValue(new DeviceValue(rnd.NextDouble() * 10.0, "Flow", "m3/h", ""));
                deviceRecord.AddValue(new DeviceValue(rnd.NextDouble() * 10.0, "Power", "kW", ""));
                deviceRecord.AddValue(new DeviceValue(rnd.NextDouble() * 100.0, "T1", "°C", ""));
                deviceRecord.AddValue(new DeviceValue(rnd.NextDouble() * 100.0, "T2", "°C", ""));
                deviceRecord.AddValue(new DeviceValue(rnd.NextDouble() * 100.0, "dT", "°C", ""));
                deviceRecord.AddValue(new DeviceValue(rnd.NextDouble() * 100.0, "OnTime", "h", ""));
                deviceRecord.AddValue(new DeviceValue("0000001001101111", "Error", "", ""));

                databaseClass.AddNewRecord(deviceRecord);

                DatabaseClass.GetDeviceList(cbDeviceList);
                if (cbDeviceList.Items.Count > 0)
                {
                    cbDeviceList.SelectedIndex = 0;
                }
            }
        }
示例#3
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (databaseClass != null)
     {
         databaseClass.CloseDatabase();
         databaseClass = null;
     }
 }
示例#4
0
        private void button3_Click(object sender, EventArgs e)
        {
            databaseClass.DeletedAllTables();

            DatabaseClass.GetDeviceList(cbDeviceList);
            if (cbDeviceList.Items.Count > 0)
            {
                cbDeviceList.SelectedIndex = 0;
            }
        }
示例#5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //byte[] Buff = new byte[260];
            //MODBUSdrv.PrepareREQ(ref Buff);

            if (databaseClass == null)
            {
                databaseClass = new DatabaseClass();
            }
        }
示例#6
0
 public DatabaseWindow(int SelectedIndex)
 {
     InitializeComponent();
     DatabaseClass.DeviceDataSelect(SelectedIndex, dgDeviceData);
 }