public FormInstructionCreator(SerialPort ser)
 {
     InitializeComponent();
     com    = new CommandFormerClass(startSeq, deviceAddr);
     serial = ser;
     //comboBoxSerialPorts.Items.AddRange(SerialPort.GetPortNames());
     //serial.ReadTimeout = 500; // 500ms
     //serial.WriteTimeout = 500; // 500ms
 }
예제 #2
0
        private void buttonGetGain_Click(object sender, EventArgs e)
        {
            try
            {
                uartReceiver.Reset();
                processFunction = ReceiveGain;

                CommandFormerClass cm = new CommandFormerClass(startSeq, deviceAddr);
                cm.GetGain();

                var data = cm.GetFinalCommandList();
                serial.Write(data, 0, data.Length);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void buttonResetInstructions_Click(object sender, EventArgs e)
 {
     com = new CommandFormerClass(startSeq, deviceAddr);
     textBoxInstructionPool.Text = "";
 }
예제 #4
0
        private void buttonRecordTask_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    // (uint8_t chMode, uint8_t operationMode, uint32_t prescaler, uint32_t targetPoints)
            //    int chMode = Convert.ToInt32(textBoxChMode.Text);
            //    int opMode = Convert.ToInt32(textBoxOpMode.Text);
            //    int prescaler = Convert.ToInt32(textBoxPrescaler.Text);
            //    int targetPoints = Convert.ToInt32(textBoxTargetPoints.Text);
            //    // Check here for invalid values

            //    // Send command to erase measurement header
            //    List<byte> sb = new List<byte>();

            //    sb.Add(startSeq);
            //    sb.Add(deviceAddr);
            //    // Append message length, and include checksum
            //    sb.Add(0);
            //    sb.Add(13);
            //    sb.Add(commandStartRecorder); //1
            //    // Convert values to separate bytes
            //    byte bChMode = CustomConvertorClass.ConvertIntTo1Byte(chMode); // 2
            //    byte bOpMode = CustomConvertorClass.ConvertIntTo1Byte(opMode); // 3
            //    byte[] bPrescaler = CustomConvertorClass.ConvertIntTo4Bytes(prescaler); //  7
            //    byte[] bTargetPoints = CustomConvertorClass.ConvertIntTo4Bytes(targetPoints); // 11

            //    sb.Add(bChMode);
            //    sb.Add(bOpMode);
            //    sb.AddRange(bPrescaler);
            //    sb.AddRange(bTargetPoints);

            //    // Now calculate and append checksum
            //    UInt16 csum = ChecksumClass.CalculateChecksum(sb.ToArray());
            //    byte[] bcsum = CustomConvertorClass.ConvertIntTo2BytesBE(csum);
            //    sb.AddRange(bcsum); // 2B

            //    serialPort1.Write(sb.ToArray(), 0, sb.Count);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}

            // First parse values from dropdown list



            try
            {
                int chMode       = InputValidatorHelperClass.GetChModeFromComboBox(comboBoxChannelSel);
                int opMode       = InputValidatorHelperClass.GetOperationModeFromComboBox(comboBoxOperationSel);
                int prescaler    = Convert.ToInt32(textBoxPrescaler.Text);
                int targetPoints = Convert.ToInt32(textBoxTargetPoints.Text);

                CommandFormerClass cm = new CommandFormerClass(startSeq, deviceAddr);
                cm.AppendDataRecorderTask((byte)chMode, (byte)opMode, (uint)prescaler, (uint)targetPoints, DateTime.Now);

                var data = cm.GetFinalCommandList();
                serial.Write(data, 0, data.Length);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }