Try to fix client
This commit is contained in:
@@ -2,6 +2,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="fr.ilyx.PlantBox.Client.Android" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
|
||||
<application android:label="PlantBox" android:icon="@mipmap/ic_launcher"></application>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
</manifest>
|
||||
@@ -7,6 +7,7 @@ using System.ComponentModel;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlantBox.Client.ViewModels
|
||||
@@ -122,38 +123,54 @@ namespace PlantBox.Client.ViewModels
|
||||
|
||||
private void LoadValues()
|
||||
{
|
||||
CaptorValue humidityCaptor;
|
||||
CaptorValue luminosityCaptor;
|
||||
CaptorValue temperatureCaptor;
|
||||
double tankValue;
|
||||
HistoricResponse minutelyHistoric;
|
||||
HistoricResponse hourlyHistoric;
|
||||
HistoricResponse dailyHistoric;
|
||||
HistoricResponse monthlyHistoric;
|
||||
|
||||
using (var client = new TcpClient(App.Settings.BrokerIP, Connection.TCP_CLIENT_PORT))
|
||||
using (var stream = new CommandStream(client.GetStream()))
|
||||
{
|
||||
|
||||
// Captors info
|
||||
stream.Send(new CaptorsRequest().ToCommandPacket(PlantInfo.ID));
|
||||
(_, var captorsReponse) = stream.Receive<CaptorsResponse>();
|
||||
|
||||
HumidityCaptor = new CaptorValue(PlantInfo.HumidityMin, PlantInfo.HumidityMax, captorsReponse.Humidity);
|
||||
LuminosityCaptor = new CaptorValue(PlantInfo.LuminosityMin, PlantInfo.LuminosityMax, captorsReponse.Luminosity);
|
||||
TemperatureCaptor = new CaptorValue(PlantInfo.TemperatureMin, PlantInfo.TemperatureMax, captorsReponse.Temperature);
|
||||
TankValue = captorsReponse.Tank;
|
||||
humidityCaptor = new CaptorValue(PlantInfo.HumidityMin, PlantInfo.HumidityMax, captorsReponse.Humidity);
|
||||
luminosityCaptor = new CaptorValue(PlantInfo.LuminosityMin, PlantInfo.LuminosityMax, captorsReponse.Luminosity);
|
||||
temperatureCaptor = new CaptorValue(PlantInfo.TemperatureMin, PlantInfo.TemperatureMax, captorsReponse.Temperature);
|
||||
tankValue = captorsReponse.Tank;
|
||||
|
||||
// Historic
|
||||
stream.Send(new HistoricRequest(HistoricInterval.Minutely, 12).ToCommandPacket(PlantInfo.ID));
|
||||
(_, var minutelyHistoric) = stream.Receive<HistoricResponse>();
|
||||
stream.Send(new HistoricRequest(HistoricInterval.Hourly, 48).ToCommandPacket(PlantInfo.ID));
|
||||
(_, var hourlyHistoric) = stream.Receive<HistoricResponse>();
|
||||
stream.Send(new HistoricRequest(HistoricInterval.Daily, 186).ToCommandPacket(PlantInfo.ID));
|
||||
(_, var dailyHistoric) = stream.Receive<HistoricResponse>();
|
||||
stream.Send(new HistoricRequest(HistoricInterval.Monthly, 36).ToCommandPacket(PlantInfo.ID));
|
||||
(_, var monthlyHistoric) = stream.Receive<HistoricResponse>();
|
||||
(_, minutelyHistoric) = stream.Receive<HistoricResponse>();
|
||||
|
||||
var historic = new Historic
|
||||
(
|
||||
new HistoricEntries(minutelyHistoric, TimeSpan.FromMinutes(5)),
|
||||
new HistoricEntries(hourlyHistoric, TimeSpan.FromHours(1)),
|
||||
new HistoricEntries(dailyHistoric, TimeSpan.FromDays(1)),
|
||||
new HistoricEntries(monthlyHistoric, TimeSpan.FromDays(31))
|
||||
);
|
||||
Historic = historic;
|
||||
stream.Send(new HistoricRequest(HistoricInterval.Hourly, 48).ToCommandPacket(PlantInfo.ID));
|
||||
(_, hourlyHistoric) = stream.Receive<HistoricResponse>();
|
||||
|
||||
stream.Send(new HistoricRequest(HistoricInterval.Daily, 186).ToCommandPacket(PlantInfo.ID));
|
||||
(_, dailyHistoric) = stream.Receive<HistoricResponse>();
|
||||
|
||||
stream.Send(new HistoricRequest(HistoricInterval.Monthly, 36).ToCommandPacket(PlantInfo.ID));
|
||||
(_, monthlyHistoric) = stream.Receive<HistoricResponse>();
|
||||
}
|
||||
|
||||
HumidityCaptor = humidityCaptor;
|
||||
LuminosityCaptor = luminosityCaptor;
|
||||
TemperatureCaptor = temperatureCaptor;
|
||||
TankValue = tankValue;
|
||||
|
||||
var historic = new Historic
|
||||
(
|
||||
new HistoricEntries(minutelyHistoric, TimeSpan.FromMinutes(5)),
|
||||
new HistoricEntries(hourlyHistoric, TimeSpan.FromHours(1)),
|
||||
new HistoricEntries(dailyHistoric, TimeSpan.FromDays(1)),
|
||||
new HistoricEntries(monthlyHistoric, TimeSpan.FromDays(31))
|
||||
);
|
||||
Historic = historic;
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
|
||||
Reference in New Issue
Block a user