/// <summary> /// Implicit constructor /// </summary> public MainController() { Actuators = new Actuators(); ActuatorInContext = new ActuatorController(); actuatorErrorHandler = new ActuatorErrorHandler(this); logController = new LogController(); notifList = new List <Notification>(); isFirstTimeLaunch = true; InitActuators(); InitBgWorkers(); }
/// <summary> /// Calls Controller.Actuators.InitializeActuators() from constructor Controller.MainController() in order to initialize actuators /// </summary> public void InitActuators() { Actuators.InitializeActuators(); if (Actuators.Count > 0) { ChangeContext(); } else { logController.LogMultipleActuatorsError(Enums.MultipleActuatorsLog.NoDevicesFound); } }
/// <summary> /// Deprecated /// </summary> /// <returns></returns> // TO DELETE public bool HasActuatorCountReduced() { Actuators.EnumerateActuators(true); if (Actuators.Count > Actuators.GetDeviceCountNoOverwrite()) { return(true); } else { return(false); } }
/// <summary> /// Deprecated. Thread used to check for the disconnection of actuators during runtime /// </summary> /// <param name="obj"></param> /// <param name="e"></param> // TO DO - CHANGE void bgWorkerPollForActuatorsChanged(object obj, ProgressChangedEventArgs e) { Actuators.EnumerateActuators(); // If new actuator detected if (Actuators.Count < Actuators.GetDeviceCountNoOverwrite()) { //gWorkerErrorPolling.CancelAsync(); Actuators = new Actuators(); Actuators.InitializeActuators(); API.open_device(API.get_device_name(API.enumerate_devices(0, ""), 0)); Actuators.EnumerateActuators(); // Update new device count and get list index value int newIndex = Actuators.GetDeviceCount() - 1; // Add to list new actuator Actuators.List.Add(new ActuatorController(newIndex)); // Get new actuator's name Actuators.List[newIndex].DeviceName = Actuators.List[newIndex].GetDeviceName(Actuators.ActuatorEnumeration, newIndex); // Get new actuator's ID & open Actuators.List[newIndex].DeviceID = Actuators.List[newIndex].OpenDevice(Actuators.List[newIndex].DeviceName); // Get all of its info Actuators.List[newIndex].GetActuatorInformation(Actuators.List[newIndex].DeviceID); // Close new actuator Actuators.List[newIndex].CloseDevice(ref newIndex); //actuators.ProcessNewActuator(); //bgWorkerErrorPolling.RunWorkerAsync(); // Update UI somehow } }
/// <summary> /// Deprecated /// </summary> // TO DELETE public void DisconnectActuator() { Actuators.RemoveActuatorFromList(); ActuatorInContext.DeviceID = -1; }
/// <summary> /// Deprecated /// </summary> /// <returns></returns> // TO DELETE public int GetNewActuatorCount() { return(Actuators.GetDeviceCount()); }