using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Maser.Feanor.Model; using Maser.Feanor.Biz; namespace Maser.Feanor.Server { public abstract class Server { public List Results { get { return _Results; } set { _Results = value; } } protected List _Results; public Chamber Chamber { get { return _chamber; } set { _chamber = value; } } protected Chamber _chamber; protected List _Sensors = new List(); // Sensors are retrieved from DB in constructor protected List _Calibrations = new List(); // Calibrations are retrieved from DB in constructor public abstract Boolean Read(); public abstract Boolean WriteDatetime(DateTime dt); public abstract Boolean WriteInterval(Int32 Interval); public abstract Boolean ModifySensor(Sensor sensor, Calibration calibration); public abstract Boolean WriteSensors(); public Server(Chamber Chamber) { _chamber = Chamber; // Get list of sensors from database and current calibration try { SetSensorsAndCalibrations(); } catch(Exception ex) { throw ex; #warning What to do if the sensors or calibrations are not found while creating server? } } public void SetSensorsAndCalibrations() { // Get list of sensors from database and current calibration _Sensors = new Sensors().GetByChamber(_chamber.PK); _Calibrations = new List(); foreach (Sensor sensor in _Sensors) { Calibration c = new Calibrations().GetLastCreatedBySensorPK(sensor.PK); if (c != null) _Calibrations.Add(c); } } public String URL { get { return @"http://" + _chamber.Network + ":8080/"; } } public abstract List StandardSensors(); // The sensor with lowest ID is exported as primary sensor } }