diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-08-06 13:03:05 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-08-06 13:03:05 +0300 |
| commit | 88407c1927faeabcec2b9c2699d657eb5723bc81 (patch) | |
| tree | 210f0877e20b401017b5f460e7f2f72dea8e91f8 /Software/Visual_Studio/Tango.Emulations | |
| parent | f9e3fb301b8b94529f14c8c3291d430cad5d71db (diff) | |
| download | Tango-88407c1927faeabcec2b9c2699d657eb5723bc81.tar.gz Tango-88407c1927faeabcec2b9c2699d657eb5723bc81.zip | |
Refactored data store to use DataStoreMessageType.
Diffstat (limited to 'Software/Visual_Studio/Tango.Emulations')
| -rw-r--r-- | Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index ab007329f..9d486c8e0 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -2147,7 +2147,7 @@ namespace Tango.Emulations.Emulators { DataType = DataType.Proto, BytesValue = new CalculateRequest() { A = 10, B = 15 }.ToByteString(), - ProtoType = MessageType.CalculateRequest, + ProtoType = DataStoreMessageType.CalculateRequest, } }); @@ -2214,7 +2214,7 @@ namespace Tango.Emulations.Emulators { DataType = DataType.Proto, BytesValue = (new CalculateRequest() { A = 10, B = 15 }).ToByteString(), - ProtoType = MessageType.CalculateRequest, + ProtoType = DataStoreMessageType.CalculateRequest, }, }); @@ -2249,7 +2249,25 @@ namespace Tango.Emulations.Emulators try { var response = await Transporter.SendRequest<GetDataStoreItemRequest, GetDataStoreItemResponse>(request); - LogManager.Log($"Received GetDataStoreItemResponse:\n{response.Message.ToJsonString()}"); + + String protoJson = String.Empty; + + try + { + if (response.Message.Item.DataType == DataType.Proto) + { + var type = MessageFactory.GetDataStorePMRTypeFromDataStoreMessageType(response.Message.Item.ProtoType); + var instance = MessageFactory.ParseProtoMessage(response.Message.Item.BytesValue.ToByteArray(), type); + protoJson = instance.ToJsonString(); + } + } + catch (Exception ex) + { + protoJson = ex.Message; + } + + LogManager.Log($"Received GetDataStoreItemResponse:\n{response.Message.ToJsonString()}\nProtobuf Message:\n{protoJson}"); + } catch (Exception ex) { |
