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