public IHttpActionResult GetDeviceList()
 {
     try
     {
         return(Ok(ConfigurationAccess.GetDeviceListFromConfig()));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult GetDevice(String id)
 {
     try
     {
         List <Device> devices = ConfigurationAccess.GetDeviceListFromConfig();
         return(Ok(DeviceListHandler.GetDeviceFromDeviceList(devices, id)));
     }
     catch (ReadWriteException ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult DeleteDevice(String id)
 {
     try
     {
         List <Device> devices      = ConfigurationAccess.GetDeviceListFromConfig();
         List <Device> modifiedList = DeviceListHandler.DeleteDeviceInDeviceList(devices, id);
         ConfigurationAccess.SaveDeviceListToConfig(modifiedList);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult SaveDevice([FromBody] Device newDevice)
 {
     try
     {
         List <Device> devices      = ConfigurationAccess.GetDeviceListFromConfig();
         List <Device> savedDevices = DeviceListHandler.SaveNewDeviceInDeviceList(devices, newDevice);
         ConfigurationAccess.SaveDeviceListToConfig(savedDevices);
         return(Ok());
     }
     catch (ReadWriteException ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public IHttpActionResult UpdateDevice([FromBody] Device updatedDevice)
 {
     try
     {
         List <Device> devicesInConfig = ConfigurationAccess.GetDeviceListFromConfig();
         List <Device> updatedList     = DeviceListHandler.UpdateDeviceInDeviceList(devicesInConfig, updatedDevice);
         ConfigurationAccess.SaveDeviceListToConfig(updatedList);
         return(Ok());
     }
     catch (ReadWriteException ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#6
0
 public IHttpActionResult GetMeasurementValue(String id)
 {
     try
     {
         List <Device> devices      = ConfigurationAccess.GetDeviceListFromConfig();
         Device        deviceToRead = DeviceListHandler.GetDeviceFromDeviceList(devices, id);
         String        actualValue  = MeasurementValueReader.GetActualMeasurementValue(deviceToRead);
         return(Ok(Double.Parse(actualValue)));
     }
     catch (ReadWriteException ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#7
0
        public IHttpActionResult SetValueZero(String id)

        {
            try
            {
                List <Device> devices      = ConfigurationAccess.GetDeviceListFromConfig();
                Device        deviceToRead = DeviceListHandler.GetDeviceFromDeviceList(devices, id);
                String        handShake    = new SylcvacComAccess().SetActualValueToZero(deviceToRead);
                return(Ok(handShake));
            }
            catch (ReadWriteException ex)
            {
                return(BadRequest(ex.Message));
            }
        }