diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-23 03:13:09 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-23 03:13:09 +0300 |
| commit | 8d2b13aaa70bc6a8f521df4eab165caf078c33fa (patch) | |
| tree | 325567b00d55fa751da7492be067e7878b132e28 | |
| parent | a79900d579ae9f624b35aa933784e4e0f0c65d03 (diff) | |
| download | Tango-8d2b13aaa70bc6a8f521df4eab165caf078c33fa.tar.gz Tango-8d2b13aaa70bc6a8f521df4eab165caf078c33fa.zip | |
DataStore Improvements.
17 files changed, 286 insertions, 115 deletions
diff --git a/Software/PMR/Messages/DataStore/DataStoreItem.proto b/Software/PMR/Messages/DataStore/DataStoreItem.proto index 5f3ce7027..f516fa92c 100644 --- a/Software/PMR/Messages/DataStore/DataStoreItem.proto +++ b/Software/PMR/Messages/DataStore/DataStoreItem.proto @@ -7,12 +7,11 @@ option java_package = "com.twine.tango.pmr.datastore"; message DataStoreItem { - string Key = 1; - DataType DataType = 2; - int32 Int32Value = 3; - float FloatValue = 4; - double DoubleValue = 5; - bool BooleanValue = 6; - string StringValue = 7; - bytes BytesValue = 8; + DataType DataType = 1; + int32 Int32Value = 2; + float FloatValue = 3; + double DoubleValue = 4; + bool BooleanValue = 5; + string StringValue = 6; + bytes BytesValue = 7; }
\ No newline at end of file diff --git a/Software/PMR/Messages/DataStore/GetDataStoreItemRequest.proto b/Software/PMR/Messages/DataStore/GetDataStoreItemRequest.proto index 097dfe97e..07d0cec47 100644 --- a/Software/PMR/Messages/DataStore/GetDataStoreItemRequest.proto +++ b/Software/PMR/Messages/DataStore/GetDataStoreItemRequest.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "DataStoreItem.proto"; + package Tango.PMR.DataStore; option java_package = "com.twine.tango.pmr.datastore"; @@ -7,4 +9,5 @@ message GetDataStoreItemRequest { string Collection = 1; string Key = 2; + DataStoreItem DefaultItem = 3; }
\ No newline at end of file diff --git a/Software/PMR/Messages/DataStore/GetDataStoreItemResponse.proto b/Software/PMR/Messages/DataStore/GetDataStoreItemResponse.proto index 1df920f08..9445a6fd9 100644 --- a/Software/PMR/Messages/DataStore/GetDataStoreItemResponse.proto +++ b/Software/PMR/Messages/DataStore/GetDataStoreItemResponse.proto @@ -7,5 +7,6 @@ option java_package = "com.twine.tango.pmr.datastore"; message GetDataStoreItemResponse { - DataStoreItem Item = 1; + string Key = 1; + DataStoreItem Item = 2; }
\ No newline at end of file diff --git a/Software/PMR/Messages/DataStore/PutDataStoreItemRequest.proto b/Software/PMR/Messages/DataStore/PutDataStoreItemRequest.proto index 746c8340e..e4dcb979c 100644 --- a/Software/PMR/Messages/DataStore/PutDataStoreItemRequest.proto +++ b/Software/PMR/Messages/DataStore/PutDataStoreItemRequest.proto @@ -8,5 +8,6 @@ option java_package = "com.twine.tango.pmr.datastore"; message PutDataStoreItemRequest { string Collection = 1; - DataStoreItem Item = 2; + string Key = 2; + DataStoreItem Item = 3; }
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/RemoteDataStoreCollection.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/RemoteDataStoreCollection.cs index b7325cd48..cb49c667d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/RemoteDataStoreCollection.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/RemoteDataStoreCollection.cs @@ -44,15 +44,26 @@ namespace Tango.FSE.UI.DataStore public T Get<T>(string key) { - return (T)Convert.ChangeType(Get(key), typeof(T)); + return (T)Convert.ChangeType(Get(key, null), typeof(T)); + } + + public T Get<T>(string key, T defaultValue) + { + return (T)Convert.ChangeType(Get(key, (object)defaultValue), typeof(T)); } public object Get(string key) { + return Get(key, null); + } + + public object Get(string key, object defaultValue) + { var result = _machineProvider.MachineOperator.SendGenericRequest<RemoteDataStoreGetRequest, RemoteDataStoreGetResponse>(new RemoteDataStoreGetRequest() { Collection = Name, - Key = key + Key = key, + DefaultValue = defaultValue }).Result; return result.Value; @@ -97,10 +108,16 @@ namespace Tango.FSE.UI.DataStore public IDataStoreItem GetItem(string key) { + return GetItem(key, null); + } + + public IDataStoreItem GetItem(string key, object defaultValue) + { var result = _machineProvider.MachineOperator.SendGenericRequest<RemoteDataStoreGetItemRequest, RemoteDataStoreGetItemResponse>(new RemoteDataStoreGetItemRequest() { Collection = Name, - Key = key + Key = key, + DefaultValue = defaultValue }).Result; return result.Item; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs index e5bec90f2..e6da8e8e7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs @@ -58,7 +58,7 @@ namespace Tango.PPC.Common.DataStore [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreGetRequest), RequestHandlerLoggingMode.LogRequestName)] public async Task OnRemoteDataStoreGetRequest(RemoteDataStoreGetRequest request, String token, ExternalBridgeReceiver receiver) { - var value = GetManager().GetCollection(request.Collection).Get(request.Key); + var value = GetManager().GetCollection(request.Collection).Get(request.Key, request.DefaultValue); await receiver.SendGenericResponse(new RemoteDataStoreGetResponse() { Value = value @@ -68,7 +68,7 @@ namespace Tango.PPC.Common.DataStore [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreGetItemRequest), RequestHandlerLoggingMode.LogRequestName)] public async Task OnRemoteDataStoreGetItemRequest(RemoteDataStoreGetItemRequest request, String token, ExternalBridgeReceiver receiver) { - var item = GetManager().GetCollection(request.Collection).GetItem(request.Key); + var item = GetManager().GetCollection(request.Collection).GetItem(request.Key, request.DefaultValue); await receiver.SendGenericResponse(new RemoteDataStoreGetItemResponse() { Item = item @@ -127,7 +127,7 @@ namespace Tango.PPC.Common.DataStore { try { - GetManager().GetCollection(request.Collection).Put(request.Item.Key, GetPMRValue(request.Item)); + GetManager().GetCollection(request.Collection).Put(request.Key, GetPMRValue(request.Item)); await transporter.SendResponse(new PutDataStoreItemResponse(), token); } catch (Exception ex) @@ -151,9 +151,10 @@ namespace Tango.PPC.Common.DataStore { try { - var item = GetManager().GetCollection(request.Collection).GetItem(request.Key); + var item = GetManager().GetCollection(request.Collection).GetItem(request.Key, GetPMRValue(request.DefaultItem)); await transporter.SendResponse(new GetDataStoreItemResponse() { + Key = item.Key, Item = CreatePMRDataStoreItem(item), }, token); } @@ -194,7 +195,6 @@ namespace Tango.PPC.Common.DataStore private DataStoreItem CreatePMRDataStoreItem(IDataStoreItem item) { DataStoreItem pmr = new DataStoreItem(); - pmr.Key = item.Key; pmr.DataType = (PMR.DataStore.DataType)item.Type; switch (item.Type) @@ -224,6 +224,8 @@ namespace Tango.PPC.Common.DataStore private Object GetPMRValue(DataStoreItem item) { + if (item == null) return null; + switch (item.DataType) { case PMR.DataStore.DataType.Int32: diff --git a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs index eab6ef377..afec27417 100644 --- a/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs +++ b/Software/Visual_Studio/Tango.DataStore.EF/EFDataStoreCollection.cs @@ -53,23 +53,46 @@ namespace Tango.DataStore.EF public T Get<T>(string key) { - return (T)Get(key); + return (T)Get(key, null); + } + + public T Get<T>(string key, T defaultValue) + { + return (T)Get(key, (object)defaultValue); } public object Get(string key) { - return GetItem(key).Value; + return Get(key, null); + } + + public object Get(string key, object defaultValue) + { + return GetItem(key, defaultValue).Value; } public IDataStoreItem GetItem(string key) { + return GetItem(key, null); + } + + public IDataStoreItem GetItem(string key, object defaultValue) + { using (var db = ObservablesContext.CreateDefault()) { var item = db.DataStoreItems.SingleOrDefault(x => x.CollectionName == Name && x.Key == key); if (item == null) { - throw new KeyNotFoundException("The specified data store key was not found."); + if (defaultValue == null) + { + throw new KeyNotFoundException("The specified data store key was not found."); + } + else + { + Put(key, defaultValue); + return GetItem(key); + } } return item.ToDataStoreItem(); diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs index e61385ab8..c76a3b6d9 100644 --- a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs +++ b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs @@ -40,21 +40,49 @@ namespace Tango.DataStore.Lite }); } + public T Get<T>(string key) + { + return (T)Convert.ChangeType(Get(key), typeof(T)); + } + + public T Get<T>(string key, T defaultValue) + { + return (T)Convert.ChangeType(Get(key, defaultValue), typeof(T)); + } + public object Get(string key) { + return Get(key, null); + } + + public object Get(string key, object defaultValue) + { + return GetItem(key, defaultValue).Value; + } + + public IDataStoreItem GetItem(string key) + { + return GetItem(key, null); + } + + public IDataStoreItem GetItem(string key, object defaultValue) + { var item = _collection.FindById(key); if (item == null) { - throw new KeyNotFoundException("The specified key was not found on the data store."); + if (defaultValue == null) + { + throw new KeyNotFoundException("The specified key was not found on the data store."); + } + else + { + Put(key, defaultValue); + return GetItem(key); + } } - return item.Value; - } - - public T Get<T>(string key) - { - return (T)Convert.ChangeType(Get(key), typeof(T)); + return item; } public List<IDataStoreItem> GetAll() @@ -77,11 +105,6 @@ namespace Tango.DataStore.Lite return _collection.Count(); } - public IDataStoreItem GetItem(string key) - { - return _collection.FindById(key); - } - public List<IDataStoreItem> GetUnsynchronized() { return _collection.Find(x => !x.IsSynchronized).ToList(); diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs index 8bd6470f9..7d16a0f38 100644 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs @@ -10,5 +10,6 @@ namespace Tango.DataStore.Remote { public String Collection { get; set; } public String Key { get; set; } + public Object DefaultValue { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs index 1244523b3..4b8e9ee47 100644 --- a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs @@ -10,5 +10,6 @@ namespace Tango.DataStore.Remote { public String Collection { get; set; } public String Key { get; set; } + public Object DefaultValue { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs index e73d02328..baca95c67 100644 --- a/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs +++ b/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs @@ -15,12 +15,14 @@ namespace Tango.DataStore /// Gets the collection name. /// </summary> String Name { get; } + /// <summary> /// Upserts the specified key and value. /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> void Put(String key, Object value); + /// <summary> /// Upserts the specified key and value of type T. /// </summary> @@ -28,6 +30,7 @@ namespace Tango.DataStore /// <param name="key">The key.</param> /// <param name="value">The value.</param> void Put<T>(String key, T value); + /// <summary> /// Upserts the specified key and value. /// The value must be of the specified DataType. @@ -36,12 +39,22 @@ namespace Tango.DataStore /// <param name="type">The type.</param> /// <param name="value">The value.</param> void Put(String key, DataType type, Object value); + /// <summary> /// Gets the value by the specified key /// </summary> /// <param name="key">The key.</param> /// <returns></returns> Object Get(String key); + + /// <summary> + /// Gets the value by the specified key + /// </summary> + /// <param name="key">The key.</param> + /// <param name="defaultValue">Will execute put when the key was not found.</param> + /// <returns></returns> + Object Get(String key, Object defaultValue); + /// <summary> /// Gets the value of type T by the specified key /// </summary> @@ -49,31 +62,54 @@ namespace Tango.DataStore /// <param name="key">The key.</param> /// <returns></returns> T Get<T>(String key); + + /// <summary> + /// Gets the value of type T by the specified key + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="key">The key.</param> + /// <param name="defaultValue">Will execute put when the key was not found.</param> + /// <returns></returns> + T Get<T>(String key, T defaultValue); + /// <summary> /// Gets the full data store item by the specified key. /// </summary> /// <param name="key">The key.</param> /// <returns></returns> IDataStoreItem GetItem(String key); + + /// <summary> + /// Gets the full data store item by the specified key. + /// </summary> + /// <param name="key">The key.</param> + /// <param name="defaultValue">Will execute put when the key was not found.</param> + /// <returns></returns> + IDataStoreItem GetItem(String key, Object defaultValue); + /// <summary> /// Gets all the data store items in the collection. /// </summary> /// <returns></returns> List<IDataStoreItem> GetAll(); + /// <summary> /// Gets all the data store unsynchronized items in the collection. /// </summary> /// <returns></returns> List<IDataStoreItem> GetUnsynchronized(); + /// <summary> /// Deleted an item by the specified key. /// </summary> /// <param name="key">The key.</param> void Delete(String key); + /// <summary> /// Deletes all items in the collection. /// </summary> void DeleteAll(); + /// <summary> /// Returns the number of items in the collection. /// </summary> diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index f8682dd18..05752c378 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -1786,9 +1786,9 @@ namespace Tango.Emulations.Emulators var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() { Collection = "TEST", + Key = "int", Item = new PMR.DataStore.DataStoreItem() { - Key = "int", DataType = DataType.Int32, Int32Value = 100 } @@ -1826,9 +1826,9 @@ namespace Tango.Emulations.Emulators var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() { Collection = "TEST", + Key = "float", Item = new PMR.DataStore.DataStoreItem() { - Key = "float", DataType = DataType.Float, FloatValue = 101f } @@ -1866,9 +1866,9 @@ namespace Tango.Emulations.Emulators var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() { Collection = "TEST", + Key = "double", Item = new PMR.DataStore.DataStoreItem() { - Key = "double", DataType = DataType.Double, DoubleValue = 102d } @@ -1906,9 +1906,9 @@ namespace Tango.Emulations.Emulators var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() { Collection = "TEST", + Key = "bool", Item = new PMR.DataStore.DataStoreItem() { - Key = "bool", DataType = DataType.Boolean, BooleanValue = true } @@ -1946,9 +1946,9 @@ namespace Tango.Emulations.Emulators var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() { Collection = "TEST", + Key = "string", Item = new PMR.DataStore.DataStoreItem() { - Key = "string", DataType = DataType.String, StringValue = "String Value" } @@ -1986,9 +1986,9 @@ namespace Tango.Emulations.Emulators var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() { Collection = "TEST", + Key = "bytes", Item = new PMR.DataStore.DataStoreItem() { - Key = "bytes", DataType = DataType.Bytes, BytesValue = ByteString.CopyFromUtf8("Bytes TEST TEST TEST"), } diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItem.cs b/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItem.cs index a6d2fe860..4b7534738 100644 --- a/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItem.cs +++ b/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItem.cs @@ -23,16 +23,16 @@ namespace Tango.PMR.DataStore { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChNEYXRhU3RvcmVJdGVtLnByb3RvEhNUYW5nby5QTVIuRGF0YVN0b3JlGg5E", - "YXRhVHlwZS5wcm90byLJAQoNRGF0YVN0b3JlSXRlbRILCgNLZXkYASABKAkS", - "LwoIRGF0YVR5cGUYAiABKA4yHS5UYW5nby5QTVIuRGF0YVN0b3JlLkRhdGFU", - "eXBlEhIKCkludDMyVmFsdWUYAyABKAUSEgoKRmxvYXRWYWx1ZRgEIAEoAhIT", - "CgtEb3VibGVWYWx1ZRgFIAEoARIUCgxCb29sZWFuVmFsdWUYBiABKAgSEwoL", - "U3RyaW5nVmFsdWUYByABKAkSEgoKQnl0ZXNWYWx1ZRgIIAEoDEIfCh1jb20u", - "dHdpbmUudGFuZ28ucG1yLmRhdGFzdG9yZWIGcHJvdG8z")); + "YXRhVHlwZS5wcm90byK8AQoNRGF0YVN0b3JlSXRlbRIvCghEYXRhVHlwZRgB", + "IAEoDjIdLlRhbmdvLlBNUi5EYXRhU3RvcmUuRGF0YVR5cGUSEgoKSW50MzJW", + "YWx1ZRgCIAEoBRISCgpGbG9hdFZhbHVlGAMgASgCEhMKC0RvdWJsZVZhbHVl", + "GAQgASgBEhQKDEJvb2xlYW5WYWx1ZRgFIAEoCBITCgtTdHJpbmdWYWx1ZRgG", + "IAEoCRISCgpCeXRlc1ZhbHVlGAcgASgMQh8KHWNvbS50d2luZS50YW5nby5w", + "bXIuZGF0YXN0b3JlYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.DataStore.DataTypeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.DataStoreItem), global::Tango.PMR.DataStore.DataStoreItem.Parser, new[]{ "Key", "DataType", "Int32Value", "FloatValue", "DoubleValue", "BooleanValue", "StringValue", "BytesValue" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.DataStoreItem), global::Tango.PMR.DataStore.DataStoreItem.Parser, new[]{ "DataType", "Int32Value", "FloatValue", "DoubleValue", "BooleanValue", "StringValue", "BytesValue" }, null, null, null) })); } #endregion @@ -63,7 +63,6 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public DataStoreItem(DataStoreItem other) : this() { - key_ = other.key_; dataType_ = other.dataType_; int32Value_ = other.int32Value_; floatValue_ = other.floatValue_; @@ -78,19 +77,8 @@ namespace Tango.PMR.DataStore { return new DataStoreItem(this); } - /// <summary>Field number for the "Key" field.</summary> - public const int KeyFieldNumber = 1; - private string key_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Key { - get { return key_; } - set { - key_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - /// <summary>Field number for the "DataType" field.</summary> - public const int DataTypeFieldNumber = 2; + public const int DataTypeFieldNumber = 1; private global::Tango.PMR.DataStore.DataType dataType_ = 0; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Tango.PMR.DataStore.DataType DataType { @@ -101,7 +89,7 @@ namespace Tango.PMR.DataStore { } /// <summary>Field number for the "Int32Value" field.</summary> - public const int Int32ValueFieldNumber = 3; + public const int Int32ValueFieldNumber = 2; private int int32Value_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Int32Value { @@ -112,7 +100,7 @@ namespace Tango.PMR.DataStore { } /// <summary>Field number for the "FloatValue" field.</summary> - public const int FloatValueFieldNumber = 4; + public const int FloatValueFieldNumber = 3; private float floatValue_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public float FloatValue { @@ -123,7 +111,7 @@ namespace Tango.PMR.DataStore { } /// <summary>Field number for the "DoubleValue" field.</summary> - public const int DoubleValueFieldNumber = 5; + public const int DoubleValueFieldNumber = 4; private double doubleValue_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double DoubleValue { @@ -134,7 +122,7 @@ namespace Tango.PMR.DataStore { } /// <summary>Field number for the "BooleanValue" field.</summary> - public const int BooleanValueFieldNumber = 6; + public const int BooleanValueFieldNumber = 5; private bool booleanValue_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool BooleanValue { @@ -145,7 +133,7 @@ namespace Tango.PMR.DataStore { } /// <summary>Field number for the "StringValue" field.</summary> - public const int StringValueFieldNumber = 7; + public const int StringValueFieldNumber = 6; private string stringValue_ = ""; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string StringValue { @@ -156,7 +144,7 @@ namespace Tango.PMR.DataStore { } /// <summary>Field number for the "BytesValue" field.</summary> - public const int BytesValueFieldNumber = 8; + public const int BytesValueFieldNumber = 7; private pb::ByteString bytesValue_ = pb::ByteString.Empty; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pb::ByteString BytesValue { @@ -179,7 +167,6 @@ namespace Tango.PMR.DataStore { if (ReferenceEquals(other, this)) { return true; } - if (Key != other.Key) return false; if (DataType != other.DataType) return false; if (Int32Value != other.Int32Value) return false; if (FloatValue != other.FloatValue) return false; @@ -193,7 +180,6 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (Key.Length != 0) hash ^= Key.GetHashCode(); if (DataType != 0) hash ^= DataType.GetHashCode(); if (Int32Value != 0) hash ^= Int32Value.GetHashCode(); if (FloatValue != 0F) hash ^= FloatValue.GetHashCode(); @@ -211,36 +197,32 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (Key.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Key); - } if (DataType != 0) { - output.WriteRawTag(16); + output.WriteRawTag(8); output.WriteEnum((int) DataType); } if (Int32Value != 0) { - output.WriteRawTag(24); + output.WriteRawTag(16); output.WriteInt32(Int32Value); } if (FloatValue != 0F) { - output.WriteRawTag(37); + output.WriteRawTag(29); output.WriteFloat(FloatValue); } if (DoubleValue != 0D) { - output.WriteRawTag(41); + output.WriteRawTag(33); output.WriteDouble(DoubleValue); } if (BooleanValue != false) { - output.WriteRawTag(48); + output.WriteRawTag(40); output.WriteBool(BooleanValue); } if (StringValue.Length != 0) { - output.WriteRawTag(58); + output.WriteRawTag(50); output.WriteString(StringValue); } if (BytesValue.Length != 0) { - output.WriteRawTag(66); + output.WriteRawTag(58); output.WriteBytes(BytesValue); } } @@ -248,9 +230,6 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (Key.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); - } if (DataType != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) DataType); } @@ -280,9 +259,6 @@ namespace Tango.PMR.DataStore { if (other == null) { return; } - if (other.Key.Length != 0) { - Key = other.Key; - } if (other.DataType != 0) { DataType = other.DataType; } @@ -314,35 +290,31 @@ namespace Tango.PMR.DataStore { default: input.SkipLastField(); break; - case 10: { - Key = input.ReadString(); - break; - } - case 16: { + case 8: { dataType_ = (global::Tango.PMR.DataStore.DataType) input.ReadEnum(); break; } - case 24: { + case 16: { Int32Value = input.ReadInt32(); break; } - case 37: { + case 29: { FloatValue = input.ReadFloat(); break; } - case 41: { + case 33: { DoubleValue = input.ReadDouble(); break; } - case 48: { + case 40: { BooleanValue = input.ReadBool(); break; } - case 58: { + case 50: { StringValue = input.ReadString(); break; } - case 66: { + case 58: { BytesValue = input.ReadBytes(); break; } diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemRequest.cs b/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemRequest.cs index 6c6d20b72..a4bb5332b 100644 --- a/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemRequest.cs +++ b/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemRequest.cs @@ -23,13 +23,15 @@ namespace Tango.PMR.DataStore { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Ch1HZXREYXRhU3RvcmVJdGVtUmVxdWVzdC5wcm90bxITVGFuZ28uUE1SLkRh", - "dGFTdG9yZSI6ChdHZXREYXRhU3RvcmVJdGVtUmVxdWVzdBISCgpDb2xsZWN0", - "aW9uGAEgASgJEgsKA0tleRgCIAEoCUIfCh1jb20udHdpbmUudGFuZ28ucG1y", - "LmRhdGFzdG9yZWIGcHJvdG8z")); + "dGFTdG9yZRoTRGF0YVN0b3JlSXRlbS5wcm90byJzChdHZXREYXRhU3RvcmVJ", + "dGVtUmVxdWVzdBISCgpDb2xsZWN0aW9uGAEgASgJEgsKA0tleRgCIAEoCRI3", + "CgtEZWZhdWx0SXRlbRgDIAEoCzIiLlRhbmdvLlBNUi5EYXRhU3RvcmUuRGF0", + "YVN0b3JlSXRlbUIfCh1jb20udHdpbmUudGFuZ28ucG1yLmRhdGFzdG9yZWIG", + "cHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, + new pbr::FileDescriptor[] { global::Tango.PMR.DataStore.DataStoreItemReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.GetDataStoreItemRequest), global::Tango.PMR.DataStore.GetDataStoreItemRequest.Parser, new[]{ "Collection", "Key" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.GetDataStoreItemRequest), global::Tango.PMR.DataStore.GetDataStoreItemRequest.Parser, new[]{ "Collection", "Key", "DefaultItem" }, null, null, null) })); } #endregion @@ -62,6 +64,7 @@ namespace Tango.PMR.DataStore { public GetDataStoreItemRequest(GetDataStoreItemRequest other) : this() { collection_ = other.collection_; key_ = other.key_; + DefaultItem = other.defaultItem_ != null ? other.DefaultItem.Clone() : null; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -91,6 +94,17 @@ namespace Tango.PMR.DataStore { } } + /// <summary>Field number for the "DefaultItem" field.</summary> + public const int DefaultItemFieldNumber = 3; + private global::Tango.PMR.DataStore.DataStoreItem defaultItem_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.DataStore.DataStoreItem DefaultItem { + get { return defaultItem_; } + set { + defaultItem_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as GetDataStoreItemRequest); @@ -106,6 +120,7 @@ namespace Tango.PMR.DataStore { } if (Collection != other.Collection) return false; if (Key != other.Key) return false; + if (!object.Equals(DefaultItem, other.DefaultItem)) return false; return true; } @@ -114,6 +129,7 @@ namespace Tango.PMR.DataStore { int hash = 1; if (Collection.Length != 0) hash ^= Collection.GetHashCode(); if (Key.Length != 0) hash ^= Key.GetHashCode(); + if (defaultItem_ != null) hash ^= DefaultItem.GetHashCode(); return hash; } @@ -132,6 +148,10 @@ namespace Tango.PMR.DataStore { output.WriteRawTag(18); output.WriteString(Key); } + if (defaultItem_ != null) { + output.WriteRawTag(26); + output.WriteMessage(DefaultItem); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -143,6 +163,9 @@ namespace Tango.PMR.DataStore { if (Key.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); } + if (defaultItem_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DefaultItem); + } return size; } @@ -157,6 +180,12 @@ namespace Tango.PMR.DataStore { if (other.Key.Length != 0) { Key = other.Key; } + if (other.defaultItem_ != null) { + if (defaultItem_ == null) { + defaultItem_ = new global::Tango.PMR.DataStore.DataStoreItem(); + } + DefaultItem.MergeFrom(other.DefaultItem); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -175,6 +204,13 @@ namespace Tango.PMR.DataStore { Key = input.ReadString(); break; } + case 26: { + if (defaultItem_ == null) { + defaultItem_ = new global::Tango.PMR.DataStore.DataStoreItem(); + } + input.ReadMessage(defaultItem_); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemResponse.cs b/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemResponse.cs index 892f197d8..a42d22d23 100644 --- a/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemResponse.cs +++ b/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemResponse.cs @@ -23,14 +23,14 @@ namespace Tango.PMR.DataStore { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Ch5HZXREYXRhU3RvcmVJdGVtUmVzcG9uc2UucHJvdG8SE1RhbmdvLlBNUi5E", - "YXRhU3RvcmUaE0RhdGFTdG9yZUl0ZW0ucHJvdG8iTAoYR2V0RGF0YVN0b3Jl", - "SXRlbVJlc3BvbnNlEjAKBEl0ZW0YASABKAsyIi5UYW5nby5QTVIuRGF0YVN0", - "b3JlLkRhdGFTdG9yZUl0ZW1CHwodY29tLnR3aW5lLnRhbmdvLnBtci5kYXRh", - "c3RvcmViBnByb3RvMw==")); + "YXRhU3RvcmUaE0RhdGFTdG9yZUl0ZW0ucHJvdG8iWQoYR2V0RGF0YVN0b3Jl", + "SXRlbVJlc3BvbnNlEgsKA0tleRgBIAEoCRIwCgRJdGVtGAIgASgLMiIuVGFu", + "Z28uUE1SLkRhdGFTdG9yZS5EYXRhU3RvcmVJdGVtQh8KHWNvbS50d2luZS50", + "YW5nby5wbXIuZGF0YXN0b3JlYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.DataStore.DataStoreItemReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.GetDataStoreItemResponse), global::Tango.PMR.DataStore.GetDataStoreItemResponse.Parser, new[]{ "Item" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.GetDataStoreItemResponse), global::Tango.PMR.DataStore.GetDataStoreItemResponse.Parser, new[]{ "Key", "Item" }, null, null, null) })); } #endregion @@ -61,6 +61,7 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public GetDataStoreItemResponse(GetDataStoreItemResponse other) : this() { + key_ = other.key_; Item = other.item_ != null ? other.Item.Clone() : null; } @@ -69,8 +70,19 @@ namespace Tango.PMR.DataStore { return new GetDataStoreItemResponse(this); } + /// <summary>Field number for the "Key" field.</summary> + public const int KeyFieldNumber = 1; + private string key_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Key { + get { return key_; } + set { + key_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// <summary>Field number for the "Item" field.</summary> - public const int ItemFieldNumber = 1; + public const int ItemFieldNumber = 2; private global::Tango.PMR.DataStore.DataStoreItem item_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Tango.PMR.DataStore.DataStoreItem Item { @@ -93,6 +105,7 @@ namespace Tango.PMR.DataStore { if (ReferenceEquals(other, this)) { return true; } + if (Key != other.Key) return false; if (!object.Equals(Item, other.Item)) return false; return true; } @@ -100,6 +113,7 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; + if (Key.Length != 0) hash ^= Key.GetHashCode(); if (item_ != null) hash ^= Item.GetHashCode(); return hash; } @@ -111,8 +125,12 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (item_ != null) { + if (Key.Length != 0) { output.WriteRawTag(10); + output.WriteString(Key); + } + if (item_ != null) { + output.WriteRawTag(18); output.WriteMessage(Item); } } @@ -120,6 +138,9 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; + if (Key.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); + } if (item_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Item); } @@ -131,6 +152,9 @@ namespace Tango.PMR.DataStore { if (other == null) { return; } + if (other.Key.Length != 0) { + Key = other.Key; + } if (other.item_ != null) { if (item_ == null) { item_ = new global::Tango.PMR.DataStore.DataStoreItem(); @@ -148,6 +172,10 @@ namespace Tango.PMR.DataStore { input.SkipLastField(); break; case 10: { + Key = input.ReadString(); + break; + } + case 18: { if (item_ == null) { item_ = new global::Tango.PMR.DataStore.DataStoreItem(); } diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemRequest.cs b/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemRequest.cs index 7281b4c9c..9e9be6768 100644 --- a/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemRequest.cs +++ b/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemRequest.cs @@ -23,14 +23,14 @@ namespace Tango.PMR.DataStore { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Ch1QdXREYXRhU3RvcmVJdGVtUmVxdWVzdC5wcm90bxITVGFuZ28uUE1SLkRh", - "dGFTdG9yZRoTRGF0YVN0b3JlSXRlbS5wcm90byJfChdQdXREYXRhU3RvcmVJ", - "dGVtUmVxdWVzdBISCgpDb2xsZWN0aW9uGAEgASgJEjAKBEl0ZW0YAiABKAsy", - "Ii5UYW5nby5QTVIuRGF0YVN0b3JlLkRhdGFTdG9yZUl0ZW1CHwodY29tLnR3", - "aW5lLnRhbmdvLnBtci5kYXRhc3RvcmViBnByb3RvMw==")); + "dGFTdG9yZRoTRGF0YVN0b3JlSXRlbS5wcm90byJsChdQdXREYXRhU3RvcmVJ", + "dGVtUmVxdWVzdBISCgpDb2xsZWN0aW9uGAEgASgJEgsKA0tleRgCIAEoCRIw", + "CgRJdGVtGAMgASgLMiIuVGFuZ28uUE1SLkRhdGFTdG9yZS5EYXRhU3RvcmVJ", + "dGVtQh8KHWNvbS50d2luZS50YW5nby5wbXIuZGF0YXN0b3JlYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.DataStore.DataStoreItemReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.PutDataStoreItemRequest), global::Tango.PMR.DataStore.PutDataStoreItemRequest.Parser, new[]{ "Collection", "Item" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.PutDataStoreItemRequest), global::Tango.PMR.DataStore.PutDataStoreItemRequest.Parser, new[]{ "Collection", "Key", "Item" }, null, null, null) })); } #endregion @@ -62,6 +62,7 @@ namespace Tango.PMR.DataStore { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public PutDataStoreItemRequest(PutDataStoreItemRequest other) : this() { collection_ = other.collection_; + key_ = other.key_; Item = other.item_ != null ? other.Item.Clone() : null; } @@ -81,8 +82,19 @@ namespace Tango.PMR.DataStore { } } + /// <summary>Field number for the "Key" field.</summary> + public const int KeyFieldNumber = 2; + private string key_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Key { + get { return key_; } + set { + key_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// <summary>Field number for the "Item" field.</summary> - public const int ItemFieldNumber = 2; + public const int ItemFieldNumber = 3; private global::Tango.PMR.DataStore.DataStoreItem item_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Tango.PMR.DataStore.DataStoreItem Item { @@ -106,6 +118,7 @@ namespace Tango.PMR.DataStore { return true; } if (Collection != other.Collection) return false; + if (Key != other.Key) return false; if (!object.Equals(Item, other.Item)) return false; return true; } @@ -114,6 +127,7 @@ namespace Tango.PMR.DataStore { public override int GetHashCode() { int hash = 1; if (Collection.Length != 0) hash ^= Collection.GetHashCode(); + if (Key.Length != 0) hash ^= Key.GetHashCode(); if (item_ != null) hash ^= Item.GetHashCode(); return hash; } @@ -129,8 +143,12 @@ namespace Tango.PMR.DataStore { output.WriteRawTag(10); output.WriteString(Collection); } - if (item_ != null) { + if (Key.Length != 0) { output.WriteRawTag(18); + output.WriteString(Key); + } + if (item_ != null) { + output.WriteRawTag(26); output.WriteMessage(Item); } } @@ -141,6 +159,9 @@ namespace Tango.PMR.DataStore { if (Collection.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Collection); } + if (Key.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); + } if (item_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Item); } @@ -155,6 +176,9 @@ namespace Tango.PMR.DataStore { if (other.Collection.Length != 0) { Collection = other.Collection; } + if (other.Key.Length != 0) { + Key = other.Key; + } if (other.item_ != null) { if (item_ == null) { item_ = new global::Tango.PMR.DataStore.DataStoreItem(); @@ -176,6 +200,10 @@ namespace Tango.PMR.DataStore { break; } case 18: { + Key = input.ReadString(); + break; + } + case 26: { if (item_ == null) { item_ = new global::Tango.PMR.DataStore.DataStoreItem(); } diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index adc8bbc21..7b3a7c397 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -482,7 +482,7 @@ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file |
