Add project files.
This commit is contained in:
79
Server/Server.Base.cs
Normal file
79
Server/Server.Base.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
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<Result> Results { get { return _Results; } set { _Results = value; } }
|
||||
protected List<Result> _Results;
|
||||
|
||||
public Chamber Chamber { get { return _chamber; } set { _chamber = value; } }
|
||||
protected Chamber _chamber;
|
||||
|
||||
|
||||
|
||||
protected List<Sensor> _Sensors = new List<Sensor>(); // Sensors are retrieved from DB in constructor
|
||||
protected List<Calibration> _Calibrations = new List<Calibration>(); // 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<Calibration>();
|
||||
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<Sensor> StandardSensors(); // The sensor with lowest ID is exported as primary sensor
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user