コード例 #1
0
        private void btnSetValues_Click(object sender, EventArgs e)
        {
            IDevice ConnectionHandle = GetDeviceConnection();

            if (ConnectionHandle == null)
            {
                MessageBox.Show("Error: Cannot connect to DataLogger device.");
                return;
            }

            Device_Report_t DeviceReport = new Device_Report_t();

            DeviceReport.Day              = (byte)dtpDate.Value.Day;
            DeviceReport.Month            = (byte)dtpDate.Value.Month;
            DeviceReport.Year             = (byte)((dtpDate.Value.Year < 2000) ? 0 : (dtpDate.Value.Year - 2000));
            DeviceReport.Hour             = (byte)dtpTime.Value.Hour;
            DeviceReport.Minute           = (byte)dtpTime.Value.Minute;
            DeviceReport.Second           = (byte)dtpTime.Value.Second;
            DeviceReport.LogInterval500MS = (byte)(nudLogInterval.Value * 2);

            try
            {
                ConnectionHandle.Write(0x00, DeviceReport.ToReport());
                MessageBox.Show("Device parameters updated sucessfully.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
コード例 #2
0
        private void btnGetValues_Click(object sender, EventArgs e)
        {
            IDevice ConnectionHandle = GetDeviceConnection();

            if (ConnectionHandle == null)
            {
                MessageBox.Show("Error: Cannot connect to DataLogger device.");
                return;
            }

            Device_Report_t DeviceReport = new Device_Report_t();

            try
            {
                Byte[] Report = new Byte[7];

                ConnectionHandle.Read(0x00, Report);
                DeviceReport.FromReport(Report);

                try
                {
                    dtpDate.Value = new DateTime(
                        (2000 + DeviceReport.Year),
                        DeviceReport.Month,
                        DeviceReport.Day);

                    dtpTime.Value = new DateTime(
                        DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                        DeviceReport.Hour,
                        DeviceReport.Minute,
                        DeviceReport.Second);
                }
                catch (Exception ex)
                {
                    dtpDate.Value = DateTime.Now;
                    dtpTime.Value = DateTime.Now;
                }

                try
                {
                    nudLogInterval.Value = (DeviceReport.LogInterval500MS / 2);
                }
                catch (Exception ex)
                {
                    nudLogInterval.Value = nudLogInterval.Minimum;
                }

                MessageBox.Show("Device parameters retrieved sucessfully.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
コード例 #3
0
        private void btnGetValues_Click(object sender, EventArgs e)
        {
            IDevice ConnectionHandle = GetDeviceConnection();

            if (ConnectionHandle == null)
            {
                MessageBox.Show("Error: Cannot connect to DataLogger device.");
                return;
            }

            Device_Report_t DeviceReport = new Device_Report_t();

            try
            {
                Byte[] Report = new Byte[7];

                ConnectionHandle.Read(0x00, Report);
                DeviceReport.FromReport(Report);

                try
                {
                    dtpDate.Value = new DateTime(
                        (2000 + DeviceReport.Year),
                        DeviceReport.Month,
                        DeviceReport.Day);

                    dtpTime.Value = new DateTime(
                        DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                        DeviceReport.Hour,
                        DeviceReport.Minute,
                        DeviceReport.Second);
                }
                catch (Exception ex)
                {
                    dtpDate.Value = DateTime.Now;
                    dtpTime.Value = DateTime.Now;
                }

                try
                {
                    nudLogInterval.Value = (DeviceReport.LogInterval500MS / 2);
                }
                catch (Exception ex)
                {
                    nudLogInterval.Value = nudLogInterval.Minimum;
                }

                MessageBox.Show("Device parameters retrieved successfully.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
コード例 #4
0
        private void btnSetValues_Click(object sender, EventArgs e)
        {
            IDevice ConnectionHandle = GetDeviceConnection();

            if (ConnectionHandle == null)
            {
                MessageBox.Show("Error: Cannot connect to Datalogger device.");
                return;
            }

            Device_Report_t DeviceReport = new Device_Report_t();
            DeviceReport.Day = (byte)dtpDate.Value.Day;
            DeviceReport.Month = (byte)dtpDate.Value.Month;
            DeviceReport.Year = (byte)((dtpDate.Value.Year < 2000) ? 0 : (dtpDate.Value.Year - 2000));
            DeviceReport.Hour = (byte)dtpTime.Value.Hour;
            DeviceReport.Minute = (byte)dtpTime.Value.Minute;
            DeviceReport.Second = (byte)dtpTime.Value.Second;
            DeviceReport.LogInterval500MS = (byte)(nudLogInterval.Value * 2);

            try
            {
                ConnectionHandle.Write(0x00, DeviceReport.ToReport());
                MessageBox.Show("Device parameters updated successfully.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }