//Start the Program private void Start() { logger.Info("Starting Custom Program Session"); DataSample.ValidateMaxAllowableTorque(); lblSelectedSpeed.Text = DataSample.SelectedSpeed.ToString(); lblSelectedTorque.Text = DataSample.SelectedTorque.ToString(); torqueTankControlCustom.TankReferenceLevel = DataSample.SelectedTorque; //Prevent screen from switching off displayPowerRequest = new PowerManager.PowerRequest("SessionActive"); displayPowerRequest.DisplayRequired = true; if (GlobalVariables.ServoController.InitiateMotor(DataSample.SelectedSpeed, DataSample.SelectedTorque, DataSample.SelectedDirection, GlobalVariables.leftSerialPort).IsSuccess == false) return; GlobalVariables.SerialPortBusyLeft = false; EnableTimers(); }
private void frmCustomProgram_Activated(object sender, EventArgs e) { if (isNewSession == true) { DialogResult result = System.Windows.Forms.DialogResult.OK; isNewSession = false; frmPulseCalibrationDialog ObjFrmPulseCalibration = new frmPulseCalibrationDialog(); result = ObjFrmPulseCalibration.ShowDialog(); System.Threading.Thread.Sleep(50); //dataSampleLeft.StartTime = DateTime.Now; if (result == System.Windows.Forms.DialogResult.OK) { //Prevent screen from switching off displayPowerRequest = new PowerManager.PowerRequest("SessionActive"); displayPowerRequest.DisplayRequired = true; dataSampleLeft.StartingPulse = CalibrationSettings.Default.LeftStartingPulse; dataSampleRight.StartingPulse = CalibrationSettings.Default.RightStartingPulse; } else { StopSequence(); Application.OpenForms["frmUserMenu"].Focus(); } } }
//Start the Program private void Start() { logger.Info("Starting Scrum Max Force Test"); ResetData(); torqueTankControlCustom.TankReferenceLevel = 9000; // 9000N Force //Prevent screen from switching off displayPowerRequest = new PowerManager.PowerRequest("SessionActive"); displayPowerRequest.DisplayRequired = true; if (GlobalVariables.ServoController.InitiateMotorForce(0, CalibrationSettings.Default.MaxAllowableForce, Enumerators.Direction.Forward, GlobalVariables.leftSerialPort).IsSuccess == false) return; if (GlobalVariables.ServoController.InitiateMotorForce(0, CalibrationSettings.Default.MaxAllowableForce, Enumerators.Direction.Forward, GlobalVariables.rightSerialPort).IsSuccess == false) return; GlobalVariables.SerialPortBusyLeft = false; EnableTimers(); }
/// <summary> /// Sets up some required Program Settings and Loads the splash screen /// </summary> private void InitializeProgramSettings() { //Change Windows Shell to current Application - Registry Setup and Batch File Creation //ConfigWindowsShell(); //Initialize Logger Settings XmlConfigurator.Configure(); //Setup the Display Timeout Settings PowerManager.PowerRequest displayPowerRequest = new PowerManager.PowerRequest("SessionActive"); displayPowerRequest.GetSystemPowerPolicy(); if (displayPowerRequest != null) displayPowerRequest.Dispose(); //Create a new fixed serial port ObjectClasses.SerialPortConfig serialPortConfig = new ObjectClasses.SerialPortConfig(CalibrationSettings.Default.LeftSerialPortName, 57600, 8, System.IO.Ports.StopBits.One, System.IO.Ports.Parity.None, false, false); GlobalVariables.leftSerialPort = new ObjectClasses.SerialPortL7S(serialPortConfig); GlobalVariables.leftSerialPort.PortName = CalibrationSettings.Default.LeftSerialPortName; GlobalVariables.ServoController = new objServoController(); ObjectClasses.SerialPortConfig serialPortSeatConfig = new ObjectClasses.SerialPortConfig(CalibrationSettings.Default.RightSerialPortName, 57600, 8, System.IO.Ports.StopBits.One, System.IO.Ports.Parity.None, false, false); GlobalVariables.rightSerialPort = new ObjectClasses.SerialPortL7S(serialPortSeatConfig); GlobalVariables.rightSerialPort.PortName = CalibrationSettings.Default.RightSerialPortName; GlobalVariables.serialPortLeftLeg = new ObjectClasses.SerialPortIo(serialPortSeatConfig); GlobalVariables.serialPortLeftLeg.PortName = CalibrationSettings.Default.LeftSerialPortName; GlobalVariables.serialPortRightLeg = new ObjectClasses.SerialPortIo(serialPortSeatConfig); GlobalVariables.serialPortRightLeg.PortName = CalibrationSettings.Default.RightSerialPortName; //Sets the Path to the DataDirectory //AppDomain.CurrentDomain.SetData("DataDirectory", "C:\\Grucox Data"); //Load the Startup Splash Screen Thread splashThread = new Thread(new ThreadStart(StartSplash)); // Create a new thread from which to start the splash screen form splashThread.Start(); //Twitter Feed - Diagnostics DataComms.CreateThreadInstance("Program Startup!"); }
//Start the motor, timers and enable Serial Data Read Event private void Start() { int SpeedVal; //Disable Display Power Off displayPowerRequest = new PowerManager.PowerRequest("SessionActive"); displayPowerRequest.DisplayRequired = true; if (CurrentVO2MaxProgram.CurrentVO2MaxStage.StageName == "Warm Up" || CurrentVO2MaxProgram.CurrentVO2MaxStage.StageName == "Cool Down") { SpeedVal = 50; } else { SpeedVal = Convert.ToInt32(DataSample.SelectedSpeed); } if (DataSample.SelectedTorque >= 300) DataSample.SelectedTorque = 300; DataSample.SelectedDirection = CurrentVO2MaxProgram.CurrentVO2MaxStage.CurrentVO2MaxSet.SelectedDirection; System.Threading.Thread.Sleep(25); //Wait to ensure that all the data in the serial buffer has been read. #if TEST #else if (GlobalVariables.ServoController.InitiateMotor(DataSample.SelectedSpeed, DataSample.SelectedTorque, CurrentVO2MaxProgram.CurrentVO2MaxStage.CurrentVO2MaxSet.SelectedDirection, GlobalVariables.leftSerialPort).IsSuccess == false) { return; } #endif DataSample.CurrentByte = 0x0; DataSample.ByteStream = new MemoryStream(); DataSample.SerialReadInProgress = false; GlobalVariables.leftSerialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(serialPort_DataReceived); timerTorqueAcc.Enabled = true; timerElapsedTime.Enabled = true; }