Skip to content

Commit

Permalink
update client
Browse files Browse the repository at this point in the history
  • Loading branch information
pehladik committed Nov 7, 2018
1 parent e723f72 commit 2c6d2fe
Show file tree
Hide file tree
Showing 18 changed files with 1,085 additions and 388 deletions.
3 changes: 1 addition & 2 deletions raspberry/TestUI/.vs/TestUI/xs/UserPrefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<MonoDevelop.Ide.Workbench ActiveDocument="TestUI/MainWindow.cs">
<Files>
<File FileName="TestUI/Program.cs" Line="13" Column="31" />
<File FileName="TestUI/MainWindow.cs" Line="58" Column="25" />
<File FileName="TestUI/Client.cs" Line="1" Column="1" />
<File FileName="TestUI/MainWindow.cs" Line="7" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
Expand Down
Binary file modified raspberry/TestUI/.vs/TestUI/xs/sqlite3/storage.ide
Binary file not shown.
Binary file modified raspberry/TestUI/.vs/TestUI/xs/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified raspberry/TestUI/.vs/TestUI/xs/sqlite3/storage.ide-wal
Binary file not shown.
145 changes: 0 additions & 145 deletions raspberry/TestUI/TestUI/Client.cs

This file was deleted.

75 changes: 57 additions & 18 deletions raspberry/TestUI/TestUI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected void OnHscale4ValueChanged(object sender, EventArgs e)
nwStream.Write(bytes, 0, bytes.Length);
}

protected async void OnBtconnectClicked(object sender, EventArgs e)
protected void OnBtconnectClicked(object sender, EventArgs e)
{
try
{
Expand All @@ -40,34 +40,73 @@ protected async void OnBtconnectClicked(object sender, EventArgs e)
// Send initial speed value
byte[] bytes = Encoding.ASCII.GetBytes("SPE" + hscale4.Value.ToString());
nwStream.Write(bytes, 0, bytes.Length);
Receive();


while(clientSocket.Connected){
byte[] myReadBuffer = new byte[20];
await nwStream.ReadAsync(myReadBuffer, 0, myReadBuffer.Length);
String st = Encoding.UTF8.GetString(myReadBuffer);
String[] elt = st.Split(':');
switch (elt[0]){
}
catch (SocketException ex)
{
btconnect.Label = "Failed to connect";
Console.WriteLine(ex.Message);
}
}

async void Receive(){
while (clientSocket.Connected)
{
byte[] myReadBuffer = new byte[20];
await nwStream.ReadAsync(myReadBuffer, 0, myReadBuffer.Length);
String st = Encoding.UTF8.GetString(myReadBuffer);
String[] msgs = st.Split(';');

foreach (String msg in msgs){
String[] elt = msg.Split(':');
switch (elt[0])
{
case "UFL":
USFL.Text = elt[1];
USFL.LabelProp = elt[1];
break;
case "UFC":
USFC.LabelProp = elt[1];
break;
case "UFR":
USFR.Text = elt[1];
USFR.LabelProp = elt[1];
break;
case "URL":
USRL.LabelProp = elt[1];
break;
case "URC":
USFC.Text = elt[1];
USRC.LabelProp = elt[1];
break;
case "URR":
USRR.LabelProp = elt[1];
break;
case "POS":
ePOS.Text = elt[1];
break;
case "BAT":
eBAT.Text = elt[1];
break;
case "SWL":
eSPL.Text = elt[1];
break;
case "SWR":
eSPR.Text = elt[1];
break;
case "YAW":
eYAW.Text = elt[1];
break;
case "ROL":
eROL.Text = elt[1];
break;
case "PIT":
ePIT.Text = elt[1];
break;
}



}
}
catch (SocketException ex)
{
btconnect.Label = "Failed to connect";
Console.WriteLine(ex.Message);
}


}

protected void OnButton1Clicked(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion raspberry/TestUI/TestUI/TestUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
<EmbeddedResource Include="gtk-gui\gui.stetic">
<LogicalName>gui.stetic</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="voiture.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="gtk-gui\generated.cs" />
<Compile Include="MainWindow.cs" />
<Compile Include="gtk-gui\MainWindow.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Client.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
Binary file removed raspberry/TestUI/TestUI/bin/Debug/TestUI.exe
Binary file not shown.
Binary file removed raspberry/TestUI/TestUI/bin/Debug/TestUI.pdb
Binary file not shown.
Loading

0 comments on commit 2c6d2fe

Please sign in to comment.