public HardwareLogEntry(string name, HardwareStatus status, LogType level = LogType.Message) { this.Name = name; this.Status = status; this.Level = level; this.TimeStamp = DateTime.Now; }
private void PopulateInfo() { // Hardware Status Info { HardwareStatus status = new HardwareStatus(); var dict = StructToDictionary(status, typeof(HardwareStatus)); foreach (var info in dict) { ListViewItem item = listInfo.Items.Add(info.Key); item.SubItems.Add(info.Value.ToString()); } } // Tasks Task[] tasks = dll.GetSchedulerTasks(); foreach (Task task in tasks) { var dict = StructToDictionary(task, typeof(Task)); var group = listTasks.Groups.Add(task.name, task.name); foreach (var info in dict) { var item = listTasks.Items.Add(info.Key); item.Group = group; item.SubItems.Add(info.Value.ToString()); } } }
private async Task InsertHardwareStatus(string[] hardwareStatusData, string parentId, string deviceId) { if (hardwareStatusData.Length < 6) { return; } var signalList = new List <Signal>(); if (hardwareStatusData.Length > 5) { int index = 0; for (int i = 6; i < hardwareStatusData.Length; i++) { var signal = new Signal(index, ParseHex(hardwareStatusData[i])); signalList.Add(signal); index++; } } var hardwareStatus = new HardwareStatus( ParseDateTime(hardwareStatusData[1]), ParseHex(hardwareStatusData[2]), ParseHex(hardwareStatusData[3]), ParseHex(hardwareStatusData[4]), ParseInt(hardwareStatusData[5]) == 1 ? true : false, signalList, parentId, deviceId ); await _context.HardwareStatuses.AddOneAsync(hardwareStatus); }
public HandleResults HandleMessage(HardwareStatus message) { STrace.Debug(GetType().FullName, message.DeviceId, "HANDLE --> <HardwareStatus>"); Enqueue(String.Format("HS,{0},{1},", message.DeviceId, message.Datos)); return(HandleResults.BreakSuccess); }
/// <summary> /// Changes a machine's status on the UI based on its status. /// </summary> /// <param name="hardware">The hardware to change.</param> /// <param name="hardwareStatus">The status to change to.</param> public void ChangeHardwareStatus(Hardware hardware, HardwareStatus hardwareStatus) { PictureBox pictureBox; string pictureBoxName = this.GetHardwarePictureBoxName(hardware); var pictureBoxCollection = !string.IsNullOrWhiteSpace(pictureBoxName) ? this.pnlContainer.Controls.Find(pictureBoxName, false) : null; if (pictureBoxCollection == null) { return; } pictureBox = pictureBoxCollection.FirstOrDefault(x => x.Name == pictureBoxName) as PictureBox; if (hardware == Hardware.SorterRobot || hardware == Hardware.LoaderRobot || hardware == Hardware.AssemblerRobot || hardware == Hardware.PalletiserRobot) { this.ChangeRobotPictureBox(pictureBox, hardwareStatus); } else if (hardware == Hardware.SorterCamera || hardware == Hardware.TrayVerifierCamera) { this.ChangeCameraPictureBox(pictureBox, hardwareStatus); } else if (hardware == Hardware.AssemblyConveyor) { this.ChangeAssemblyConveyorPictureBox(pictureBox, hardwareStatus); } else if (hardware == Hardware.SorterConveyor) { this.ChangeSorterConveyorPictureBox(pictureBox, hardwareStatus); } }
public void Initialise() { var networkScanner = new NetworkScanner(); for(int i = 0; i < 20; i++) { Thread.Sleep(100); networkScanner.Scan(); foreach (ControllerInfo controller in networkScanner.Controllers) { if (controller.IPAddress.Equals(this.RobotIPAddress)) { this.Controller = ControllerFactory.CreateFrom(controller); this.Controller.Rapid.ExecutionStatusChanged += new EventHandler<ExecutionStatusChangedEventArgs>(RapidExecutionStatusChanged); this.SetSpeed(100); _status = HardwareStatus.Operational; return; } } } _status = HardwareStatus.Offline; throw new Exception(string.Format("Robot at {0} could not be found.", this.RobotIPAddress)); }
public void Initialise() { if (SerialPort.GetPortNames().Contains(PortName)) { _serialPort.PortName = PortName; if (!_serialPort.IsOpen) { try { _serialPort.Open(); _status = HardwareStatus.Operational; } catch (Exception ex) { _status = HardwareStatus.Failed; throw ex; } } } else { _status = HardwareStatus.Failed; throw new InvalidOperationException("Serial port name " + PortName + "does not exist"); } }
static void Main(string[] args) { HardwareStatus myComputerStatus = HardwareStatus.OK; HttpStatus websiteStatus = HttpStatus.NotFound; Console.WriteLine((int)myComputerStatus); Console.WriteLine((int)websiteStatus); }
public void Initialise() { Position = ConveyorPosition.Right; Conveyor.initialisePLC(); Thread.Sleep(1000); Conveyor.start(_portName); _status = HardwareStatus.Operational; }
public HardwareStatus GetHardwareStatus() { Send(Constants.DMC_GET_HARDWARE_STATUS); var result = Read(); var dict = ToDictionary(result, Constants.HardwareStatusPrexies); var status = new HardwareStatus(); return(status.FromDictionary(dict)); }
public HardwareStatusDTO(HardwareStatus hardwareStatus) { Id = hardwareStatus.Id; DateTime = hardwareStatus.DateTime; MainPower = hardwareStatus.MainPower; Battery = hardwareStatus.Battery; McuTemperature = hardwareStatus.McuTemperature; IsMoving = hardwareStatus.IsMoving; Signals = hardwareStatus.Signals; }
private void Hw_HandsetStateChanged(object sender, HardwareStatus e) { if (_core.TryGetUiManager(out IUiManager ui)) { Call(); } if (_telephonePage != null) { _telephonePage.SetAudioDevices( e == HardwareStatus.On ? SpeakerPhoneAudioOutDevice : HandsetAudioOutDevice, e == HardwareStatus.On ? SpeakerPhoneAudioInDevice: HandsetAudioInDevice); } }
public void MoveBackward() { switch(Position) { case ConveyorPosition.Right: _status = HardwareStatus.Failed; throw new Exception("Conveyor is at its most backward position"); case ConveyorPosition.Middle: Conveyor.middleToRight(); Position = ConveyorPosition.Right; break; case ConveyorPosition.Left: Conveyor.leftToMiddle(); Position = ConveyorPosition.Middle; break; } }
/// <summary>Initializes a new instance of the <see cref="SimulatorStateMachine" /> class.</summary> /// <param name="timeSource">A source of the current time.</param> /// <param name="simulatorConfiguration"></param> public SimulatorStateMachine(IClock timeSource, SimulatorConfiguration simulatorConfiguration, ILog logger) { Contract.Requires(timeSource != null); log = logger; Configuration = simulatorConfiguration; this.timeSource = timeSource; DomeSupportRingOpen = false; ShutterStuck = false; HardwareStatus = new HardwareStatus { AtHome = false, Coast = 1, CurrentAzimuth = 0, DeadZone = 3, DomeCircumference = 414, DsrSensor = SensorState.Indeterminate, FirmwareVersion = "V4", HomeClockwise = 16, HomeCounterClockwise = 1, HomePosition = 8, Humidity = 255, Lx200Azimuth = 999, Offset = 0, ShutterSensor = SensorState.Indeterminate, Slaved = false, Snow = 255, // For weather items, 255 means no data Temperature = 255, TimeStamp = timeSource.GetCurrentTime(), UserPins = 0, WeatherAge = 128, WindDirection = 255, WindPeak = 255, WindSpeed = 255 }; SetAzimuthDependentSensorsAndStates(); // Set the starting state and begin receiving. SimulatorState.Transition(new StateStartup(this)); var receiveObservable = receiveSubject.AsObservable(); receiveSubscription = receiveObservable.Subscribe(InputStimulus, EndOfSimulation); }
public void UpdateInfo() { // Hardware Status Info { //listInfo.BeginUpdate(); HardwareStatus status = dll.GetHardwareStatus(); var dict = StructToDictionary(status, typeof(HardwareStatus)); int i = 0; foreach (var info in dict) { var item = listInfo.Items[i++]; string newValue = info.Value.ToString(); if (item.SubItems[1].Text != newValue) { item.SubItems[1].Text = newValue; } } //listInfo.EndUpdate(); } // Tasks { //listTasks.BeginUpdate(); Task[] tasks = dll.GetSchedulerTasks(); int i = 0; foreach (Task task in tasks) { var dict = StructToDictionary(task, typeof(Task)); foreach (var info in dict) { var item = listTasks.Items[i++]; string newValue = info.Value.ToString(); if (item.SubItems[1].Text != newValue) { item.SubItems[1].Text = newValue; } } } //listTasks.EndUpdate(); } }
private void UpdateAllSwitchStates() { this._plc.Function = enumAsadtcpFunction.ASADTCP_FUNC_READ; this._plc.MemStart = "Y0"; this._plc.MemQty = 1; this._plc.SyncRefresh(); if (this._plc.Result == 0) { var switchKeysArray = _switchStates.Keys.ToArray(); for (int i = 0; i < switchKeysArray.Count(); i++) { var switchKey = switchKeysArray[i]; _switchStates[switchKey] = this._plc.GetDataBitM((short)switchKey); } } else { this._hwStatus = HardwareStatus.Failed; throw new Exception("Unable to retrieve state from PLC"); } }
public void EmergencyStop() { this.Controller.Rapid.Stop(StopMode.Immediate); _status = HardwareStatus.Failed; }
/// <summary> /// Appends Fru for GetBladeHealth function. /// </summary> /// <param name="response"></param> /// <param name="hwresp"></param> /// <param name="append"></param> private void AppendFruInfo(ref Contracts.BladeHealthResponse response, HardwareStatus hwresp, bool append) { // append fru info if required. if (append) { response.serialNumber = hwresp.SerialNumber; response.assetTag = hwresp.AssetTag; response.productType = hwresp.ProductType; response.hardwareVersion = hwresp.HardwareVersion; } else { response.serialNumber = string.Empty; response.assetTag = string.Empty; response.productType = string.Empty; response.hardwareVersion = string.Empty; } }
public HardwareInfo(ControllerType controllerType, string serialOrPort, HardwareStatus status) { this.ControllerType = controllerType; this.Id = new HardwareId(controllerType, serialOrPort); this.Status = status; }
protected void RunRapidProgram(string filename) { if (this.Controller.OperatingMode != ControllerOperatingMode.Auto) { _status = HardwareStatus.Failed; throw new Exception(string.Format("Robot {0} is not in autonomous mode. Rotate the Mode switch on the robot controller into Autonomous Mode", this.Name)); } if (this.Controller.State != ControllerState.MotorsOn) { _status = HardwareStatus.Failed; throw new Exception(string.Format("Robot {0} motors are not on. Press the white flashing button on the robot controller to enable motors", this.Name)); } var filePath = Controller.FileSystem.LocalDirectory + "\\mod\\" + filename; if (!File.Exists(filePath)) { _status = HardwareStatus.Failed; throw new FileNotFoundException(string.Format("{0} does not exist.", filePath)); } _status = HardwareStatus.Operational; this.BeginControl(); this.Controller.FileSystem.PutFile(filePath, filename, true); this.Task.DeleteProgram(); this.Task.LoadModuleFromFile(filename, RapidLoadMode.Replace); this.Task.ResetProgramPointer(); this.Task.Start(); this.EndControl(); this._eventWait.WaitOne(); this.Controller.FileSystem.RemoveFile(filename); }
void UpdateStatus(HardwareStatus status, decimal scanPercentage = 0) { Status = status; OnHardwareStatusChange(status, scanPercentage); }
private static extern int BthGetHardwareStatus(ref HardwareStatus pistatus);
/// <summary> /// Creates a new Sensor class with hardware status to be 'Offline' as default /// </summary> public Sensor() { _hardwareStatus = HardwareStatus.Offline; }
/// <summary> /// Shutdown TCP client connections with the Raspberry Pi /// </summary> public void Shutdown() { try { //_tcpClient.Close(); _hardwareStatus = HardwareStatus.Offline; } catch (SocketException e) { _hardwareStatus = HardwareStatus.Failed; throw new Exception("Error: Unable to shutdown TCP client: " + e); } }
public void Shutdown() { Conveyor.shutdown(); _status = HardwareStatus.Offline; }
public SerialConveyor() { _status = HardwareStatus.Offline; }
/// <summary> /// Communicate with the TCP server (Raspberry Pi) to obtain sensory data information. /// The result is specific to the channel of the sensor as defined in setparameters() /// </summary> /// <returns>float: sensor data</returns> public float GetData() { float data = 0; try { _streamWriter.Write(this.Channel); _streamWriter.Flush(); // Flush WriterStream data to network stream (i.e. sending to Raspberry Pi) string result = null; result = _streamReader.ReadLine(); if (result != null) { float number; if (Single.TryParse(result, out number) ) { data = number; _hardwareStatus = HardwareStatus.Operational; } else { _hardwareStatus = HardwareStatus.Failed; throw new Exception("Error: The result is not a float"); } _hardwareStatus = HardwareStatus.Operational; if (data <= 0.63) { _hardwareStatus = HardwareStatus.Offline; } return data; } else { _hardwareStatus = HardwareStatus.Failed; return data; } } catch (Exception e) { Console.WriteLine("Error: Exception in getting data:" + e); _hardwareStatus = HardwareStatus.Failed; return data; } }
public BluetoothConveyor() { _serialPort = new SerialPort(); _status = HardwareStatus.Offline; this.Position = ConveyorPosition.Right; }
public void Shutdown() { if (_serialPort.IsOpen) { _serialPort.Close(); } _status = HardwareStatus.Offline; }
private void Manager_HandsetStateChanged(object sender, HardwareStatus e) { HandsetStateChanged?.Invoke(sender, e); }
/// <summary> /// Parse sensor configurations to sensor name, channel, IP address and Port number /// </summary> /// <param name="parameters"></param> public void SetParameters(Dictionary<string, string> parameters) { string s = ""; if (parameters.TryGetValue("Name", out s)) { this.Name = s; } if (parameters.TryGetValue("Channel", out s)) { this.Channel = s; } else { _hardwareStatus = HardwareStatus.Failed; throw new InvalidOperationException("Error: No sensor channel passed to sensors"); } if (parameters.TryGetValue("IPAddress", out s)) { this.IPAddress = s; } else { _hardwareStatus = HardwareStatus.Failed; throw new InvalidOperationException("Error: No connection IP address passed to sensors"); } if (parameters.TryGetValue("PortName", out s)) { this.PortName = s; } else { _hardwareStatus = HardwareStatus.Failed; throw new InvalidOperationException("Error: No connection Port number passed to sensors"); } }
private void ChangeAssemblyConveyorPictureBox(PictureBox pictureBox, HardwareStatus hardwareStatus) { switch (hardwareStatus) { case HardwareStatus.Offline: pictureBox.Image = Properties.Resources.assembly_conveyor_off; return; case HardwareStatus.Operational: pictureBox.Image = Properties.Resources.assembly_conveyor_on; return; case HardwareStatus.Failed: pictureBox.Image = Properties.Resources.assembly_conveyor_error; return; } }
/// <summary> /// Initialises the network connection between SCADA and Raspberry Pi server with the /// </summary> public void Initialise() { try { int number; if (Int32.TryParse(this.PortName, out number)) { _tcpClient = new TcpClient(this.IPAddress, number); } else { _hardwareStatus = HardwareStatus.Failed; throw new Exception("Error: Portname is not an integer on initialise"); } _networkStream = _tcpClient.GetStream(); _streamWriter = new StreamWriter(_networkStream); _streamReader = new StreamReader(_networkStream); _hardwareStatus = HardwareStatus.Operational; } catch (SocketException ex) { _hardwareStatus = HardwareStatus.Failed; throw new Exception("Error: Unable to initialise TCP client: " + ex); } }
public Image<Bgr, byte> GetImage() { var image = GetImageHttp(ConnectionString); if (image == null) { _hardwareStatus = HardwareStatus.Failed; throw new InvalidOperationException("Could not get image from capture device"); } return image; }
// Done! #region .Ctor // Done! internal HardwareHistoryItem(HardwareHistoryType actionType, HardwareActionStatus actionStatus, HardwareStatus status, float degrees, float speed, Vector heading) { this.ActionType = actionType; this.ActionStatus = actionStatus; this.Status = status; this.Degrees = degrees; this.Speed = speed; this.Heading = heading; }
//--- IBluetoothRadio TestRadioStates(RadioModes expectedModes, RadioMode expectedMode, HardwareStatus expectedStatus, Android.Bluetooth.State state, Android.Bluetooth.ScanMode scanMode) { var values = new AndroidMockValues { Radio_Address = "10:23:45:67:89:ab", Radio_Name = "radio2222", Radio_State = state, Radio_ScanMode = scanMode, }; var f = AndroidTestInfra.Init(values); var r = f.DoGetPrimaryRadio(); // Assert.AreEqual(expectedMode, r.Mode, "r.Mode"); Assert.AreEqual(expectedModes, r.Modes, "r.Modes"); Assert.AreEqual(expectedStatus, r.HardwareStatus, "r.HardwareStatus"); return(r); }
private static extern int BthGetHardwareStatus(ref HardwareStatus pistatus);
public virtual void Shutdown() { _status = HardwareStatus.Offline; this.ReturnToHomePosition(); }
void UpdateStatus(HardwareStatus s, decimal percentage) { if (percentage > 0) status.Text = string.Format("{0} ({1:F0}% complete)", s, percentage); else status.Text = s.ToString(); switch (s) { case HardwareStatus.Initializing: propertyGrid.Enabled = true; startButton.Enabled = false; startButton.Visible = true; stopButton.Enabled = false; stopButton.Visible = false; reinitializeButton.Enabled = false; reinitializeButton.Visible = false; status.ForeColor = Color.Gray; break; case HardwareStatus.Error: propertyGrid.Enabled = true; startButton.Enabled = false; startButton.Visible = false; stopButton.Enabled = false; stopButton.Visible = false; reinitializeButton.Enabled = true; reinitializeButton.Visible = true; status.ForeColor = Color.Red; break; case HardwareStatus.Idle: propertyGrid.Enabled = true; startButton.Enabled = true; startButton.Visible = true; stopButton.Enabled = false; stopButton.Visible = false; reinitializeButton.Enabled = false; reinitializeButton.Visible = false; status.ForeColor = Color.Black; break; case HardwareStatus.Homing: propertyGrid.Enabled = false; startButton.Enabled = false; startButton.Visible = false; stopButton.Enabled = false; stopButton.Visible = true; reinitializeButton.Enabled = false; reinitializeButton.Visible = false; status.ForeColor = Color.Blue; break; case HardwareStatus.Scanning: propertyGrid.Enabled = false; startButton.Enabled = false; startButton.Visible = false; stopButton.Enabled = true; stopButton.Visible = true; reinitializeButton.Enabled = false; reinitializeButton.Visible = false; status.ForeColor = Color.Green; break; } }
internal BaseRobot() { _status = HardwareStatus.Offline; }
internal static extern int BthGetHardwareStatus(ref HardwareStatus pistatus);
public Camera() { _hardwareStatus = HardwareStatus.Offline; HSVColorRanges = new Hsv[5, 2]; }
private void ChangeRobotPictureBox(PictureBox pictureBox, HardwareStatus hardwareStatus) { switch (hardwareStatus) { case HardwareStatus.Offline: pictureBox.Image = Properties.Resources.robot_off; return; case HardwareStatus.Operational: pictureBox.Image = Properties.Resources.robot_on; return; case HardwareStatus.Failed: pictureBox.Image = Properties.Resources.robot_error; return; } }
public void Shutdown() { //this._plc.Disconnect(); this._hwStatus = HardwareStatus.Offline; }
public static HardwareStatus FromDictionary(this HardwareStatus status, IDictionary <string, string> dict) { if (dict.TryGetValue(Constants.DMC_SERVER_HELLO, out var timeStr)) { try { status.Time = DateTime.Parse(timeStr); } catch (FormatException) { } } if (dict.TryGetValue(Constants.DMC_MAX_BYTES_PER_BLOCK, out var bytes)) { status.MaxBytes = int.Parse(bytes); } // ADC if (dict.TryGetValue(Constants.DMC_Primary_ADC_Connected, out var primaryAdc)) { status.ADC.PrimaryConnected = primaryAdc.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Virtual_Primary_ADC, out var vPrimaryAdc)) { status.ADC.PrimaryVirtualConnected = vPrimaryAdc.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Secondary_ADC_Connected, out var secondaryADC)) { status.ADC.SecondaryConnected = secondaryADC.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Virtual_Secondary_ADC, out var vSecondaryAdc)) { status.ADC.SecondaryVirtualConnected = vSecondaryAdc.Trim().Equals("1"); } // PMT if (dict.TryGetValue(Constants.DMC_Primary_PMT_Bias_Control_Connected, out var primaryPMT)) { status.PMT.PrimaryConnected = primaryPMT.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Virtual_Primary_PMT_Bias_Control, out var vPrimaryPMT)) { status.PMT.PrimaryVirtualConnected = vPrimaryPMT.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Secondary_PMT_Bias_Control_Connected, out var secondaryPMT)) { status.PMT.SecondaryConnected = secondaryPMT.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Virtual_Secondary_PMT_Bias_Control, out var vSecondaryPMT)) { status.PMT.SecondaryVirtualConnected = vSecondaryPMT.Trim().Equals("1"); } // DDS if (dict.TryGetValue(Constants.DMC_Virtual_Primary_DDS_System, out var primaryDDS)) { status.DDS.PrimaryConnected = primaryDDS.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Virtual_Primary_DDS_System, out var vPrimaryDDS)) { status.DDS.PrimaryVirtualConnected = vPrimaryDDS.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Secondary_DDS_System_Connected, out var secondaryDDS)) { status.DDS.SecondaryConnected = secondaryDDS.Trim().Equals("1"); } if (dict.TryGetValue(Constants.DMC_Virtual_Secondary_DDS_System, out var vSecondaryDDS)) { status.DDS.SecondaryVirtualConnected = vSecondaryDDS.Trim().Equals("1"); } return(status); }
public void Initialise() { try { this._plc = CreatePlcControl(); } catch (Exception ex) { this._hwStatus = HardwareStatus.Failed; throw new Exception("PLC initialisation failed", ex); } this._hwStatus = HardwareStatus.Operational; }
private void Manager_LcdButtonChange(object sender, HardwareStatus e) { LcdButtonChange?.Invoke(this, e); }