Update Broker
This commit is contained in:
@@ -34,9 +34,20 @@ namespace PlantBox.Broker
|
||||
|
||||
protected override void HistoricCommand(CommandStream commandStream, CommandPacket packet)
|
||||
{
|
||||
double[] FillArray(double[] values, int length)
|
||||
{
|
||||
var array = new double[length];
|
||||
int startIndex = length - values.Length;
|
||||
|
||||
values.CopyTo(array, startIndex);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
HistoricRequest historicRequest = new HistoricRequest().Deserialize(packet.Arguments);
|
||||
ulong id = packet.ID;
|
||||
PlantBox plantBox = Broker.PlantBoxesManager[id];
|
||||
int count = historicRequest.Number;
|
||||
|
||||
if (plantBox == null)
|
||||
{
|
||||
@@ -70,9 +81,9 @@ namespace PlantBox.Broker
|
||||
var response = new HistoricResponse
|
||||
(
|
||||
DateTime.Now - plantBox.LastMeasureDate,
|
||||
captorsValues.Select(x => x.Humidity).ToArray(),
|
||||
captorsValues.Select(x => x.Luminosity).ToArray(),
|
||||
captorsValues.Select(x => x.Temperature).ToArray()
|
||||
FillArray(captorsValues.Select(x => x.Humidity).ToArray(), count),
|
||||
FillArray(captorsValues.Select(x => x.Luminosity).ToArray(), count),
|
||||
FillArray(captorsValues.Select(x => x.Temperature).ToArray(), count)
|
||||
);
|
||||
commandStream.Send(response.ToCommandPacket(id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user