aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2018-01-02 23:06:26 +0200
committerRoy <roy.mail.net@gmail.com>2018-01-02 23:06:26 +0200
commit06071e5417fb3353702fd4c4c3da5b8fa7caa804 (patch)
tree85dad724eff2f14e55007dfdc52c83bd5322206b /Software/Visual_Studio
parent0ab7e3d35c01eaaa6ebf03225971909bea365597 (diff)
downloadTango-06071e5417fb3353702fd4c4c3da5b8fa7caa804.tar.gz
Tango-06071e5417fb3353702fd4c4c3da5b8fa7caa804.zip
Allegedly improved USB adapter on C# on PREPEND_HEADER mode. (tested !)
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs14
-rw-r--r--Software/Visual_Studio/Tango.Stubs/Stubs/BigData.cs47
-rw-r--r--Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj1
-rw-r--r--Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs15
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs2
5 files changed, 69 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
index a41501f7f..59de23f82 100644
--- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
+++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
@@ -13,6 +13,7 @@ using Tango.PMR.Common;
using Tango.PMR.Stubs;
using Tango.Core.Commands;
using Tango.Transport;
+using Tango.PMR.Integration;
namespace Tango.Emulations.Emulators
{
@@ -63,7 +64,7 @@ namespace Tango.Emulations.Emulators
var r = MessageFactory.ParseMessageFromContainer<ProgressRequest>(container);
- Task.Factory.StartNew(() =>
+ Task.Factory.StartNew(() =>
{
for (int i = 0; i < r.Amount; i++)
{
@@ -76,10 +77,19 @@ namespace Tango.Emulations.Emulators
Transporter.SendResponse(res);
}
});
+ break;
+ case MessageType.DirectSynchronizationRequest:
+ Task.Factory.StartNew(() =>
+ {
+ var request = MessageFactory.ParseMessageFromContainer<DirectSynchronizationRequest>(container);
+ var response = MessageFactory.CreateTangoMessage<DirectSynchronizationResponse>(container.Token);
+ response.Message.LocalDB = ByteString.CopyFrom(new byte[1024 * 1024 * 10]);
+ Transporter.SendResponse(response);
+ });
break;
}
- }
+ }
#endregion
}
diff --git a/Software/Visual_Studio/Tango.Stubs/Stubs/BigData.cs b/Software/Visual_Studio/Tango.Stubs/Stubs/BigData.cs
new file mode 100644
index 000000000..a0d84558b
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Stubs/Stubs/BigData.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+using Tango.Logging;
+using Tango.PMR;
+using Tango.PMR.Integration;
+using Tango.PMR.Stubs;
+using Tango.Transport;
+
+namespace Tango.Stubs.Stubs
+{
+ [Stub("Big Data", "Sends a lot of bytes.", StubDirection.Both)]
+ public class BigData : StubBase
+ {
+ public BigData(ITransporter transporter) : base(transporter)
+ {
+ }
+
+ [ParameterItem(Minimum = null, Maximum = null)]
+ public double NumberA { get; set; }
+
+ [ParameterItem(Minimum = null, Maximum = null)]
+ public double NumberB { get; set; }
+
+ protected async override Task<string> OnRun(Action<String> multiResponseCallback)
+ {
+ try
+ {
+ var response = await Transporter.SendRequest<DirectSynchronizationRequest, DirectSynchronizationResponse>(
+ new DirectSynchronizationRequest()
+ {
+
+ }
+ );
+
+ return response.Message.LocalDB.Length.ToString();
+ }
+ catch (Exception ex)
+ {
+ return ex.Message;
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj b/Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj
index 541119a44..c21f1d40a 100644
--- a/Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj
+++ b/Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj
@@ -68,6 +68,7 @@
<Compile Include="IStub.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StubDirection.cs" />
+ <Compile Include="Stubs\BigData.cs" />
<Compile Include="Stubs\Progress.cs" />
<Compile Include="Stubs\Calculate.cs" />
<Compile Include="StubAttribute.cs" />
diff --git a/Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs b/Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs
index a97f55ee6..e433d9498 100644
--- a/Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs
+++ b/Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs
@@ -20,7 +20,7 @@ namespace Tango.Transport.Adapters
/// <summary>
/// Initializes a new instance of the <see cref="UsbTransportAdapter"/> class.
/// </summary>
- public UsbTransportAdapter()
+ public UsbTransportAdapter() : base()
{
Address = "COM1";
}
@@ -29,7 +29,7 @@ namespace Tango.Transport.Adapters
/// Initializes a new instance of the <see cref="UsbTransportAdapter"/> class.
/// </summary>
/// <param name="portName">The COM.</param>
- public UsbTransportAdapter(String portName) : base()
+ public UsbTransportAdapter(String portName) : this()
{
Address = portName;
}
@@ -139,7 +139,6 @@ namespace Tango.Transport.Adapters
try
{
if (e.EventType == SerialData.Eof) return;
- Thread.Sleep(10);
if (AdapterMode == TransportAdapterMode.NO_HEADER)
{
@@ -152,14 +151,17 @@ namespace Tango.Transport.Adapters
if (_serialPort.BytesToRead > 4)
{
byte[] size = new byte[4];
- _serialPort.Read(size, 0, size.Length);
+ _serialPort.Read(size, 0, size.Length);
int expectedSize = BitConverter.ToInt32(size, 0);
byte[] data = new byte[expectedSize];
+ int read = 0;
- while (_serialPort.BytesToRead < expectedSize)
+ while (read < expectedSize)
{
- Thread.Sleep(10);
+ read += _serialPort.Read(data, read, Math.Min(_serialPort.BytesToRead, expectedSize - read));
+
+ Thread.Sleep(2);
if (State != TransportComponentState.Connected)
{
@@ -167,7 +169,6 @@ namespace Tango.Transport.Adapters
}
}
- _serialPort.Read(data, 0, data.Length);
OnDataAvailable(data);
}
}
diff --git a/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs
index fc953a2fa..306da384f 100644
--- a/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs
+++ b/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/App.xaml.cs
@@ -21,7 +21,7 @@ namespace Tango.MobileEM.UI
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
- Emulator = new MobileEmulator(new ProtoTransporter(new TcpTransportAdapter("127.0.0.1",9999)));
+ Emulator = new MobileEmulator(new ProtoTransporter(new UsbTransportAdapter("COM2")));
}
}
}