Beispiel #1
0
 public Form1()
 {
     InitializeComponent();
     //4.use delegate function in form because Form1 will run one time
     //after Run Program
     myDelegate = new AddDataDelegate(AddData);
 }
        //Form Reset Methods - Called everytime the form is shown
        private void ResetData()
        {
            DataSample = new Classes.DynamicStrengthTestDS(GlobalVariables.leftSerialPort);
            ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;
            ThreadCallbackUpdateCycleCounter = DataSample.UpdateCycleCounter;
            ThreadCallbackCheckIfMaxTorque = DataSample.CheckIfMaxTorque;
            ThreadCallbackUpdateCharts = DataSample.UpdateCharts;

            SetupLeftLegGraph();
            SetupRightLegGraph();
            if (GlobalVariables.DynamicStrengthTestPB != null)
            {
                lblMCTL_PB.Text = Math.Round(GlobalVariables.DynamicStrengthTestPB.LeftMaxTorqueConc.Value, 1).ToString() + " - [" + GlobalVariables.DynamicStrengthTestPB.SpeedLeftMaxConc.ToString() + "]";
                lblMETL_PB.Text = Math.Round(GlobalVariables.DynamicStrengthTestPB.LeftMaxTorqueEcce.Value, 1).ToString() + " - [" + GlobalVariables.DynamicStrengthTestPB.SpeedLeftMaxEcce.ToString() + "]";
                lblMCTR_PB.Text = Math.Round(GlobalVariables.DynamicStrengthTestPB.RightMaxTorqueConc.Value, 1).ToString() + " - [" + GlobalVariables.DynamicStrengthTestPB.SpeedRightMaxConc.ToString() + "]";
                lblMETR_PB.Text = Math.Round(GlobalVariables.DynamicStrengthTestPB.RightMaxTorqueEcce.Value, 1).ToString() + " - [" + GlobalVariables.DynamicStrengthTestPB.SpeedRightMaxEcce.ToString() + "]";
            }

            lblMaxTorqueConcLeft.Text = "-";
            lblMaxTorqueConcRight.Text = "-";
            lblMaxTorqueEcceLeft.Text = "-";
            lblMaxTorqueEcceRight.Text = "-";

            DataSample.IsTestDataAvailible = false;

            EnableButtons(); //Just in case
        }
 //AssignCallbackMethods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorCalibration;
     ThreadCallbackUpdateProgressBar = new AddDataDelegate(UpdateProgressBar);
     ThreadCallbackPositioningComplete = new AddDataDelegate(PositionSequenceComplete);
     ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
 }
        //First Method called every time the form is displayed
        public void InitiateProgram(int SelectedSpeed, int SelectedTorque, TimeSpan SelectedDuration, Enumerators.Direction SelectedDirection)
        {
            logger.Info("Initiating Custom Program.");

            dataSampleLeft = new EcceScrumDS(GlobalVariables.leftSerialPort);
            dataSampleRight = new EcceScrumDS(GlobalVariables.rightSerialPort);

            dataSampleLeft.ProgramSelector = Enumerators.ProgramSelect.CustomProgram;
            dataSampleLeft.SelectedSpeed = SelectedSpeed;
            dataSampleLeft.SelectedTorque = SelectedTorque;
            dataSampleLeft.SelectedDuration = SelectedDuration;
            dataSampleLeft.TimeRemaining = SelectedDuration;
            dataSampleLeft.SelectedDirection = SelectedDirection;
            dataSampleLeft.SampleTimerInterval = 100;
            dataSampleLeft.CapturePowerFlag = true;
            ThreadCallbackProcessFeedbackErrorLeft = dataSampleLeft.ProcessErrorSession;

            dataSampleRight.ProgramSelector = Enumerators.ProgramSelect.CustomProgram;
            dataSampleRight.SelectedSpeed = SelectedSpeed;
            dataSampleRight.SelectedTorque = SelectedTorque;
            dataSampleRight.SelectedDuration = SelectedDuration;
            dataSampleRight.TimeRemaining = SelectedDuration;
            dataSampleRight.SelectedDirection = SelectedDirection;
            dataSampleRight.SampleTimerInterval = 100;
            dataSampleRight.CapturePowerFlag = true;
            ThreadCallbackProcessFeedbackErrorRight = dataSampleRight.ProcessErrorSession;

            ResetData();

            isNewSession = true;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.WindowState = FormWindowState.Normal;
            this.Focus();
        }
Beispiel #5
0
        public chartOperation()
        {
            // set the multi thread on/off
            multi_thread = true;

            addElementsCnt    = 0;
            addChartCnt       = 0;
            current_chart_ind = 0;
            current_area_ind  = 0;

            mouse_select_chart = 0;

            chart_update_interval = 1000;  // unit: ms
            add_num_amount        = 10;

            if (!multi_thread)
            {
                // create the Adding Data Thread but do not start until start button clicked
                //ThreadStart addDataThreadStart = new ThreadStart(AddDataThreadLoop);
                //addDataRunner = new Thread(addDataThreadStart);

                addDataRunner = new Thread(() => AddDataThreadLoop());

                // create a delegate for adding data
                addDataDel += new AddDataDelegate(AddData);
            }
        }
Beispiel #6
0
        private void Connect_button_Click(object sender, EventArgs e)
        {
            try
            {
                ComPort_label.Text = "Serial Port:      connected";

                Atmega328SerialPort.InitializeSerialPort(ComPort_combobox.Text);

                Atmega328SerialPort.GetSerialPort().DataReceived += Atmega328SerialPort_DataReceived;
                this.myDelegate = new AddDataDelegate(AddDataMethod);

                Connect_button.Enabled          = false;
                Disconnect_button.Enabled       = true;
                ResetHardware_button.Enabled    = true;
                Sensitivity_groupbox.Enabled    = true;
                OpenStallMonitor_button.Enabled = true;
                ClearReceived_button.Enabled    = true;
                setCurrent_groupbox.Enabled     = true;
                Position_groupbox.Enabled       = true;
                Calibration_groupbox.Enabled    = true;
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
 public Form1()
 {
     InitializeComponent();
     setInitForm();
     this.myDelegate = new AddDataDelegate(AddDataMethod);
     this.level1 = new addLevel1(AddLevel1);
 }
Beispiel #8
0
 public Form1()
 {
     this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
     InitializeComponent();
     this.myDelegate = new AddDataDelegate(AddDataMethod);
     backgroundWorker1.RunWorkerAsync();
 }
        //Form Reset Methods - Called everytime the form is shown
        private void ResetData(int DifficultyLevel, int Speed, int Torque, Enumerators.ProgramSelect ProgramSelect)
        {
            ChartPowerLeft.ResetData();
            ChartPowerRight.ResetData();

            DataSample = new objDataSample(GlobalVariables.leftSerialPort);
            DataSample.DifficultyLevel = DifficultyLevel;
            DataSample.SelectedSpeed = Speed;
            DataSample.SelectedTorque = Torque;
            DataSample.ProgramSelector = ProgramSelect;
            DataSample.CapturePowerFlag = false;
            if (DataSample.ProgramSelector == Enumerators.ProgramSelect.RehabBilateral || DataSample.ProgramSelector == Enumerators.ProgramSelect.RehabLeftLeg || DataSample.ProgramSelector == Enumerators.ProgramSelect.RehabRightLeg)
                DataSample.CapturePowerFlag = true;
            else
                DataSample.CapturePowerFlag = false;
            ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;

            torqueTankControl1.panelRightConcRef.Height = Convert.ToInt32(DataSample.SelectedTorque * torqueTankControl1.TankLevelMultiplier);
            torqueTankControl1.panelLeftConcRef.Height = Convert.ToInt32(DataSample.SelectedTorque * torqueTankControl1.TankLevelMultiplier);
            torqueTankControl1.panelRightEcceRef.Height = Convert.ToInt32(DataSample.SelectedTorque * torqueTankControl1.TankLevelMultiplier);
            torqueTankControl1.panelLeftEcceRef.Height = Convert.ToInt32(DataSample.SelectedTorque * torqueTankControl1.TankLevelMultiplier);
            torqueTankControl1.Invalidate();

            btnSkipStage.Visible = true;

            lblSetPrevious.Text = "-";
            lblTimePrevious.Text = "-";
        }
Beispiel #10
0
 private void Form1_Load(object sender, EventArgs e)
 {
     serialPort1.Open();                                                        //Opening the serial port
     this.myDelegate        = new AddDataDelegate(AddDataMethod);               //Assigning  "the function that changes richtextbox text" to the delegate
     this.myDelegate_button = new AddDataDelegate_button(AddDataMethod_button); //Assigning "the function that changes button text" to the delegate
     //serialPort1.WriteLine("STATE");
 }
Beispiel #11
0
        private void RAM_Load(object sender, EventArgs e)
        {
            AllocConsole();

            getRamData();
            ram_DataWidth.Text    = wmi.info[5];
            ram_Manufacturer.Text = wmi.info[4];
            ram_SerialNumber.Text = wmi.info[6];
            ram_Speed.Text        = wmi.info[7] + " MHz";
            ram_Interleave.Text   = wmi.info[8];
            ram_Capacity.Text     = wmi.info[2] + " Bytes";

            ThreadStart addDataThreadStart = new ThreadStart(AddDataThreadLoop);

            addDataRunner = new Thread(addDataThreadStart);

            addDataDel += new AddDataDelegate(AddData);


            //add series into chart
            startTrending_Click(null, new EventArgs());

            //button1.Enabled = true;

            tick1 = new System.Windows.Forms.Timer {
                Enabled = true, Interval = Configuration.timeInterval
            };
            tick1.Tick += tick_Tick;
            tick2       = new System.Windows.Forms.Timer {
                Enabled = true, Interval = Configuration.timeInterval + 2000
            };
            tick2.Tick += tick_Tick2;
        }
        //Form Reset Methods - Called everytime the form is shown
        private void ResetData()
        {
            DataSample = new Classes.StaticStrengthTestDS(GlobalVariables.leftSerialPort);
            DataSample.IsTestDataAvailible = false;
            ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;

            if (GlobalVariables.StaticStrengthPB != null)
            {
                lblLeftLegPreviousBest.Text = Math.Round(GlobalVariables.StaticStrengthPB[0], 1).ToString();
                lblRightLegPreviousBest.Text = Math.Round(GlobalVariables.StaticStrengthPB[1], 1).ToString();
            }

            lblMaxTorqueConcLeft.Text = "0";
            gaugeLeft.CircularScales[1].Pointers[0].Value = 0;
            gaugeLeft.CircularScales[0].Pointers[0].Value = GlobalVariables.StaticStrengthPB[0];

            //DataSample.ResetChart(chart_LeftLeg);

            lblMaxTorqueConcRight.Text = "0";
            //DataSample.ResetChart(chart_RightLeg);
            gaugeRight.CircularScales[1].Pointers[0].Value = 0;
            gaugeRight.CircularScales[0].Pointers[0].Value = GlobalVariables.StaticStrengthPB[1];

            EnableButtons();
        }
Beispiel #13
0
        public void SerialInit()
        {
            if (!bluetooth.IsOpen)
            {
                opened                           = true;
                bluetooth.PortName               = "COM5";
                bluetooth.DataBits               = 8;
                bluetooth.Handshake              = Handshake.None;
                bluetooth.ReadTimeout            = 5000;
                bluetooth.ReceivedBytesThreshold = 88;
                bluetooth.DataReceived          += new SerialDataReceivedEventHandler(DataReceivedHandler);

                textBoxDelegate = new AddDataDelegate(AddDataToTextBoxMethod);
                chartDelegate   = new AddDataDelegate(AddDataToChartDelegate);
                quatDelegate    = new AddDataDelegate(UpdateQuaternion);

                try {
                    bluetooth.Open();
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.ToString());
                    return;
                }
            }

            watch = System.Diagnostics.Stopwatch.StartNew();
        }
Beispiel #14
0
 public Form1()
 {
     InitializeComponent();
     getAvailableports();
     this.myDelegate   = new AddDataDelegate(AddDataMethod);
     this.FormClosing += Form1_FormClosing;
 }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackPlotter = new DelegatePlotter(Plotter);
     ThreadCallbackPlotter2 = new DelegatePlotter(Plotter2);
     ThreadCallbackUpdateUI = new AddDataDelegate(UpdateUI);
     ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
     ThreadCallbackUpdateUI_Labels = new AddDataDelegate(UpdateUI_Labels);
 }
Beispiel #16
0
 private void Form1_Load_1(object sender, EventArgs e)
 {
     InitSerial();
     this.myDelegate        = new AddDataDelegate(AddDataMethod);               //Assigning "the function that changes richtextbox text" to the delegate
     this.myDelegate_button = new AddDataDelegate_button(AddDataMethod_button); //Assigning "the function that changes button text" to the delegate
     cpuCounter             = new PerformanceCounter("Processor", "% Processor Time", "_Total");
     ramCounter             = new PerformanceCounter("Memory", "Available MBytes");
 }
Beispiel #17
0
 public MainWindowViewImpl()
 {
     InitializeComponent();
     setupSerialPort();
     myDelegate      = new AddDataDelegate(AddDataMethod);
     replaceDelegate = new ReplaceDataDelegate(ReplaceDataMethod);
     listPorts();
 }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     DataSample = new ObjectClasses.WeighYourselfDS(GlobalVariables.leftSerialPort);
     DataSample.PulseTop = Convert.ToInt32(12000 * CalibrationSettings.Default.GearRatio);
     ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;
     ThreadCallbackZeroSequenceComplete = new AddDataDelegate(ZeroSequenceComplete);
     ThreadCallbackCalculateWeight = new AddDataDelegate(CalculateWeight);       
 }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
     ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;
     ThreadCallbackCloseMessage = new AddDataDelegate(CloseMessage);
     ThreadCallbackUpdateSpeed = new AddDataDelegate(UpdateSpeed);
     ThreadCallbackUpdateCycleCounter = new DelegateUpdateCycleCounter1(UpdateCycleCounter);
     ThreadCallbackUpdateCharts = DataSample.UpdateCharts;
 }
        public Form1()
        {
            InitializeComponent();

            serialPort1.DataReceived += new SerialDataReceivedEventHandler(SerialPort_DataReceived);
            this.Delegate1            = new AddDataDelegate(AddDataMethodNumber);
            this.Delegate2            = new AddDataDelegate(AddDataMethodEven);
            this.Delegate3            = new AddDataDelegate(AddDatatoFileAndLBO);
        }
Beispiel #21
0
        String outPutVoltage = ""; // Voltage wird auf 0 gesetzt, da noch keine vorliegt


        public MainWindow()
        {
            InitializeComponent();
            GetAvaialblePorts();
            ConnectToDatabase();
            LoadDataFromDatabase();
            OpenSerialPort();
            this.myDelegate = new AddDataDelegate(AddDataMethod);
        }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackUpdateTorqueTankLeft = new AddDataDelegate(UpdateTorqueTankLevelLeft);
     ThreadCallbackUpdateTorqueTankRight = new AddDataDelegate(UpdateTorqueTankLevelRight);
     ThreadCallbackPositionSequenceComplete = new AddDataDelegate(PositionSequenceComplete);
     ThreadCallbackTestComplete = new AddDataDelegate(TestSequenceComplete);
     ThreadCallbackUpdatePosition = new DelegateUpdatePosition(UpdatePosition);
     ThreadCallbackTestFailed = new AddDataDelegate(TestFailed);
 }
Beispiel #23
0
 private void Form1_Load(object sender, System.EventArgs e)
 {
     //Create a new single thread to add points to chart series
     Start       = new ThreadStart(DataThreadLoop);
     addRealData = new Thread(Start);
     addDataDel += new AddDataDelegate(AddChartData);
     InitializeChart();
     ChartAppearance.ApplyChartStyles(this.chartControl1);
 }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
     ThreadCallbackPositionSequenceComplete = new AddDataDelegate(PositionSequenceComplete);
     ThreadCallbackUpdateRightLegTorque = new AddDataDelegate(UpdateRightLegTorque);
     ThreadCallbackRightLegTorqueTestComplete = new AddDataDelegate(RightLegTorqueTestComplete);
     ThreadCallbackUpdateLeftLegTorque = new AddDataDelegate(UpdateLeftLegTorque);
     ThreadCallbackLeftLegTorqueTestComplete = new AddDataDelegate(LeftLegTorqueTestComplete);
 }
Beispiel #25
0
 //------------------------------------------>
 //  Function: Connect to Port
 //------------------------------------------<
 private void PortConnect_Button_Click(object sender, EventArgs e)
 {
     if (ConnectFlag == true)    // If the port is aready connected and the button test is "Disconnect", pressing it will disconnect the Port;
     {
         message_richTextBox.Text = "";
         PortStatus_TextBox.Text  = "";
         PortConnect_Button.Text  = "Connect";
         ProgressBar.Value        = 0;
         SerialPort.Close();
         ConnectFlag = false;
     }
     else    // Only if the Port is not connected, it will try to connect to a port;
     {
         if (Ports_comboBox.Text == "")
         {
             PortStatus_TextBox.Text = "        Invalid Port!";
         }
         else
         {
             try
             {
                 if (!SerialPort.IsOpen)
                 {
                     SerialPort               = new SerialPort("COM1", 19200, Parity.None, 8, StopBits.One);
                     SerialPort.PortName      = Ports_comboBox.Text;
                     SerialPort.DataReceived += new SerialDataReceivedEventHandler(SerialPort_DataReceived);
                     SerialPort.Open();
                     for (int i = 0; i < 100; i++)
                     {
                         ProgressBar.Value = i;
                         Thread.Sleep(2);
                     }
                     ProgressBar.Value       = 100;
                     PortStatus_TextBox.Text = "       Port Connected";
                     PortConnect_Button.Text = "Disconnect";
                     ConnectFlag             = true;
                     //SerialPort.ReadTimeout = 500;
                     //SerialPort.WriteTimeout = 500;
                     ////SerialPort.RtsEnable = false;
                     SerialPort.DtrEnable = true;
                     SerialPort.RtsEnable = true;
                     SerialPort.Handshake = System.IO.Ports.Handshake.None;
                     this.myDelegate      = new AddDataDelegate(AddDataMethod);
                 }
                 else
                 {
                     PortStatus_TextBox.Text = "        Port busy!";
                 }
             }
             catch (UnauthorizedAccessException)
             {
                 PortStatus_TextBox.Text = "UnauthorizedAccessException";
             }
         }
     }
 }
Beispiel #26
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // create the Adding Data Thread but do not start until start button clicked
            ThreadStart addDataThreadStart = new ThreadStart(AddDataThreadLoop);

            addDataRunner = new Thread(addDataThreadStart);

            // create a delegate for adding data
            addDataDel += new AddDataDelegate(AddData);
        }
        //EventArgs - Form Load
        private void frmPulseCalibration_Load(object sender, EventArgs e)
        {
            //Congifure app settings for error logging
            XmlConfigurator.Configure();

            DataSample = new objDataSample(GlobalVariables.leftSerialPort);
            ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorCalibration;
            this.ThreadCallbackUpdateLabels = new AddDataDelegate(UpdateLabels);
            ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
        }
Beispiel #28
0
        /// <summary>
        /// Page load event handler.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void RealTimeSample_Load(object sender, System.EventArgs e)
        {
            ThreadStart addDataThreadStart = new ThreadStart(AddDataThreadLoop);

            addDataRunner = new Thread(addDataThreadStart);

            addDataDel += new AddDataDelegate(AddData);

            this.startTrending_Click(null, EventArgs.Empty);
        }
Beispiel #29
0
        //private void Form1_Load(object sender, EventArgs e)
        //{

        //    List<int> x = new List<int>() { 1, 2, 3, 4 };
        //    List<int> y1 = new List<int>() { 100, 20, 60, 31 };
        //    List<int> y2 = new List<int>() { 200, 20, 30, 31 };

        //    //chart1.Series["示例1"].Points.DataBindXY(x, y1);
        //    //chart1.Series[0].Points.DataBindXY(x, y2);

        //}



        private void Form1_Load(object sender, System.EventArgs e)
        {
            // create the Adding Data Thread but do not start until start button clicked
            ThreadStart addDataThreadStart = new ThreadStart(AddDataThreadLoop);

            addDataRunnerThread = new Thread(addDataThreadStart);
            addDataRunnerThread.IsBackground = true; //后台
                                                     // create a delegate for adding data
            //addDataDel += new AddDataDelegate(AddData);  //注册一个方法,初始化一个委托变量
            addDataDel += AddData;                   //另一种初始化方法
        }
Beispiel #30
0
        public Form1()
        {
            InitializeComponent();
            File.AppendAllText(filePath, "Team ID, Packet Count, GPS Time, Fix, Latitude, Longitude, Speed, Angle," +
                               "Altitude, No. of Satellites, Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10" + "\r\n");

            string[] ports = SerialPort.GetPortNames();

            comboPort.Items.AddRange(ports);
            this.myDelegate = new AddDataDelegate(AddDataMethod);
        }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
     ThreadCallbackPositionSequenceComplete = new AddDataDelegate(PositionSequenceComplete);
     ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;
     //ThreadCallbackUpdateRightLegTorque = new AddDataDelegate(UpdateRightLegTorque);
     //ThreadCallbackRightLegTorqueTestComplete = new AddDataDelegate(RightLegTorqueTestComplete);
     ThreadCallbackUpdateLeftLegQuadConc = new AddDataDelegate(UpdateLeftLegQuadConc);
     ThreadCallbackUpdateLeftLegQuadConcComplete = new AddDataDelegate(UpdateLeftLegQuadConcComplete);
     ThreadCallbackUpdateGraph = new AddDataDelegate(UpdateGraph);
 }
Beispiel #32
0
        /// <summary>
        /// 开始绘制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDrawStart_Click(object sender, EventArgs e)
        {
            btnDrawStart.Enabled       = false;
            btnEndDraw.Enabled         = true;
            addDataRunner              = new Thread(new ThreadStart(AddDataThreadLoop));
            addDataRunner.IsBackground = true;
            addDataDel = new AddDataDelegate(AddData);
            DateTime timeValue = DateTime.Now;
            DateTime minValue  = timeValue.ToLocalTime();
            DateTime maxValue  = timeValue.AddSeconds(600).ToLocalTime();

            chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss";
            chart1.ChartAreas[0].AxisX.Title             = "时间";
            chart1.ChartAreas[0].AxisY.Title             = "吊杆力(kN)";
            chart1.ChartAreas[0].AxisX.Minimum           = minValue.ToOADate();
            chart1.ChartAreas[0].AxisX.Maximum           = maxValue.ToOADate();
            chart1.Series.Clear();
            //曲线f1
            f1             = new Series();
            f1.ChartType   = SeriesChartType.Spline;
            f1.BorderWidth = 1;
            f1.BorderColor = Color.Red;
            f1.LegendText  = "一号吊杆";
            //f1.IsValueShownAsLabel = true;
            f1.XValueType = ChartValueType.DateTime;
            //f2
            f2             = new Series();
            f2.ChartType   = SeriesChartType.Spline;
            f2.BorderWidth = 1;
            f2.BorderColor = Color.Orange;
            f2.XValueType  = ChartValueType.DateTime;
            f2.LegendText  = "二号吊杆";
            f3             = new Series();
            f3.ChartType   = SeriesChartType.Spline;
            f3.BorderWidth = 1;
            f3.BorderColor = Color.Green;
            f3.XValueType  = ChartValueType.DateTime;
            f3.LegendText  = "三号吊杆";


            f4             = new Series();
            f4.ChartType   = SeriesChartType.Spline;
            f4.BorderWidth = 1;
            f4.BorderColor = Color.Blue;
            f4.XValueType  = ChartValueType.DateTime;
            f4.LegendText  = "四号吊杆";
            chart1.Series.Add(f1);
            chart1.Series.Add(f2);
            chart1.Series.Add(f3);
            chart1.Series.Add(f4);

            addDataRunner.Start();
        }
Beispiel #33
0
        public Form1()
        {
            InitializeComponent();
            this.myDelegate = new AddDataDelegate(AddDataMethod);
            // Get a list of serial port names.
            string[] ports = SerialPort.GetPortNames();

            textBox1.AppendText("The following serial ports were found:");

            // Display each port name to the console.
            foreach (string port in ports)
            {
                textBox1.AppendText("  " + port);
                ToolStripMenuItem item = new ToolStripMenuItem(port); // create a new menu item
                item.Click += comPortsStripMenuItem_Click;            // add event handler
                comPortsStripMenuItem.DropDownItems.Add(item);        // add to the menu of COM ports
            }


            // scan for COM ports and add to menu item if found

            /*  for (int port = 0; port <= 20; port++)
             *                    {
             *                    serialPort1.PortName = "COM" + port.ToString();
             *                    try
             *                            {
             *                            serialPort1.Open();			// attempt to open serial port
             *                            serialPort1.BaudRate=115200;
             *                            textBox1.AppendText("Found " + serialPort1.PortName + "\n");
             *                            Console.WriteLine("serial port open OK {0}", serialPort1.PortName);
             *                            serialPort1.Close() ;														//open OK, close it
             *                            ToolStripMenuItem item = new ToolStripMenuItem(serialPort1.PortName);	// create a new menu item
             *        item.Click += comPortsStripMenuItem_Click;	// add event handler
             *        comPortsStripMenuItem.DropDownItems.Add(item);	// add to the menu of COM ports
             *                            }
             *                    catch ( Exception ex)
             *                            { Console.WriteLine("serial port open fail {0} ", serialPort1.PortName, ex); }
             *            }
             *
             * Console.WriteLine("COM ports found {0} ", comPortsStripMenuItem.DropDownItems.Count);
             *    textBox1.AppendText(String.Format("{0} COM ports found - select from COM ports menu\r\n\r\n", comPortsStripMenuItem.DropDownItems.Count));
             */
            // if no COM ports were found display message
            if (comPortsStripMenuItem.DropDownItems.Count == 0)
            {
                textBox1.AppendText("\r\n  No COM ports found\r\n");
            }
            else
            {
                textBox1.AppendText("\r\n  Found " + comPortsStripMenuItem.DropDownItems.Count + " COM ports \n");
            }
        }
Beispiel #34
0
        public Form1()
        {
            InitializeComponent();

            string[] ports = SerialPort.GetPortNames();

            ivCbPorts.Items.AddRange(ports);
            ivCbPorts.Items.Add("test");

            this.myDelegate = new AddDataDelegate(AddDataMethod);

            ivSerialPort.DataReceived += new SerialDataReceivedEventHandler(mySerialPort_DataReceived);
        }
Beispiel #35
0
 private void SerialLogger_Load(object sender, EventArgs e)
 {
     //initialize some variables.
     for (int i = 0; i < BAUDRATE.Length; i++)
     {
         baudRateCB.Items.Add(BAUDRATE[i]);
     }
     SerialPort1               = new SerialPort();
     baudRateCB.SelectedItem   = BAUDRATE[0];
     this.myDelegate           = new AddDataDelegate(addText);
     SerialPort1.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
     isOpen   = false;
     logState = loggingState.noLog;
     sb       = new StringBuilder();
 }
        private void Mainform_Load(object sender, EventArgs e)
        {
            // setup delegate
            this.mySerialPortDelegate = new AddDataDelegate(AddSerialPortData);
            msc = new MaximSplashScreenForm(3);                                        // Instantiating the splash screen and making it run for 3 seconds
            msc.disableCheckBoxValue = Properties.Settings.Default.DisableSplashValue; // Setting up the properties to enable/disable the splash screen
            msc.showOK_Click(false);

            com = new SerialUSBForm(serialPort1);// Instantiating the serial port selection form/window and passing th eserial port object to it

            // Setting up the default values on the visual components on the main form
            MaximRadio_Button_CC_LR.Checked                   = true;                      //Setting this as default condition
            TransientLowCurrentRadioButton.Checked            = true;                      // Setting this as default condition
            maxim_Load_ON_OFF_CC.Checked                      = false;                     //Setting default as load off condition
            maximStatusIndicator_Green_CC.IndicatorColor      = StatusIndicatorColor.Gray; //Setting default color conditions
            maximStatusIndicator_Red_CC.IndicatorColor        = StatusIndicatorColor.Red;  //Setting default color conditions
            maximLoad_transientToggleButton.Checked           = false;
            maximTransientStatusIndicatorGreen.IndicatorColor = StatusIndicatorColor.Gray; //Setting default color conditions
            maximTransientStatusIndicatorRed.IndicatorColor   = StatusIndicatorColor.Red;
            Maxim_NumericUpDown_LR_CC.ValueFloat              = 0.00;
            Maxim_NumericUpDown_HR_CC.ValueFloat              = 0.00;


            this.maximtabcontrol.SelectedIndexChanged += new System.EventHandler(this.maximtabcontrol1_SelectedIndexChanged);

            //H CURRENT METER DEFAULT VALUES Constant mode

            maximHCurrentMeter1_CC.UnitsText        = "A";
            maximHCurrentMeter1_CC.MinorTickInc     = 1;
            maximHCurrentMeter1_CC.MajorTickModulos = 1;
            maximHCurrentMeter1_CC.Maximum          = 10;
            maximHCurrentMeter1_CC.Step             = 1;
            maximVoltageAnalogMeter1_CC.Initialize(this);
            maximVoltageAnalogMeter1_CC.DrawColor = true;
            maximLCurrentMeter1_CC.Initialize(this);
            maximLCurrentMeter1_CC.DrawColor = true;
            maximHCurrentMeter1_CC.Initialize(this);
            maximHCurrentMeter1_CC.DrawColor = true;
            MaximAnalogVoltMeter_Transient.Initialize(this);
            MaximAnalogVoltMeter_Transient.DrawColor = true;


            if (!msc.disableCheckBoxValue) // Checks to see if splash screen should be shown
            {
                msc.ShowDialog();          // Shows the splash screen
            }
            com.ShowDialog();              //Show the screen for port selection
        }
Beispiel #37
0
 private void Form1_Load(object sender, EventArgs e)
 {
     SerialDelegate = new AddDataDelegate(AddDataMethod);
     ports          = SerialPort.GetPortNames();
     cmbPorts.Items.AddRange(ports);
     if (ports.Length != 0)
     {
         cmbPorts.SelectedIndex = 0;
         string[] baud = { "4800", "9600", "19200", "38400", "57600", "115200", "230400", "250000" };
         cmbBaud.Items.AddRange(baud);
         cmbBaud.SelectedIndex     = 1;
         serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
     }
     btnSend.Enabled  = false;
     btnClose.Enabled = false;
 }
Beispiel #38
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string fileString = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/testFile.txt";

            //System.IO.File.Create(fileString);
            System.IO.File.WriteAllText(fileString, "X\r\nX");
            try
            {
                serialPort3.Open();//Opening the serial port
            } catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            this.myDelegate        = new AddDataDelegate(AddDataMethod);               //Assigning "the function that changes richtextbox text" to the delegate
            this.myDelegate_button = new AddDataDelegate_button(AddDataMethod_button); //Assigning "the function that changes button text" to the delegate
        }
        //First Method called every time the form is displayed
        public void InitiateProgram(Enumerators.ProgramSelect ProgramSelect)
        {
            this.StartPosition = FormStartPosition.CenterScreen;
            this.WindowState = FormWindowState.Normal;

            DataSample = new objDataSample(GlobalVariables.leftSerialPort);
            DataSample.ProgramSelector = ProgramSelect;
            DataSample.SelectedSpeed = 65;
            DataSample.SelectedTorque = 250;
            ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;

            ResetData();
            CurrentProgram = DataSample.ReadXMLProgram();
            this.Focus();
            Start();
        }
        public mainForm(Form sender, bool autoConnect, string com)
        {
            InitializeComponent();
            //hide all UI components
            toggleUI(true);

            this.logDel = new AddDataDelegate(logSerialText);
            string[] ArrayComPortsNames = null;

            ArrayComPortsNames = SerialPort.GetPortNames();


            if (ArrayComPortsNames.Length != 0)
            {
                for (int i = 0; i < ArrayComPortsNames.Length; i++)
                {
                    cbCom.Items.Add(ArrayComPortsNames[i]);
                }
                cbCom.SelectedIndex   = 0;
                btnDisconnect.Enabled = false;
                btnMoveMtr.Enabled    = false;
                cbMtr.Enabled         = false;
                cbMtrPos.Enabled      = false;

                cbMtr.Items.Add("V");
                cbMtr.Items.Add("I");
                cbMtr.Items.Add("L");


                cbMtrPos.Items.Add("0");
                cbMtrPos.Items.Add("22.5");
                cbMtrPos.Items.Add("45");
                cbMtrPos.Items.Add("67.5");
                cbMtrPos.SelectedIndex = 0;
                cbMtrPos.Enabled       = false;
            }
            else
            {
                cbCom.Items.Add("No COM ports");
                cbCom.SelectedIndex = 0;
            }
            if (autoConnect)
            {
                cbCom.Text = com;
                btnConnect_Click(this, new EventArgs());
            }
        }
Beispiel #41
0
 public Form1()
 {
     InitializeComponent();
     connected       = false;
     this.myDelegate = new AddDataDelegate(AddDataMethod);
     toFile          = "";
     rejectT         = 3; //reject threshold. amount of OOB packets allowed in a single trial
     timeLeft        = 60;
     timeBetween     = 30;
     timerGo         = false;
     DIR             = @"c:\EEG Trial Data\";
     count           = 0;
     packetCount     = 0;
     record          = false;
     outThread       = new Thread(new ThreadStart(outputThread));
     stopOutThread   = false;
 }
        //EventArgs - Form Load
        private void frmPulseCalibration_Load(object sender, EventArgs e)
        {
            //Congifure app settings for error logging
            XmlConfigurator.Configure();

            dataSampleLeft = new objDataSample(GlobalVariables.leftSerialPort);
            dataSampleRight = new objDataSample(GlobalVariables.rightSerialPort);

            ThreadCallbackProcessFeedbackErrorLeft = dataSampleLeft.ProcessErrorCalibration;
            ThreadCallbackProcessFeedbackErrorRight = dataSampleRight.ProcessErrorCalibration;

            ThreadCallbackUpdateLabelLeft = new AddDataDelegate(UpdateLabelLeft);
            ThreadCallbackUpdateLabelRight = new AddDataDelegate(UpdateLabelRight);

            ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
            ThreadCallbackDiagnostics = new AddDataDelegate(UpdateDiagnosticsLabel);
            ThreadCallbackCloseDialog = new CloseDialogDelegate(CloseDialog);
        }
Beispiel #43
0
        public Form1()
        {
            InitializeComponent();

            connected   = false;
            webClient   = new WebClient();
            addDataDel += new AddDataDelegate(AddData);

            DateTime minValue = DateTime.Now;
            DateTime maxValue = minValue.AddSeconds(CHART_SECONDS);

            chart1.ChartAreas[0].AxisX.Minimum                = minValue.ToOADate();
            chart1.ChartAreas[0].AxisX.Maximum                = maxValue.ToOADate();
            chart1.ChartAreas[0].AxisX.LabelStyle.Format      = "T";
            chart1.ChartAreas[0].AxisX.IntervalType           = DateTimeIntervalType.Minutes;
            chart1.ChartAreas[0].AxisX.Interval               = 1;
            chart1.ChartAreas[0].AxisX.MajorGrid.LineColor    = Color.DarkGray;
            chart1.ChartAreas[0].AxisX.MinorGrid.IntervalType = DateTimeIntervalType.Seconds;
            chart1.ChartAreas[0].AxisX.MinorGrid.Interval     = 10;
            chart1.ChartAreas[0].AxisX.MinorGrid.LineColor    = Color.LightGray;
            chart1.ChartAreas[0].AxisX.MinorGrid.Enabled      = true;

            chart1.ChartAreas[0].AxisY.Minimum                = 0;
            chart1.ChartAreas[0].AxisY.Maximum                = 1023;
            chart1.ChartAreas[0].AxisY.IntervalType           = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisY.Interval               = 200;
            chart1.ChartAreas[0].AxisY.MajorGrid.LineColor    = Color.DarkGray;
            chart1.ChartAreas[0].AxisY.MinorGrid.IntervalType = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisY.MinorGrid.Interval     = 50;
            chart1.ChartAreas[0].AxisY.MinorGrid.LineColor    = Color.LightGray;
            chart1.ChartAreas[0].AxisY.MinorGrid.Enabled      = true;

            chart1.Series.Clear();
            mySerie             = new Series("AnalogInput");
            mySerie.ChartType   = SeriesChartType.FastLine;
            mySerie.BorderWidth = 1;
            mySerie.Color       = Color.Red;
            mySerie.XValueType  = ChartValueType.DateTime;
            chart1.Series.Add(mySerie);

            DateTime timeStamp = DateTime.Now;

            chart1.Series[0].Points.AddXY(timeStamp, 0);
        }
Beispiel #44
0
        private void BatteryForm_Load(object sender, EventArgs e)
        {
            System.Diagnostics.Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
            netData.Max = 1000000;
            powerStatus = new SYSTEM_POWER_STATUS();

            DoAsync async = new DoAsync(GetBatteryDetails);

            async.BeginInvoke(null, null);

            //define a thread to add values into chart
            ThreadStart addDataThreadStart = new ThreadStart(AddDataThreadLoop);

            addDataRunner = new Thread(addDataThreadStart);
            addDataDel   += new AddDataDelegate(AddData);
            //add series into chart
            startTrending_Click(null, new EventArgs());

            t = new System.Windows.Forms.Timer {
                Enabled = true, Interval = 1000
            };
            t.Tick += t_Tick;
            powerSource.TextChanged += new EventHandler(this.t_Tick);

            metroComboBox1.Items.Add("Monitor");
            metroComboBox1.Items.Add("Fan");
            metroComboBox1.Items.Add("Heat pipe");
            metroComboBox1.Items.Add("Refrigeration");
            metroComboBox1.Items.Add("TemperatureProbe");
            metroComboBox1.Items.Add("CDROM Drive");
            metroComboBox1.Items.Add("Disk Drive");
            metroComboBox1.Items.Add("Floppy Drive");
            metroComboBox1.Items.Add("Tape Drive");
            metroComboBox1.Items.Add("Mother Board");
            metroComboBox1.Items.Add("USB Hub");
            metroComboBox1.Items.Add("Network adapter");
            metroComboBox1.Items.Add("Voltage Probe");
            metroComboBox1.Items.Add("Printer");
            metroComboBox1.Items.Add("Processor");

            this.metroComboBox1.SelectedIndexChanged +=
                new System.EventHandler(metroComboBox1_SelectedIndexChanged);
        }
Beispiel #45
0
        public Form1()
        {
            InitializeComponent();

            connected = false;
            webClient = new WebClient();
            addDataDel += new AddDataDelegate(AddData);

            DateTime minValue = DateTime.Now;
            DateTime maxValue = minValue.AddSeconds(CHART_SECONDS);
            chart1.ChartAreas[0].AxisX.Minimum = minValue.ToOADate();
            chart1.ChartAreas[0].AxisX.Maximum = maxValue.ToOADate();
            chart1.ChartAreas[0].AxisX.LabelStyle.Format = "T";
            chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Minutes;
            chart1.ChartAreas[0].AxisX.Interval = 1;
            chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.DarkGray;
            chart1.ChartAreas[0].AxisX.MinorGrid.IntervalType = DateTimeIntervalType.Seconds;
            chart1.ChartAreas[0].AxisX.MinorGrid.Interval = 10;
            chart1.ChartAreas[0].AxisX.MinorGrid.LineColor = Color.LightGray;
            chart1.ChartAreas[0].AxisX.MinorGrid.Enabled = true;

            chart1.ChartAreas[0].AxisY.Minimum = 0;
            chart1.ChartAreas[0].AxisY.Maximum = 1023;
            chart1.ChartAreas[0].AxisY.IntervalType = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisY.Interval = 200;
            chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.DarkGray;
            chart1.ChartAreas[0].AxisY.MinorGrid.IntervalType = DateTimeIntervalType.Number;
            chart1.ChartAreas[0].AxisY.MinorGrid.Interval = 50;
            chart1.ChartAreas[0].AxisY.MinorGrid.LineColor = Color.LightGray;
            chart1.ChartAreas[0].AxisY.MinorGrid.Enabled = true;

            chart1.Series.Clear();
            mySerie = new Series("AnalogInput");
            mySerie.ChartType = SeriesChartType.FastLine;
            mySerie.BorderWidth = 1;
            mySerie.Color = Color.Red;
            mySerie.XValueType = ChartValueType.DateTime;
            chart1.Series.Add(mySerie);

            DateTime timeStamp = DateTime.Now;
            chart1.Series[0].Points.AddXY(timeStamp, 0);
        }
Beispiel #46
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Code to run when the Form loads
            // Initialise the location graph
            seriesLocation = chartLocation.Series[0];
            seriesLocation.Points.Clear();
            seriesLocation.Points.AddXY(0, 10);
            seriesLocation.Points.AddXY(0, 0);
            seriesLocation.Points[0].Label = seriesLocation.Points[0].XValue.ToString() + "°";

            //Initial serial port settings
            serialPort1.PortName        = "COM1";
            serialPort1.BaudRate        = 9600;
            serialPort1.DataBits        = 8;
            serialPort1.StopBits        = StopBits.One;
            serialPort1.Parity          = Parity.None;
            serialPort1.Handshake       = Handshake.None;
            serialPort1.ReadBufferSize  = 4096;
            serialPort1.ReadTimeout     = 500;
            serialPort1.WriteBufferSize = 2048;
            serialPort1.WriteTimeout    = 500;


            // Show port selection dialog
            do
            {
                if (connection_dialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.Close();
                    return;
                }
                if (serialPort1.IsOpen)
                {
                    serialPort1.Close();
                }
                serialPort1.PortName = connection_dialog.Port_Name;
            } while (Connect_Serial() < 0);

            this.myDelegate = new AddDataDelegate(serial_Logger);
            this.serialPort1.DataReceived     += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived);
            comboCurrentStepSize.SelectedIndex = 0;
        }
 public Form2(ref string path_p1, ref string path_np1,ref int gap1,ref float glen1)
 {
     try
     {
         InitializeComponent();
         //Icon = New_ping.Properties.Resources.ajax_loader__3_;
         path_p = path_p1;
         path_np = path_np1;
         gap = gap1;
         glen = glen1;
         btn_resume.Enabled = false;
         addDataThreadStart = new ThreadStart(AddDataThreadLoop);
         addDataRunner = new Thread(addDataThreadStart);
         addDataDel += new AddDataDelegate(AddData);
         addDataRunner.Start();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void frmDropTest_Load(object sender, EventArgs e)
        {
            logger.Info("Initiating Drop Test.");

            frmPulseCalibrationDialog ObjFrmPulseCalibration = new frmPulseCalibrationDialog();
            ObjFrmPulseCalibration.ShowDialog();

            ChartTorque.ResetData();
            SetupGraphs();

            DataSample = new Classes.StaticStrengthTestDS(GlobalVariables.leftSerialPort);
            DataSample.CapturePowerFlag = true;
            ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;
            isNewSession = true;
        }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
     ThreadCallbackPositionSequenceComplete = new AddDataDelegate(PositionSequenceComplete);
     ThreadCallbackResetSequenceComplete = new AddDataDelegate(ResetSequenceComplete);
     ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;
     ThreadCallbackUpdateGraph = new AddDataDelegate(UpdateGraph);
     ThreadCallbackUpdateLabels = new AddDataDelegate(UpdateLabels);
     ThreadCallbackTestComplete = new AddDataDelegate(TestComplete);
     ThreadCallbackRepComplete = new AddDataDelegate(RepComplete);
     ThreadCallbackEnableButtons = new AddDataDelegate(EnableButtons);
 }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackStopSequence = new AddDataDelegate(StopSequence);
     ThreadCallbackUpdateSpeed = new AddDataDelegate(UpdateSpeed);
 }
Beispiel #51
0
 private void Main_Load(object sender, EventArgs e)
 {
     this.myDelegate = new AddDataDelegate(AddDataMethod);
 }
 public Form4(ref string ip,ref string interfaceforoidpass,ref string cstring,ref int snmp_gap1)
 {
     InitializeComponent();
     ipadd = ip;
     cs = cstring;
     snmp_gap = snmp_gap1;
     interfaceforoid = interfaceforoidpass;
     if (interfaceforoid.Substring(0, 1) == "2")
     {
         iface = interfaceforoid.Substring(1);
         try
         {
             btn_resume.Enabled = false;
             response = conn.get("get", ipadd, cs, "1.3.6.1.2.1.2.2.1.5." + iface);
             speed1 = packetoutputval(response);
             if (speed1 == 0)
             {
                 response = conn.get("get", ipadd, cs, "1.3.6.1.2.1.2.2.1.5." + iface);
                 speed1 = packetoutputval(response);
                 if (speed1 == 0)
                 {
                     MessageBox.Show("Please try again.Sorry for inconvenience");
                     this.Close();
                 }
             }
             speed1 = speed1 / 8;
         }
         catch (Exception ex)
         {
             MessageBox.Show("1 " + ex.Message);
         }
         threadno = 1;
         interfaceforoid = "1.3.6.1.2.1.2.2.1.10." + iface;
         addDataThreadStart1 = new ThreadStart(AddDataThreadLoop1);
         addDataRunner1 = new Thread(addDataThreadStart1);
         addDataDel1 += new AddDataDelegate(AddData1);
         addDataRunner1.Start();
     }
     else
     {
         if (interfaceforoid.Substring(0, 1) == "3")
         {
             iface = interfaceforoid.Substring(1);
             try
             {
                 //Icon = New_ping.Properties.Resources.ajax_loader__3_;
                 btn_resume.Enabled = false;
                 response = conn.get("get", ipadd, cs, "1.3.6.1.2.1.2.2.1.5." + iface);
                 speed1 = packetoutputval(response);
                 if (speed1 == 0)
                 {
                     response = conn.get("get", ipadd, cs, "1.3.6.1.2.1.2.2.1.5." + iface);
                     speed1 = packetoutputval(response);
                     if (speed1 == 0)
                     {
                         MessageBox.Show("Please try again.Sorry for inconvenience");
                         this.Close();
                     }
                 }
                 speed1 = speed1 / 8;
             }
             catch (Exception ex)
             {
                 MessageBox.Show("1 " + ex.Message);
             }
             interfaceforoid = "1.3.6.1.2.1.2.2.1.16." + iface;
             threadno = 1;
             addDataThreadStart1 = new ThreadStart(AddDataThreadLoop1);
             addDataRunner1 = new Thread(addDataThreadStart1);
             addDataDel1 += new AddDataDelegate(AddData1);
             addDataRunner1.Start();
         }
         else
         {
             if (interfaceforoid.Substring(0, 1) == "4")
             {
                 iface = interfaceforoid.Substring(1);
                 try
                 {
                     //Icon = New_ping.Properties.Resources.ajax_loader__3_;
                     btn_resume.Enabled = false;
                     response = conn.get("get", ipadd, cs, "1.3.6.1.2.1.2.2.1.5." + iface);
                     speed1 = packetoutputval(response);
                     if (speed1 == 0)
                     {
                         response = conn.get("get", ipadd, cs, "1.3.6.1.2.1.2.2.1.5." + iface);
                         speed1 = packetoutputval(response);
                         if (speed1 == 0)
                         {
                             MessageBox.Show("Please try again.Sorry for inconvenience");
                             this.Close();
                         }
                     }
                     speed1 = speed1 / 8;
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("1 " + ex.Message);
                 }
                 threadno = 2;
                 addDataThreadStart2 = new ThreadStart(AddDataThreadLoop2);
                 addDataRunner2 = new Thread(addDataThreadStart2);
                 addDataDel2 += new AddDataDelegate(AddData2);
                 addDataRunner2.Start();
             }
             else
             {
                 try
                 {
                     btn_resume.Enabled = false;
                     threadno = 0;
                     addDataThreadStart = new ThreadStart(AddDataThreadLoop);
                     addDataRunner = new Thread(addDataThreadStart);
                     addDataDel += new AddDataDelegate(AddData);
                     addDataRunner.Start();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("1 " + ex.Message);
                 }
             }
         }
     }
 }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackUpdateTorqueTank = new AddDataDelegate(UpdateTorqueTankLevel);
 }
Beispiel #54
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Code to run when the Form loads
            // Initialise the location graph
            seriesLocation = chartLocation.Series[0];
            seriesLocation.Points.Clear();
            seriesLocation.Points.AddXY(0, 10);
            seriesLocation.Points.AddXY(0, 0);
            seriesLocation.Points[0].Label = seriesLocation.Points[0].XValue.ToString() + "°";

            //Initial serial port settings
            serialPort1.PortName = "COM1";
            serialPort1.BaudRate = 9600;
            serialPort1.DataBits = 8;
            serialPort1.StopBits = StopBits.One;
            serialPort1.Parity = Parity.None;
            serialPort1.Handshake = Handshake.None;
            serialPort1.ReadBufferSize = 4096;
            serialPort1.ReadTimeout = 500;
            serialPort1.WriteBufferSize = 2048;
            serialPort1.WriteTimeout = 500;

            // Show port selection dialog
             do
             {
                if (connection_dialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.Close();
                    return;
                }
                if (serialPort1.IsOpen)
                    serialPort1.Close();
                serialPort1.PortName = connection_dialog.Port_Name;
            } while (Connect_Serial() < 0);

            this.myDelegate = new AddDataDelegate(serial_Logger);
            this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived);
            comboCurrentStepSize.SelectedIndex = 0;
        }
        //Form Reset Methods - Called everytime the form is shown
        private void ResetData()
        {
            lblMax_T_L.Text = "-";
            lblMax_T_R.Text = "-";
            lblMax_A_L.Text = "-";
            lblMax_A_R.Text = "-";
            lblShapeFactor_L.Text = "-";
            lblShapeFactor_R.Text = "-";
            lblDeviation_L.Text = "-";
            lblDeviation_R.Text = "-";
            lblTime.Text = "00:00";

            chart1.Series[0].Points.Clear();
            chart1.Series[1].Points.Clear();
            chart1.Series[2].Points.Clear();
            chart1.Series[3].Points.Add(0);

            chartRightLeg.Series[0].Points.Clear();
            chartRightLeg.Series[1].Points.Clear();
            chartRightLeg.Series[2].Points.Clear();
            chartRightLeg.Series[3].Points.Clear();

            chartRightLeg.ChartAreas[0].AxisY.Maximum = 180;
            chart1.ChartAreas[0].AxisY.Maximum = 180;

            chartRightLeg.Series[3].Points.Add(0).YValues[0] = -5;

            DataSample = new SpinShaperDS(GlobalVariables.leftSerialPort);
            DataSample.CapturePowerFlag = false;
            ThreadCallbackProcessFeedbackError = DataSample.ProcessErrorSession;
        }
Beispiel #56
0
        private void sp_DataReceived(object sender,SerialDataReceivedEventArgs e)
        {
            if (!test1StartSoundPlayed)
            {
                playSound();
                test1StartSoundPlayed = true;
            }
            isReceiving = true;
            char[] data = new char[sp.BytesToRead];
            sp.Read(data, 0, data.Length);

            AddDataDelegate utb = new AddDataDelegate(addData);
            this.Invoke(utb,new object[]{data});
            isReceiving = false;
        }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackUpdateTorqueTankLeft = new AddDataDelegate(UpdateTorqueTankLevelLeft);
     ThreadCallbackUpdateTorqueTankRight = new AddDataDelegate(UpdateTorqueTankLevelRight);
 }
Beispiel #58
0
		/// <summary>
		/// Page load event handler.
		/// </summary>
		/// <param name="sender">Event sender.</param>
		/// <param name="e">Event arguments.</param>
		private void RealTimeSample_Load(object sender, System.EventArgs e)
		{
			ThreadStart addDataThreadStart = new ThreadStart(AddDataThreadLoop);
			addDataRunner = new Thread(addDataThreadStart);

			addDataDel += new AddDataDelegate(AddData);

			this.startTrending_Click( null, EventArgs.Empty);
		}
        private void FormularioOperador_Load(object sender, EventArgs e)
        {
            FormResizer objFormResizer = new FormResizer();
            objFormResizer.ResizeForm(this, 864, 1152);

            try
            {

                if (!RS232.IsOpen)
                {
                    this.myDelegate = new AddDataDelegate(AddDataMethod);
                    RS232.DataReceived += new SerialDataReceivedEventHandler(RS232_DataReceived);
                    RS232.Open();
                }

            }
            catch (Exception error)
            {
                //loggerError(error.Message);
            }
        }
 //Form Initialise Methods - Called when the form is created for the first time
 private void AssignCallbackMethods()
 {
     ThreadCallbackPositionSequenceComplete = new AddDataDelegate(PositionSequenceComplete);
     ThreadCallbackUpdateTorqueGraph = new AddDataDelegate(UpdateTorqueGraph);
 }