diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-20 20:58:32 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-10-20 20:58:32 +0300 |
| commit | 50b5a229c4fe547a896539f24c96e5e9a86ebb80 (patch) | |
| tree | 653f78a466296564862e5bcba38422284f693545 /Software/Visual_Studio | |
| parent | b732167cbc51f0b19447d67687af5c514cf4f65a (diff) | |
| download | Tango-50b5a229c4fe547a896539f24c96e5e9a86ebb80.tar.gz Tango-50b5a229c4fe547a896539f24c96e5e9a86ebb80.zip | |
DATA STORE !
Diffstat (limited to 'Software/Visual_Studio')
62 files changed, 2746 insertions, 23 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/IProcedureContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/IProcedureContext.cs index 829da6a43..69b747906 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/IProcedureContext.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/IProcedureContext.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using Tango.BL.Entities; using Tango.Core; using Tango.FSE.Common.Connection; +using Tango.FSE.Common.DataStore; using Tango.FSE.Common.Diagnostics; using Tango.Integration.Operation; using Tango.Scripting.Basic; @@ -694,6 +695,12 @@ namespace Tango.FSE.Procedures void WriteCsv<T>(String file, List<T> items); /// <summary> + /// Gets the remote data store manager. + /// </summary> + /// <returns></returns> + IRemoteDataStoreManager GetRemoteDataStoreManager(); + + /// <summary> /// Request a breakpoint operation from the host IDE (internal use only). /// </summary> /// <param name="file">The file.</param> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ProcedureContext.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ProcedureContext.cs index 0c9dff893..43c969a35 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ProcedureContext.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ProcedureContext.cs @@ -22,6 +22,7 @@ using Tango.Core.ExtensionMethods; using Tango.Core.Threading; using Tango.CSV; using Tango.FSE.Common.Connection; +using Tango.FSE.Common.DataStore; using Tango.FSE.Common.Diagnostics; using Tango.FSE.Common.Notifications; using Tango.FSE.Common.Threading; @@ -57,6 +58,9 @@ namespace Tango.FSE.Procedures [TangoInject] private IDiagnosticsProvider DiagnosticsProvider { get; set; } + [TangoInject] + private IRemoteDataStoreManager RemoteDataStore { get; set; } + public ReadOnlyCollection<Result> Results { get; private set; } public MachineConnectionTypes ConnectionType @@ -813,6 +817,11 @@ namespace Tango.FSE.Procedures csvFile.Dispose(); } + public IRemoteDataStoreManager GetRemoteDataStoreManager() + { + return RemoteDataStore; + } + public void BreakPoint(string file, int lineNumber, params object[] symbolsMap) { if (BreakPointRequest != null && symbolsMap.Length > 0) diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs new file mode 100644 index 000000000..02cc3ac9d --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore; + +namespace Tango.FSE.Common.DataStore +{ + public interface IRemoteDataStoreManager : IDataStoreManager + { + + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index 9c67d0902..4f0cb622b 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -188,6 +188,7 @@ <Compile Include="Converters\TimeSpanHumanizeConverter.cs" /> <Compile Include="Core\FSEProgress.cs" /> <Compile Include="DashboardTile.cs" /> + <Compile Include="DataStore\IRemoteDataStoreManager.cs" /> <Compile Include="DemoMode\DemoModeCommand.cs" /> <Compile Include="DemoMode\IDemoModeManager.cs" /> <Compile Include="Diagnostics\DiagnosticsFrame.cs" /> @@ -504,6 +505,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Emulations\Tango.Emulations.csproj"> <Project>{63561e19-ff5a-414b-a5ef-e30711543e1d}</Project> <Name>Tango.Emulations</Name> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultRemoteDataStoreManager.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultRemoteDataStoreManager.cs new file mode 100644 index 000000000..a9c40c6e3 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultRemoteDataStoreManager.cs @@ -0,0 +1,35 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.DataStore; +using Tango.DataStore.Remote; +using Tango.FSE.Common.Connection; +using Tango.FSE.Common.DataStore; + +namespace Tango.FSE.UI.DataStore +{ + public class DefaultRemoteDataStoreManager : IRemoteDataStoreManager + { + [TangoInject] + internal IMachineProvider MachineProvider { get; set; } + + public IDataStoreCollection GetCollection(string name) + { + return new RemoteDataStoreCollection(name, MachineProvider); + } + + public List<string> GetCollectionNames() + { + return MachineProvider.MachineOperator.SendGenericRequest<RemoteDataStoreGetCollectionNamesRequest, RemoteDataStoreGetCollectionNamesResponse>(new RemoteDataStoreGetCollectionNamesRequest()).Result.Names; + } + + public void Dispose() + { + //Do nothing. + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/RemoteDataStoreCollection.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/RemoteDataStoreCollection.cs new file mode 100644 index 000000000..323a1b550 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/RemoteDataStoreCollection.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore; +using Tango.DataStore.Remote; +using Tango.FSE.Common.Connection; + +namespace Tango.FSE.UI.DataStore +{ + public class RemoteDataStoreCollection : IDataStoreCollection + { + private IMachineProvider _machineProvider; + + public string Name { get; } + + public RemoteDataStoreCollection(String name, IMachineProvider machineProvider) + { + Name = name; + _machineProvider = machineProvider; + } + + public void Put<T>(string key, T value) + { + Put(key, (object)value); + } + + public void Put(string key, object value) + { + Put(key, DataStoreHelper.GetDataType(value), value); + } + + public void Put(string key, DataType type, object value) + { + var result = _machineProvider.MachineOperator.SendGenericRequest<RemoteDataStorePutRequest, RemoteDataStorePutResponse>(new RemoteDataStorePutRequest() + { + Collection = Name, + DataType = type, + Key = key, + Value = value + }).Result; + } + + public T Get<T>(string key) + { + return (T)Convert.ChangeType(Get(key), typeof(T)); + } + + public object Get(string key) + { + var result = _machineProvider.MachineOperator.SendGenericRequest<RemoteDataStoreGetRequest, RemoteDataStoreGetResponse>(new RemoteDataStoreGetRequest() + { + Collection = Name, + Key = key + }).Result; + + return result.Value; + } + + public List<IDataStoreItem> GetAll() + { + throw new NotImplementedException(); + } + + public void Delete(string key) + { + throw new NotImplementedException(); + } + + public void DeleteAll() + { + throw new NotImplementedException(); + } + + public int Count() + { + throw new NotImplementedException(); + } + + public IDataStoreItem GetItem(string key) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index 5dc93878f..6c5b993b5 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -261,6 +261,8 @@ <Compile Include="Converters\MidTankLevelToElementHeightConverter.cs" /> <Compile Include="Converters\StringToFirstLetterConverter.cs" /> <Compile Include="Cryptography\DefaultCryptographyProvider.cs" /> + <Compile Include="DataStore\DefaultRemoteDataStoreManager.cs" /> + <Compile Include="DataStore\RemoteDataStoreCollection.cs" /> <Compile Include="DemoMode\DefaultDemoModeManager.cs" /> <Compile Include="DemoMode\DemoModeWindow.xaml.cs"> <DependentUpon>DemoModeWindow.xaml</DependentUpon> @@ -638,6 +640,14 @@ <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore.Remote\Tango.DataStore.Remote.csproj"> + <Project>{29448f3c-9b3e-4da6-8555-46a8b9a6b3aa}</Project> + <Name>Tango.DataStore.Remote</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{E0364DFA-0721-4637-9D32-9D22AAC109D6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Emulations\Tango.Emulations.csproj"> <Project>{63561e19-ff5a-414b-a5ef-e30711543e1d}</Project> <Name>Tango.Emulations</Name> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs index f466b1818..fd514b7ac 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs @@ -72,6 +72,8 @@ using Tango.FSE.Common.RemoteActions; using Tango.FSE.UI.RemoteActions; using Tango.FSE.UI.Cryptography; using Tango.BL.ActionLogs; +using Tango.FSE.Common.DataStore; +using Tango.FSE.UI.DataStore; namespace Tango.FSE.UI { @@ -114,6 +116,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Unregister<IInsightsProvider>(); TangoIOC.Default.Unregister<IRemoteActionsProvider>(); TangoIOC.Default.Unregister<IActionLogManager>(); + TangoIOC.Default.Unregister<IRemoteDataStoreManager>(); //TangoIOC.Default.Unregister<ExternalBridgeScanner>(); //TangoIOC.Default.Unregister<IDiagnosticsFrameProvider>(); //TangoIOC.Default.Unregister<IEventLogger>(); @@ -156,6 +159,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Register<IFileAssociationProvider, DefaultFileAssociationProvider>(); TangoIOC.Default.Register<IInsightsProvider, DefaultInsightsProvider>(); TangoIOC.Default.Register<IRemoteActionsProvider, DefaultRemoteActionsProvider>(); + TangoIOC.Default.Register<IRemoteDataStoreManager, DefaultRemoteDataStoreManager>(); TangoIOC.Default.Register<MainWindowVM>(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs new file mode 100644 index 000000000..02d8e1858 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs @@ -0,0 +1,254 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.DataStore; +using Tango.DataStore.Lite; +using Tango.DataStore.Remote; +using Tango.Integration.ExternalBridge; +using Tango.PMR.DataStore; +using Tango.PPC.Common.Connection; +using Tango.PPC.Common.ExternalBridge; +using Tango.Transport; + +namespace Tango.PPC.Common.DataStore +{ + [TangoCreateWhenRegistered] + public class DefaultDataStoreService : IDataStoreService, IExternalBridgeRequestHandler + { + private IDataStoreManager _manager; + + public DefaultDataStoreService(IPPCExternalBridgeService externalBridge, IMachineProvider machineProvider) + { + externalBridge.RegisterRequestHandler(this); + + machineProvider.MachineOperator.RegisterRequestHandler<PutDataStoreItemRequest>(OnPutDataStoreItemRequest); + machineProvider.MachineOperator.RegisterRequestHandler<GetDataStoreItemRequest>(OnGetDataStoreItemRequest); + } + + public IDataStoreManager GetManager() + { + if (_manager == null) + { + _manager = new LiteDBDataStoreManager(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "DataStore", Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName) + ".db")); + } + + return _manager; + } + + public void Dispose() + { + _manager?.Dispose(); + } + + #region Generic Handlers + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStorePutRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStorePutRequest(RemoteDataStorePutRequest request, String token, ExternalBridgeReceiver receiver) + { + GetManager().GetCollection(request.Collection).Put(request.Key, request.DataType, request.Value); + await receiver.SendGenericResponse(new RemoteDataStorePutResponse(), token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreGetRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreGetRequest(RemoteDataStoreGetRequest request, String token, ExternalBridgeReceiver receiver) + { + var value = GetManager().GetCollection(request.Collection).Get(request.Key); + await receiver.SendGenericResponse(new RemoteDataStoreGetResponse() + { + Value = value + }, token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreGetItemRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreGetItemRequest(RemoteDataStoreGetItemRequest request, String token, ExternalBridgeReceiver receiver) + { + var item = GetManager().GetCollection(request.Collection).GetItem(request.Key); + await receiver.SendGenericResponse(new RemoteDataStoreGetItemResponse() + { + Item = item + }, token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreCountRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreCountRequest(RemoteDataStoreCountRequest request, String token, ExternalBridgeReceiver receiver) + { + var count = GetManager().GetCollection(request.Collection).Count(); + await receiver.SendGenericResponse(new RemoteDataStoreCountResponse() + { + Count = count + }, token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreDeleteRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreDeleteRequest(RemoteDataStoreDeleteRequest request, String token, ExternalBridgeReceiver receiver) + { + GetManager().GetCollection(request.Collection).Delete(request.Key); + await receiver.SendGenericResponse(new RemoteDataStoreDeleteResponse(), token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreDeleteAllRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreDeleteAllRequest(RemoteDataStoreDeleteAllRequest request, String token, ExternalBridgeReceiver receiver) + { + GetManager().GetCollection(request.Collection).DeleteAll(); + await receiver.SendGenericResponse(new RemoteDataStoreDeleteAllResponse(), token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreGetAllRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreGetAllRequest(RemoteDataStoreGetAllRequest request, String token, ExternalBridgeReceiver receiver) + { + var all = GetManager().GetCollection(request.Collection).GetAll(); + await receiver.SendGenericResponse(new RemoteDataStoreGetAllResponse() + { + Items = all + }, token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreGetCollectionNamesRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreGetCollectionNamesRequest(RemoteDataStoreGetCollectionNamesRequest request, String token, ExternalBridgeReceiver receiver) + { + var names = GetManager().GetCollectionNames(); + await receiver.SendGenericResponse(new RemoteDataStoreGetCollectionNamesResponse() + { + Names = names + }, token); + } + + #endregion + + #region Proto Handlers + + private async void OnPutDataStoreItemRequest(ITransporter transporter, PutDataStoreItemRequest request, string token) + { + try + { + GetManager().GetCollection(request.Collection).Put(request.Item.Key, GetPMRValue(request.Item)); + await transporter.SendResponse(new PutDataStoreItemResponse(), token); + } + catch (Exception ex) + { + try + { + await transporter.SendResponse(new PutDataStoreItemResponse(), token, new TransportResponseConfig() + { + ErrorCode = PMR.Common.ErrorCode.GeneralDatastoreError, + ErrorMessage = ex.Message + }); + } + catch (Exception exx) + { + Debug.WriteLine(exx); + } + } + } + + private async void OnGetDataStoreItemRequest(ITransporter transporter, GetDataStoreItemRequest request, string token) + { + try + { + var item = GetManager().GetCollection(request.Collection).GetItem(request.Key); + await transporter.SendResponse(new GetDataStoreItemResponse() + { + Item = CreatePMRDataStoreItem(item), + }, token); + } + catch (KeyNotFoundException ex) + { + try + { + await transporter.SendResponse(new GetDataStoreItemResponse(), token, new TransportResponseConfig() + { + ErrorCode = PMR.Common.ErrorCode.KeyNotFound, + ErrorMessage = ex.Message + }); + } + catch (Exception exx) + { + Debug.WriteLine(exx); + } + } + catch (Exception ex) + { + try + { + await transporter.SendResponse(new GetDataStoreItemResponse(), token, new TransportResponseConfig() + { + ErrorCode = PMR.Common.ErrorCode.GeneralDatastoreError, + ErrorMessage = ex.Message + }); + } + catch (Exception exx) + { + Debug.WriteLine(exx); + } + } + } + + #region Helpers + + private DataStoreItem CreatePMRDataStoreItem(IDataStoreItem item) + { + DataStoreItem pmr = new DataStoreItem(); + pmr.Key = item.Key; + pmr.DataType = (PMR.DataStore.DataType)item.Type; + + switch (item.Type) + { + case Tango.DataStore.DataType.Int32: + pmr.Int32Value = (int)Convert.ChangeType(item.Value, typeof(int)); + break; + case Tango.DataStore.DataType.Float: + pmr.FloatValue = (float)Convert.ChangeType(item.Value, typeof(float)); + break; + case Tango.DataStore.DataType.Double: + pmr.DoubleValue = (double)Convert.ChangeType(item.Value, typeof(double)); + break; + case Tango.DataStore.DataType.Boolean: + pmr.BooleanValue = (bool)Convert.ChangeType(item.Value, typeof(bool)); + break; + case Tango.DataStore.DataType.String: + pmr.StringValue = (String)Convert.ChangeType(item.Value, typeof(String)); + break; + case Tango.DataStore.DataType.Bytes: + pmr.BytesValue = Google.Protobuf.ByteString.CopyFrom((byte[])Convert.ChangeType(item.Value, typeof(byte[]))); + break; + } + + return pmr; + } + + private Object GetPMRValue(DataStoreItem item) + { + switch (item.DataType) + { + case PMR.DataStore.DataType.Int32: + return item.Int32Value; + case PMR.DataStore.DataType.Float: + return item.FloatValue; + case PMR.DataStore.DataType.Double: + return item.DoubleValue; + case PMR.DataStore.DataType.Boolean: + return item.BooleanValue; + case PMR.DataStore.DataType.String: + return item.StringValue; + case PMR.DataStore.DataType.Bytes: + return item.BytesValue.ToByteArray(); + } + + throw new NotSupportedException("The specified data type if not supported."); + } + + #endregion + + #endregion + + public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) + { + //Do nothing. + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/IDataStoreService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/IDataStoreService.cs new file mode 100644 index 000000000..94ae3fa30 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/IDataStoreService.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore; + +namespace Tango.PPC.Common.DataStore +{ + public interface IDataStoreService : IDisposable + { + IDataStoreManager GetManager(); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 2e0c6843e..fec0dfd1a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -151,6 +151,8 @@ </Compile> <Compile Include="Controls\TwineCatalogRenderer.cs" /> <Compile Include="Converters\HeightToOpacityConverter.cs" /> + <Compile Include="DataStore\DefaultDataStoreService.cs" /> + <Compile Include="DataStore\IDataStoreService.cs" /> <Compile Include="ExtensionMethods\IListExtensions.cs" /> <Compile Include="ExtensionMethods\ObservableCollectionExtensions.cs" /> <Compile Include="ExternalBridge\IPPCExternalBridgeService.cs" /> @@ -381,6 +383,18 @@ <Project>{58e8825f-0c96-449c-b320-1e82b0aa876b}</Project> <Name>Tango.CSV</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore.LiteDB\Tango.DataStore.Lite.csproj"> + <Project>{fa96bc0c-4055-475c-9dcc-70a5a9436b10}</Project> + <Name>Tango.DataStore.Lite</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore.Remote\Tango.DataStore.Remote.csproj"> + <Project>{29448f3c-9b3e-4da6-8555-46a8b9a6b3aa}</Project> + <Name>Tango.DataStore.Remote</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Emulations\Tango.Emulations.csproj"> <Project>{63561e19-ff5a-414b-a5ef-e30711543e1d}</Project> <Name>Tango.Emulations</Name> @@ -493,7 +507,7 @@ </Target> <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 diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 181f70d4d..222d3a1e8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -10,6 +10,7 @@ using Tango.PPC.Common.BackupRestore; using Tango.PPC.Common.Connection; using Tango.PPC.Common.Connectivity; using Tango.PPC.Common.Console; +using Tango.PPC.Common.DataStore; using Tango.PPC.Common.Diagnostics; using Tango.PPC.Common.EventLogging; using Tango.PPC.Common.ExternalBridge; @@ -100,6 +101,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister<IInsightsService>(); TangoIOC.Default.Unregister<IRemoteActionsService>(); TangoIOC.Default.Unregister<IThreadLoadingService>(); + TangoIOC.Default.Unregister<IDataStoreService>(); if (App.StartupArgs != null && App.StartupArgs.Contains("-webDebug")) { @@ -143,6 +145,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<IInsightsService, DefaultInsightsService>(); TangoIOC.Default.Register<IRemoteActionsService, DefaultRemoteActionsService>(); TangoIOC.Default.Register<IThreadLoadingService, DefaultThreadLoadingService>(); + TangoIOC.Default.Register<IDataStoreService, DefaultDataStoreService>(); TangoIOC.Default.Register<LoadingViewVM>(); TangoIOC.Default.Register<MainViewVM>(); diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs index c2e7ac422..f55838db3 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs @@ -124,6 +124,15 @@ namespace Tango.Scripting.Editors.Intellisense { var methods = Type.GetRuntimeMethods().Where(x => x.IsPublic && !x.IsSpecialName).ToList(); + if (Type.IsInterface) + { + foreach (var inter in Type.GetInterfaces()) + { + methods.AddRange(inter.GetRuntimeMethods().Where(x => x.IsPublic && !x.IsSpecialName).ToList()); + } + methods = methods.Distinct().ToList(); + } + //TODO: Separate extension methods! methods.AddRange(Type.GetExtensionMethods(Type.Assembly).ToList()); diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs new file mode 100644 index 000000000..9c939797a --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreCollection.cs @@ -0,0 +1,84 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Lite +{ + public class LiteDBDataStoreCollection : IDataStoreCollection + { + private ILiteCollection<IDataStoreItem> _collection; + + public string Name { get; private set; } + + public LiteDBDataStoreCollection(ILiteCollection<IDataStoreItem> collection) + { + _collection = collection; + } + + public void Put<T>(string key, T value) + { + Put(key, (object)value); + } + + public void Put(string key, object value) + { + Put(key, DataStoreHelper.GetDataType(value), value); + } + + public void Put(string key, DataType type, object value) + { + _collection.Upsert(new LiteDBDataStoreItem() + { + Key = key, + Date = DateTime.UtcNow, + Type = type, + Value = value + }); + } + + public object Get(string key) + { + var item = _collection.FindById(key); + + if (item == null) + { + throw new KeyNotFoundException("The specified key was not found on the data store."); + } + + return item.Value; + } + + public T Get<T>(string key) + { + return (T)Convert.ChangeType(Get(key), typeof(T)); + } + + public List<IDataStoreItem> GetAll() + { + return _collection.FindAll().ToList(); + } + + public void Delete(string key) + { + _collection.Delete(key); + } + + public void DeleteAll() + { + _collection.DeleteMany(x => true); + } + + public int Count() + { + return _collection.Count(); + } + + public IDataStoreItem GetItem(string key) + { + return _collection.FindById(key); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs new file mode 100644 index 000000000..6a5a44462 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreItem.cs @@ -0,0 +1,23 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Lite +{ + public class LiteDBDataStoreItem : IDataStoreItem + { + [BsonId] + public string Key { get; set; } + public DataType Type { get; set; } + public object Value { get; set; } + public DateTime Date { get; set; } + + public override string ToString() + { + return $"{Key}: {Value}"; + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs new file mode 100644 index 000000000..25abd91ab --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.LiteDB/LiteDBDataStoreManager.cs @@ -0,0 +1,47 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Lite +{ + public class LiteDBDataStoreManager : IDataStoreManager + { + private bool _disposed; + private LiteDatabase _database; + + public String DatabasePath { get; private set; } + + public LiteDBDataStoreManager(String databasePath) + { + DatabasePath = databasePath; + Directory.CreateDirectory(Path.GetDirectoryName(DatabasePath)); + _database = new LiteDatabase($"Filename={DatabasePath}"); + _database.Pragma("TIMEOUT", 10); //Read Timeout + _database.Pragma("UTC_DATE", true); //Keep time as UTC when getting data + _database.Commit(); + } + + public IDataStoreCollection GetCollection(string name) + { + return new LiteDBDataStoreCollection(_database.GetCollection<IDataStoreItem>(name)); + } + + public List<String> GetCollectionNames() + { + return _database.GetCollectionNames().ToList(); + } + + public void Dispose() + { + if (!_disposed) + { + _disposed = true; + _database.Dispose(); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..f1b35f107 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.LiteDB/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Data Store LiteDB Implementation")] +[assembly: AssemblyVersion("2.0.4.1608")] +[assembly: ComVisible(false)]
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj b/Software/Visual_Studio/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj new file mode 100644 index 000000000..2bf561432 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.LiteDB/Tango.DataStore.Lite.csproj @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{FA96BC0C-4055-475C-9DCC-70A5A9436B10}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Tango.DataStore.Lite</RootNamespace> + <AssemblyName>Tango.DataStore.Lite</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="LiteDB, Version=5.0.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL"> + <HintPath>..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Runtime" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="..\Versioning\GlobalVersionInfo.cs"> + <Link>GlobalVersionInfo.cs</Link> + </Compile> + <Compile Include="LiteDBDataStoreCollection.cs" /> + <Compile Include="LiteDBDataStoreItem.cs" /> + <Compile Include="LiteDBDataStoreManager.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.LiteDB/packages.config b/Software/Visual_Studio/Tango.DataStore.LiteDB/packages.config new file mode 100644 index 000000000..9dcac7837 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.LiteDB/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="LiteDB" version="5.0.4" targetFramework="net461" /> +</packages>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore.Remote/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..808b25d41 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Data Store Remote Messages")] +[assembly: AssemblyVersion("2.0.4.1608")] +[assembly: ComVisible(false)]
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs new file mode 100644 index 000000000..84ba279fb --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreCountRequest + { + public String Collection { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs new file mode 100644 index 000000000..71d4e13b2 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCountResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreCountResponse + { + public int Count { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs new file mode 100644 index 000000000..ab5406611 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreDeleteAllRequest + { + public String Collection { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs new file mode 100644 index 000000000..b5ddc0b64 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteAllResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreDeleteAllResponse + { + + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs new file mode 100644 index 000000000..13d400154 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreDeleteRequest + { + public String Collection { get; set; } + public String Key { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs new file mode 100644 index 000000000..07bb40a8b --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreDeleteResponse.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreDeleteResponse + { + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs new file mode 100644 index 000000000..747a5cb2f --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllRequest + { + public String Collection { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs new file mode 100644 index 000000000..98848924c --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllResponse + { + public List<IDataStoreItem> Items { get; set; } + + public RemoteDataStoreGetAllResponse() + { + Items = new List<IDataStoreItem>(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs new file mode 100644 index 000000000..6299f7512 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetCollectionNamesRequest + { + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs new file mode 100644 index 000000000..fe98b73fc --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetCollectionNamesResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetCollectionNamesResponse + { + public List<String> Names { get; set; } + + public RemoteDataStoreGetCollectionNamesResponse() + { + Names = new List<string>(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs new file mode 100644 index 000000000..8bd6470f9 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetItemRequest + { + public String Collection { get; set; } + public String Key { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs new file mode 100644 index 000000000..ebd19eb4f --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetItemResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetItemResponse + { + public IDataStoreItem Item { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs new file mode 100644 index 000000000..1244523b3 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetRequest + { + public String Collection { get; set; } + public String Key { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs new file mode 100644 index 000000000..a3c5eb99c --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetResponse + { + public Object Value { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs new file mode 100644 index 000000000..6ea13bf6b --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutRequest.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStorePutRequest + { + public String Collection { get; set; } + public DataType DataType { get; set; } + public String Key { get; set; } + public Object Value { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs new file mode 100644 index 000000000..7dd92490a --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStorePutResponse.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStorePutResponse + { + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj b/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj new file mode 100644 index 000000000..b60d91d71 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Tango.DataStore.Remote</RootNamespace> + <AssemblyName>Tango.DataStore.Remote</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="..\Versioning\GlobalVersionInfo.cs"> + <Link>GlobalVersionInfo.cs</Link> + </Compile> + <Compile Include="RemoteDataStoreCountRequest.cs" /> + <Compile Include="RemoteDataStoreCountResponse.cs" /> + <Compile Include="RemoteDataStoreDeleteAllRequest.cs" /> + <Compile Include="RemoteDataStoreDeleteAllResponse.cs" /> + <Compile Include="RemoteDataStoreDeleteRequest.cs" /> + <Compile Include="RemoteDataStoreDeleteResponse.cs" /> + <Compile Include="RemoteDataStoreGetAllRequest.cs" /> + <Compile Include="RemoteDataStoreGetAllResponse.cs" /> + <Compile Include="RemoteDataStoreGetCollectionNamesRequest.cs" /> + <Compile Include="RemoteDataStoreGetCollectionNamesResponse.cs" /> + <Compile Include="RemoteDataStoreGetItemRequest.cs" /> + <Compile Include="RemoteDataStoreGetItemResponse.cs" /> + <Compile Include="RemoteDataStoreGetRequest.cs" /> + <Compile Include="RemoteDataStoreGetResponse.cs" /> + <Compile Include="RemoteDataStorePutRequest.cs" /> + <Compile Include="RemoteDataStorePutResponse.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs new file mode 100644 index 000000000..56afb15b7 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + public static class DataStoreHelper + { + public static DataType GetDataType(Object value) + { + return GetDataType(value.GetType()); + } + + public static DataType GetDataType(Type type) + { + if (type == typeof(Int32)) + { + return DataType.Int32; + } + else if (type == typeof(float)) + { + return DataType.Float; + } + else if (type == typeof(double)) + { + return DataType.Double; + } + else if (type == typeof(String)) + { + return DataType.String; + } + else if (type == typeof(bool)) + { + return DataType.Boolean; + } + else if (type == typeof(byte[])) + { + return DataType.Bytes; + } + + throw new NotSupportedException($"The specified type '{type.Name}' is not supported by the data store."); + } + + public static Type GetType(DataType type) + { + switch (type) + { + case DataType.Boolean: + return typeof(bool); + case DataType.Bytes: + return typeof(byte[]); + case DataType.Double: + return typeof(double); + case DataType.Float: + return typeof(float); + case DataType.Int32: + return typeof(Int32); + case DataType.String: + return typeof(String); + } + + throw new NotSupportedException("The specified data type is not supported."); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore/DataType.cs b/Software/Visual_Studio/Tango.DataStore/DataType.cs new file mode 100644 index 000000000..18de1107f --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore/DataType.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + public enum DataType + { + Int32, + Float, + Double, + Boolean, + String, + Bytes + } +} diff --git a/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs new file mode 100644 index 000000000..bbb86639b --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore/IDataStoreCollection.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + public interface IDataStoreCollection + { + String Name { get; } + void Put(String key, Object value); + void Put<T>(String key, T value); + void Put(String key, DataType type, Object value); + Object Get(String key); + T Get<T>(String key); + IDataStoreItem GetItem(String key); + List<IDataStoreItem> GetAll(); + void Delete(String key); + void DeleteAll(); + int Count(); + } +} diff --git a/Software/Visual_Studio/Tango.DataStore/IDataStoreItem.cs b/Software/Visual_Studio/Tango.DataStore/IDataStoreItem.cs new file mode 100644 index 000000000..e27030321 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore/IDataStoreItem.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + public interface IDataStoreItem + { + String Key { get; set; } + DataType Type { get; set; } + Object Value { get; set; } + DateTime Date { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore/IDataStoreManager.cs b/Software/Visual_Studio/Tango.DataStore/IDataStoreManager.cs new file mode 100644 index 000000000..3b7b7d0f1 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore/IDataStoreManager.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore +{ + public interface IDataStoreManager : IDisposable + { + IDataStoreCollection GetCollection(String name); + List<String> GetCollectionNames(); + } +} diff --git a/Software/Visual_Studio/Tango.DataStore/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..8e9365e03 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Data Store Library")] +[assembly: AssemblyVersion("2.0.4.1608")] +[assembly: ComVisible(false)]
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore/Tango.DataStore.csproj b/Software/Visual_Studio/Tango.DataStore/Tango.DataStore.csproj new file mode 100644 index 000000000..2411e3b45 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore/Tango.DataStore.csproj @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{E0364DFA-0721-4637-9D32-9D22AAC109D6}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Tango.DataStore</RootNamespace> + <AssemblyName>Tango.DataStore</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="..\Versioning\GlobalVersionInfo.cs"> + <Link>GlobalVersionInfo.cs</Link> + </Compile> + <Compile Include="DataStoreHelper.cs" /> + <Compile Include="IDataStoreItem.cs" /> + <Compile Include="DataType.cs" /> + <Compile Include="IDataStoreCollection.cs" /> + <Compile Include="IDataStoreManager.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 8ab5bd553..0c47f5e34 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -35,6 +35,7 @@ using Tango.PMR.MachineStatus; using Tango.PMR.Power; using Tango.PMR.ThreadLoading; using Tango.PMR.IFS; +using Tango.PMR.DataStore; namespace Tango.Emulations.Emulators { @@ -1773,6 +1774,252 @@ namespace Tango.Emulations.Emulators await Transporter.SendResponse<StartThreadLoadingResponse>(new StartThreadLoadingResponse() { State = state, Message = $"{state.ToString()}", ErrorReason = "Fake emulator error" }, _threadLoadingToken); } + public async void PerformDataStoreTest() + { + LogManager.Log("Starting data store test..."); + + { + try + { + LogManager.Log("Testing Int32..."); + + var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() + { + Collection = "TEST", + Item = new DataStoreItem() + { + Key = "int", + DataType = DataType.Int32, + Int32Value = 100 + } + }); + + if (response.Container.Error != ErrorCode.None) + { + LogManager.Log("Put Failed."); + LogManager.Log(response.ToJsonString()); + } + else + { + var res = await Transporter.SendRequest<GetDataStoreItemRequest, GetDataStoreItemResponse>(new GetDataStoreItemRequest() + { + Collection = "TEST", + Key = "int" + }); + + LogManager.Log(res.Container.Error != ErrorCode.None ? "Get Failed." : "Passed."); + + LogManager.Log(res.ToJsonString()); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed."); + } + } + + { + try + { + LogManager.Log("Testing float..."); + + var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() + { + Collection = "TEST", + Item = new DataStoreItem() + { + Key = "float", + DataType = DataType.Float, + FloatValue = 101f + } + }); + + if (response.Container.Error != ErrorCode.None) + { + LogManager.Log("Put Failed."); + LogManager.Log(response.ToJsonString()); + } + else + { + var res = await Transporter.SendRequest<GetDataStoreItemRequest, GetDataStoreItemResponse>(new GetDataStoreItemRequest() + { + Collection = "TEST", + Key = "float" + }); + + LogManager.Log(res.Container.Error != ErrorCode.None ? "Get Failed." : "Passed."); + + LogManager.Log(res.ToJsonString()); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed."); + } + } + + { + try + { + LogManager.Log("Testing double..."); + + var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() + { + Collection = "TEST", + Item = new DataStoreItem() + { + Key = "double", + DataType = DataType.Double, + DoubleValue = 102d + } + }); + + if (response.Container.Error != ErrorCode.None) + { + LogManager.Log("Put Failed."); + LogManager.Log(response.ToJsonString()); + } + else + { + var res = await Transporter.SendRequest<GetDataStoreItemRequest, GetDataStoreItemResponse>(new GetDataStoreItemRequest() + { + Collection = "TEST", + Key = "double" + }); + + LogManager.Log(res.Container.Error != ErrorCode.None ? "Get Failed." : "Passed."); + + LogManager.Log(res.ToJsonString()); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed."); + } + } + + { + try + { + LogManager.Log("Testing boolean..."); + + var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() + { + Collection = "TEST", + Item = new DataStoreItem() + { + Key = "bool", + DataType = DataType.Boolean, + BooleanValue = true + } + }); + + if (response.Container.Error != ErrorCode.None) + { + LogManager.Log("Put Failed."); + LogManager.Log(response.ToJsonString()); + } + else + { + var res = await Transporter.SendRequest<GetDataStoreItemRequest, GetDataStoreItemResponse>(new GetDataStoreItemRequest() + { + Collection = "TEST", + Key = "bool" + }); + + LogManager.Log(res.Container.Error != ErrorCode.None ? "Get Failed." : "Passed."); + + LogManager.Log(res.ToJsonString()); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed."); + } + } + + { + try + { + LogManager.Log("Testing string..."); + + var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() + { + Collection = "TEST", + Item = new DataStoreItem() + { + Key = "string", + DataType = DataType.String, + StringValue = "String Value" + } + }); + + if (response.Container.Error != ErrorCode.None) + { + LogManager.Log("Put Failed."); + LogManager.Log(response.ToJsonString()); + } + else + { + var res = await Transporter.SendRequest<GetDataStoreItemRequest, GetDataStoreItemResponse>(new GetDataStoreItemRequest() + { + Collection = "TEST", + Key = "string" + }); + + LogManager.Log(res.Container.Error != ErrorCode.None ? "Get Failed." : "Passed."); + + LogManager.Log(res.ToJsonString()); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed."); + } + } + + { + try + { + LogManager.Log("Testing bytes..."); + + var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(new PutDataStoreItemRequest() + { + Collection = "TEST", + Item = new DataStoreItem() + { + Key = "bytes", + DataType = DataType.Bytes, + BytesValue = ByteString.CopyFromUtf8("Bytes TEST TEST TEST"), + } + }); + + if (response.Container.Error != ErrorCode.None) + { + LogManager.Log("Put Failed."); + LogManager.Log(response.ToJsonString()); + } + else + { + var res = await Transporter.SendRequest<GetDataStoreItemRequest, GetDataStoreItemResponse>(new GetDataStoreItemRequest() + { + Collection = "TEST", + Key = "bytes" + }); + + LogManager.Log(res.Container.Error != ErrorCode.None ? "Get Failed." : "Passed."); + + LogManager.Log(res.Message.Item.BytesValue.ToStringUtf8()); + LogManager.Log(res.ToJsonString()); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed."); + } + } + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.PMR/Common/ErrorCode.cs b/Software/Visual_Studio/Tango.PMR/Common/ErrorCode.cs index 057820787..98931d0a6 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/ErrorCode.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/ErrorCode.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static ErrorCodeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "Cg9FcnJvckNvZGUucHJvdG8SEFRhbmdvLlBNUi5Db21tb24qsgwKCUVycm9y", + "Cg9FcnJvckNvZGUucHJvdG8SEFRhbmdvLlBNUi5Db21tb24q5AwKCUVycm9y", "Q29kZRIICgROT05FEAASEQoNR0VORVJBTF9FUlJPUhABEgsKB0JBRF9DUkMQ", "AhIeChpJTlZBTElEX0RJR0lUQUxfUElOX05VTUJFUhADEhsKF1VOQVVUSE9S", "SVpFRF9DT05ORUNUSU9OEAQSHwobQ09OVElOVU9VU19SRVNQT05TRV9BQk9S", @@ -58,7 +58,9 @@ namespace Tango.PMR.Common { "TklUSUFMX0JMT1dFUl9GQUlMRUQQuxcSLwoqUE9XRVJfVVBfRElTUEVOU0VS", "X1BSRVNTVVJFX0JVSUxEVVBfRkFJTEVEELwXEiAKG1BPV0VSX1VQX05PX1RI", "UkVBRF9ERVRFQ1RFRBC9FxIfChpQT1dFUl9VUF9OT19QUk9DRVNTX1BBUkFN", - "UxC+F0IcChpjb20udHdpbmUudGFuZ28ucG1yLmNvbW1vbmIGcHJvdG8z")); + "UxC+FxIcChdHRU5FUkFMX0RBVEFTVE9SRV9FUlJPUhCgHxISCg1LRVlfTk9U", + "X0ZPVU5EEKEfQhwKGmNvbS50d2luZS50YW5nby5wbXIuY29tbW9uYgZwcm90", + "bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.ErrorCode), }, null)); @@ -158,6 +160,11 @@ namespace Tango.PMR.Common { [pbr::OriginalName("POWER_UP_DISPENSER_PRESSURE_BUILDUP_FAILED")] PowerUpDispenserPressureBuildupFailed = 3004, [pbr::OriginalName("POWER_UP_NO_THREAD_DETECTED")] PowerUpNoThreadDetected = 3005, [pbr::OriginalName("POWER_UP_NO_PROCESS_PARAMS")] PowerUpNoProcessParams = 3006, + /// <summary> + ///DataStore + /// </summary> + [pbr::OriginalName("GENERAL_DATASTORE_ERROR")] GeneralDatastoreError = 4000, + [pbr::OriginalName("KEY_NOT_FOUND")] KeyNotFound = 4001, } #endregion diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index d2908fa53..2ef40336c 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static MessageTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiriPAoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbircPQoLTWVz", "c2FnZVR5cGUSCAoETm9uZRAAEhEKDUVycm9yUmVzcG9uc2UQARIUChBDYWxj", "dWxhdGVSZXF1ZXN0EAMSFQoRQ2FsY3VsYXRlUmVzcG9uc2UQBBITCg9Qcm9n", "cmVzc1JlcXVlc3QQBRIUChBQcm9ncmVzc1Jlc3BvbnNlEAYSHAoYU3R1YkNh", @@ -195,8 +195,11 @@ namespace Tango.PMR.Common { "dBD8VRIeChlTdG9wVGhyZWFkTG9hZGluZ1Jlc3BvbnNlEP1VEhwKF1RyeVRo", "cmVhZExvYWRpbmdSZXF1ZXN0EP5VEh0KGFRyeVRocmVhZExvYWRpbmdSZXNw", "b25zZRD/VRIhChxTdGFydElua0ZpbGxpbmdTdGF0dXNSZXF1ZXN0EOBdEiIK", - "HVN0YXJ0SW5rRmlsbGluZ1N0YXR1c1Jlc3BvbnNlEOFdQhwKGmNvbS50d2lu", - "ZS50YW5nby5wbXIuY29tbW9uYgZwcm90bzM=")); + "HVN0YXJ0SW5rRmlsbGluZ1N0YXR1c1Jlc3BvbnNlEOFdEhwKF1B1dERhdGFT", + "dG9yZUl0ZW1SZXF1ZXN0EMhlEh0KGFB1dERhdGFTdG9yZUl0ZW1SZXNwb25z", + "ZRDJZRIcChdHZXREYXRhU3RvcmVJdGVtUmVxdWVzdBDKZRIdChhHZXREYXRh", + "U3RvcmVJdGVtUmVzcG9uc2UQy2VCHAoaY29tLnR3aW5lLnRhbmdvLnBtci5j", + "b21tb25iBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -519,6 +522,13 @@ namespace Tango.PMR.Common { /// </summary> [pbr::OriginalName("StartInkFillingStatusRequest")] StartInkFillingStatusRequest = 12000, [pbr::OriginalName("StartInkFillingStatusResponse")] StartInkFillingStatusResponse = 12001, + /// <summary> + ///DataStore + /// </summary> + [pbr::OriginalName("PutDataStoreItemRequest")] PutDataStoreItemRequest = 13000, + [pbr::OriginalName("PutDataStoreItemResponse")] PutDataStoreItemResponse = 13001, + [pbr::OriginalName("GetDataStoreItemRequest")] GetDataStoreItemRequest = 13002, + [pbr::OriginalName("GetDataStoreItemResponse")] GetDataStoreItemResponse = 13003, } #endregion diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItem.cs b/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItem.cs new file mode 100644 index 000000000..a6d2fe860 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItem.cs @@ -0,0 +1,359 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DataStoreItem.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.DataStore { + + /// <summary>Holder for reflection information generated from DataStoreItem.proto</summary> + public static partial class DataStoreItemReflection { + + #region Descriptor + /// <summary>File descriptor for DataStoreItem.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DataStoreItemReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChNEYXRhU3RvcmVJdGVtLnByb3RvEhNUYW5nby5QTVIuRGF0YVN0b3JlGg5E", + "YXRhVHlwZS5wcm90byLJAQoNRGF0YVN0b3JlSXRlbRILCgNLZXkYASABKAkS", + "LwoIRGF0YVR5cGUYAiABKA4yHS5UYW5nby5QTVIuRGF0YVN0b3JlLkRhdGFU", + "eXBlEhIKCkludDMyVmFsdWUYAyABKAUSEgoKRmxvYXRWYWx1ZRgEIAEoAhIT", + "CgtEb3VibGVWYWx1ZRgFIAEoARIUCgxCb29sZWFuVmFsdWUYBiABKAgSEwoL", + "U3RyaW5nVmFsdWUYByABKAkSEgoKQnl0ZXNWYWx1ZRgIIAEoDEIfCh1jb20u", + "dHdpbmUudGFuZ28ucG1yLmRhdGFzdG9yZWIGcHJvdG8z")); + 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) + })); + } + #endregion + + } + #region Messages + public sealed partial class DataStoreItem : pb::IMessage<DataStoreItem> { + private static readonly pb::MessageParser<DataStoreItem> _parser = new pb::MessageParser<DataStoreItem>(() => new DataStoreItem()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<DataStoreItem> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.DataStore.DataStoreItemReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItem() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItem(DataStoreItem other) : this() { + key_ = other.key_; + dataType_ = other.dataType_; + int32Value_ = other.int32Value_; + floatValue_ = other.floatValue_; + doubleValue_ = other.doubleValue_; + booleanValue_ = other.booleanValue_; + stringValue_ = other.stringValue_; + bytesValue_ = other.bytesValue_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItem Clone() { + 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; + private global::Tango.PMR.DataStore.DataType dataType_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.DataStore.DataType DataType { + get { return dataType_; } + set { + dataType_ = value; + } + } + + /// <summary>Field number for the "Int32Value" field.</summary> + public const int Int32ValueFieldNumber = 3; + private int int32Value_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Int32Value { + get { return int32Value_; } + set { + int32Value_ = value; + } + } + + /// <summary>Field number for the "FloatValue" field.</summary> + public const int FloatValueFieldNumber = 4; + private float floatValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float FloatValue { + get { return floatValue_; } + set { + floatValue_ = value; + } + } + + /// <summary>Field number for the "DoubleValue" field.</summary> + public const int DoubleValueFieldNumber = 5; + private double doubleValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleValue { + get { return doubleValue_; } + set { + doubleValue_ = value; + } + } + + /// <summary>Field number for the "BooleanValue" field.</summary> + public const int BooleanValueFieldNumber = 6; + private bool booleanValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool BooleanValue { + get { return booleanValue_; } + set { + booleanValue_ = value; + } + } + + /// <summary>Field number for the "StringValue" field.</summary> + public const int StringValueFieldNumber = 7; + private string stringValue_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string StringValue { + get { return stringValue_; } + set { + stringValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "BytesValue" field.</summary> + public const int BytesValueFieldNumber = 8; + private pb::ByteString bytesValue_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString BytesValue { + get { return bytesValue_; } + set { + bytesValue_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DataStoreItem); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DataStoreItem other) { + if (ReferenceEquals(other, null)) { + return false; + } + 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; + if (DoubleValue != other.DoubleValue) return false; + if (BooleanValue != other.BooleanValue) return false; + if (StringValue != other.StringValue) return false; + if (BytesValue != other.BytesValue) return false; + return true; + } + + [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(); + if (DoubleValue != 0D) hash ^= DoubleValue.GetHashCode(); + if (BooleanValue != false) hash ^= BooleanValue.GetHashCode(); + if (StringValue.Length != 0) hash ^= StringValue.GetHashCode(); + if (BytesValue.Length != 0) hash ^= BytesValue.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [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.WriteEnum((int) DataType); + } + if (Int32Value != 0) { + output.WriteRawTag(24); + output.WriteInt32(Int32Value); + } + if (FloatValue != 0F) { + output.WriteRawTag(37); + output.WriteFloat(FloatValue); + } + if (DoubleValue != 0D) { + output.WriteRawTag(41); + output.WriteDouble(DoubleValue); + } + if (BooleanValue != false) { + output.WriteRawTag(48); + output.WriteBool(BooleanValue); + } + if (StringValue.Length != 0) { + output.WriteRawTag(58); + output.WriteString(StringValue); + } + if (BytesValue.Length != 0) { + output.WriteRawTag(66); + output.WriteBytes(BytesValue); + } + } + + [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); + } + if (Int32Value != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Int32Value); + } + if (FloatValue != 0F) { + size += 1 + 4; + } + if (DoubleValue != 0D) { + size += 1 + 8; + } + if (BooleanValue != false) { + size += 1 + 1; + } + if (StringValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(StringValue); + } + if (BytesValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(BytesValue); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DataStoreItem other) { + if (other == null) { + return; + } + if (other.Key.Length != 0) { + Key = other.Key; + } + if (other.DataType != 0) { + DataType = other.DataType; + } + if (other.Int32Value != 0) { + Int32Value = other.Int32Value; + } + if (other.FloatValue != 0F) { + FloatValue = other.FloatValue; + } + if (other.DoubleValue != 0D) { + DoubleValue = other.DoubleValue; + } + if (other.BooleanValue != false) { + BooleanValue = other.BooleanValue; + } + if (other.StringValue.Length != 0) { + StringValue = other.StringValue; + } + if (other.BytesValue.Length != 0) { + BytesValue = other.BytesValue; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Key = input.ReadString(); + break; + } + case 16: { + dataType_ = (global::Tango.PMR.DataStore.DataType) input.ReadEnum(); + break; + } + case 24: { + Int32Value = input.ReadInt32(); + break; + } + case 37: { + FloatValue = input.ReadFloat(); + break; + } + case 41: { + DoubleValue = input.ReadDouble(); + break; + } + case 48: { + BooleanValue = input.ReadBool(); + break; + } + case 58: { + StringValue = input.ReadString(); + break; + } + case 66: { + BytesValue = input.ReadBytes(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/DataType.cs b/Software/Visual_Studio/Tango.PMR/DataStore/DataType.cs new file mode 100644 index 000000000..0c2a2c1ab --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/DataStore/DataType.cs @@ -0,0 +1,50 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DataType.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.DataStore { + + /// <summary>Holder for reflection information generated from DataType.proto</summary> + public static partial class DataTypeReflection { + + #region Descriptor + /// <summary>File descriptor for DataType.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DataTypeReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Cg5EYXRhVHlwZS5wcm90bxITVGFuZ28uUE1SLkRhdGFTdG9yZSpQCghEYXRh", + "VHlwZRIJCgVJbnQzMhAAEgkKBUZsb2F0EAESCgoGRG91YmxlEAISCwoHQm9v", + "bGVhbhADEgoKBlN0cmluZxAEEgkKBUJ5dGVzEAVCHwodY29tLnR3aW5lLnRh", + "bmdvLnBtci5kYXRhc3RvcmViBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.DataStore.DataType), }, null)); + } + #endregion + + } + #region Enums + public enum DataType { + [pbr::OriginalName("Int32")] Int32 = 0, + [pbr::OriginalName("Float")] Float = 1, + [pbr::OriginalName("Double")] Double = 2, + [pbr::OriginalName("Boolean")] Boolean = 3, + [pbr::OriginalName("String")] String = 4, + [pbr::OriginalName("Bytes")] Bytes = 5, + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemRequest.cs b/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemRequest.cs new file mode 100644 index 000000000..6c6d20b72 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemRequest.cs @@ -0,0 +1,188 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: GetDataStoreItemRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.DataStore { + + /// <summary>Holder for reflection information generated from GetDataStoreItemRequest.proto</summary> + public static partial class GetDataStoreItemRequestReflection { + + #region Descriptor + /// <summary>File descriptor for GetDataStoreItemRequest.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static GetDataStoreItemRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch1HZXREYXRhU3RvcmVJdGVtUmVxdWVzdC5wcm90bxITVGFuZ28uUE1SLkRh", + "dGFTdG9yZSI6ChdHZXREYXRhU3RvcmVJdGVtUmVxdWVzdBISCgpDb2xsZWN0", + "aW9uGAEgASgJEgsKA0tleRgCIAEoCUIfCh1jb20udHdpbmUudGFuZ28ucG1y", + "LmRhdGFzdG9yZWIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + 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) + })); + } + #endregion + + } + #region Messages + public sealed partial class GetDataStoreItemRequest : pb::IMessage<GetDataStoreItemRequest> { + private static readonly pb::MessageParser<GetDataStoreItemRequest> _parser = new pb::MessageParser<GetDataStoreItemRequest>(() => new GetDataStoreItemRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<GetDataStoreItemRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.DataStore.GetDataStoreItemRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GetDataStoreItemRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GetDataStoreItemRequest(GetDataStoreItemRequest other) : this() { + collection_ = other.collection_; + key_ = other.key_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GetDataStoreItemRequest Clone() { + return new GetDataStoreItemRequest(this); + } + + /// <summary>Field number for the "Collection" field.</summary> + public const int CollectionFieldNumber = 1; + private string collection_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Collection { + get { return collection_; } + set { + collection_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <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"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as GetDataStoreItemRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(GetDataStoreItemRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Collection != other.Collection) return false; + if (Key != other.Key) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Collection.Length != 0) hash ^= Collection.GetHashCode(); + if (Key.Length != 0) hash ^= Key.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Collection.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Collection); + } + if (Key.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Key); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Collection.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Collection); + } + if (Key.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(GetDataStoreItemRequest other) { + if (other == null) { + return; + } + if (other.Collection.Length != 0) { + Collection = other.Collection; + } + if (other.Key.Length != 0) { + Key = other.Key; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Collection = input.ReadString(); + break; + } + case 18: { + Key = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemResponse.cs b/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemResponse.cs new file mode 100644 index 000000000..892f197d8 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/DataStore/GetDataStoreItemResponse.cs @@ -0,0 +1,167 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: GetDataStoreItemResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.DataStore { + + /// <summary>Holder for reflection information generated from GetDataStoreItemResponse.proto</summary> + public static partial class GetDataStoreItemResponseReflection { + + #region Descriptor + /// <summary>File descriptor for GetDataStoreItemResponse.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static GetDataStoreItemResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5HZXREYXRhU3RvcmVJdGVtUmVzcG9uc2UucHJvdG8SE1RhbmdvLlBNUi5E", + "YXRhU3RvcmUaE0RhdGFTdG9yZUl0ZW0ucHJvdG8iTAoYR2V0RGF0YVN0b3Jl", + "SXRlbVJlc3BvbnNlEjAKBEl0ZW0YASABKAsyIi5UYW5nby5QTVIuRGF0YVN0", + "b3JlLkRhdGFTdG9yZUl0ZW1CHwodY29tLnR3aW5lLnRhbmdvLnBtci5kYXRh", + "c3RvcmViBnByb3RvMw==")); + 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) + })); + } + #endregion + + } + #region Messages + public sealed partial class GetDataStoreItemResponse : pb::IMessage<GetDataStoreItemResponse> { + private static readonly pb::MessageParser<GetDataStoreItemResponse> _parser = new pb::MessageParser<GetDataStoreItemResponse>(() => new GetDataStoreItemResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<GetDataStoreItemResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.DataStore.GetDataStoreItemResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GetDataStoreItemResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GetDataStoreItemResponse(GetDataStoreItemResponse other) : this() { + Item = other.item_ != null ? other.Item.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public GetDataStoreItemResponse Clone() { + return new GetDataStoreItemResponse(this); + } + + /// <summary>Field number for the "Item" field.</summary> + public const int ItemFieldNumber = 1; + private global::Tango.PMR.DataStore.DataStoreItem item_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.DataStore.DataStoreItem Item { + get { return item_; } + set { + item_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as GetDataStoreItemResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(GetDataStoreItemResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Item, other.Item)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (item_ != null) hash ^= Item.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (item_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Item); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (item_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Item); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(GetDataStoreItemResponse other) { + if (other == null) { + return; + } + if (other.item_ != null) { + if (item_ == null) { + item_ = new global::Tango.PMR.DataStore.DataStoreItem(); + } + Item.MergeFrom(other.Item); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + if (item_ == null) { + item_ = new global::Tango.PMR.DataStore.DataStoreItem(); + } + input.ReadMessage(item_); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemRequest.cs b/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemRequest.cs new file mode 100644 index 000000000..7281b4c9c --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemRequest.cs @@ -0,0 +1,195 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: PutDataStoreItemRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.DataStore { + + /// <summary>Holder for reflection information generated from PutDataStoreItemRequest.proto</summary> + public static partial class PutDataStoreItemRequestReflection { + + #region Descriptor + /// <summary>File descriptor for PutDataStoreItemRequest.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static PutDataStoreItemRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch1QdXREYXRhU3RvcmVJdGVtUmVxdWVzdC5wcm90bxITVGFuZ28uUE1SLkRh", + "dGFTdG9yZRoTRGF0YVN0b3JlSXRlbS5wcm90byJfChdQdXREYXRhU3RvcmVJ", + "dGVtUmVxdWVzdBISCgpDb2xsZWN0aW9uGAEgASgJEjAKBEl0ZW0YAiABKAsy", + "Ii5UYW5nby5QTVIuRGF0YVN0b3JlLkRhdGFTdG9yZUl0ZW1CHwodY29tLnR3", + "aW5lLnRhbmdvLnBtci5kYXRhc3RvcmViBnByb3RvMw==")); + 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) + })); + } + #endregion + + } + #region Messages + public sealed partial class PutDataStoreItemRequest : pb::IMessage<PutDataStoreItemRequest> { + private static readonly pb::MessageParser<PutDataStoreItemRequest> _parser = new pb::MessageParser<PutDataStoreItemRequest>(() => new PutDataStoreItemRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<PutDataStoreItemRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.DataStore.PutDataStoreItemRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PutDataStoreItemRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PutDataStoreItemRequest(PutDataStoreItemRequest other) : this() { + collection_ = other.collection_; + Item = other.item_ != null ? other.Item.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PutDataStoreItemRequest Clone() { + return new PutDataStoreItemRequest(this); + } + + /// <summary>Field number for the "Collection" field.</summary> + public const int CollectionFieldNumber = 1; + private string collection_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Collection { + get { return collection_; } + set { + collection_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "Item" field.</summary> + public const int ItemFieldNumber = 2; + private global::Tango.PMR.DataStore.DataStoreItem item_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.DataStore.DataStoreItem Item { + get { return item_; } + set { + item_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as PutDataStoreItemRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(PutDataStoreItemRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Collection != other.Collection) return false; + if (!object.Equals(Item, other.Item)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Collection.Length != 0) hash ^= Collection.GetHashCode(); + if (item_ != null) hash ^= Item.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Collection.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Collection); + } + if (item_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Item); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Collection.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Collection); + } + if (item_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Item); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(PutDataStoreItemRequest other) { + if (other == null) { + return; + } + if (other.Collection.Length != 0) { + Collection = other.Collection; + } + if (other.item_ != null) { + if (item_ == null) { + item_ = new global::Tango.PMR.DataStore.DataStoreItem(); + } + Item.MergeFrom(other.Item); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Collection = input.ReadString(); + break; + } + case 18: { + if (item_ == null) { + item_ = new global::Tango.PMR.DataStore.DataStoreItem(); + } + input.ReadMessage(item_); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemResponse.cs b/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemResponse.cs new file mode 100644 index 000000000..bd798cedf --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/DataStore/PutDataStoreItemResponse.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: PutDataStoreItemResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.DataStore { + + /// <summary>Holder for reflection information generated from PutDataStoreItemResponse.proto</summary> + public static partial class PutDataStoreItemResponseReflection { + + #region Descriptor + /// <summary>File descriptor for PutDataStoreItemResponse.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static PutDataStoreItemResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5QdXREYXRhU3RvcmVJdGVtUmVzcG9uc2UucHJvdG8SE1RhbmdvLlBNUi5E", + "YXRhU3RvcmUiGgoYUHV0RGF0YVN0b3JlSXRlbVJlc3BvbnNlQh8KHWNvbS50", + "d2luZS50YW5nby5wbXIuZGF0YXN0b3JlYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.PutDataStoreItemResponse), global::Tango.PMR.DataStore.PutDataStoreItemResponse.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class PutDataStoreItemResponse : pb::IMessage<PutDataStoreItemResponse> { + private static readonly pb::MessageParser<PutDataStoreItemResponse> _parser = new pb::MessageParser<PutDataStoreItemResponse>(() => new PutDataStoreItemResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<PutDataStoreItemResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.DataStore.PutDataStoreItemResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PutDataStoreItemResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PutDataStoreItemResponse(PutDataStoreItemResponse other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PutDataStoreItemResponse Clone() { + return new PutDataStoreItemResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as PutDataStoreItemResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(PutDataStoreItemResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(PutDataStoreItemResponse other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/CartridgeTagContent.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/CartridgeTagContent.cs index 70b4b48df..563f1d3f2 100644 --- a/Software/Visual_Studio/Tango.PMR/Diagnostics/CartridgeTagContent.cs +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/CartridgeTagContent.cs @@ -216,7 +216,7 @@ namespace Tango.PMR.Diagnostics { public const int TypeRevFieldNumber = 8; private uint typeRev_; /// <summary> - ///TBD � can be formulation # + ///TBD – can be formulation # /// </summary> [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public uint TypeRev { @@ -258,7 +258,7 @@ namespace Tango.PMR.Diagnostics { public const int InkBatchNoFieldNumber = 11; private string inkBatchNo_ = ""; /// <summary> - ///MFG batch No� + ///MFG batch No’ /// </summary> [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string InkBatchNo { diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index 1852068ea..adc8bbc21 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -78,6 +78,12 @@ <Compile Include="Connection\DisconnectResponse.cs" /> <Compile Include="Connection\KeepAliveRequest.cs" /> <Compile Include="Connection\KeepAliveResponse.cs" /> + <Compile Include="DataStore\DataStoreItem.cs" /> + <Compile Include="DataStore\DataType.cs" /> + <Compile Include="DataStore\GetDataStoreItemRequest.cs" /> + <Compile Include="DataStore\GetDataStoreItemResponse.cs" /> + <Compile Include="DataStore\PutDataStoreItemRequest.cs" /> + <Compile Include="DataStore\PutDataStoreItemResponse.cs" /> <Compile Include="Debugging\DebugDistributor.cs" /> <Compile Include="Debugging\DebugDistributorType.cs" /> <Compile Include="Debugging\DebugLogCategory.cs" /> @@ -476,7 +482,7 @@ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs new file mode 100644 index 000000000..4a7d55e1e --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs @@ -0,0 +1,82 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR; +using Tango.PMR.Embroidery; +using Tango.DataStore; +using Tango.DataStore.Lite; +using Tango.Core.IO; + +namespace Tango.UnitTesting.DataStore +{ + [TestClass] + [TestCategory("DataStore")] + public class DataStore_TST + { + [TestMethod] + public void LiteDB_DataStore_Working() + { + var tempFile = TemporaryManager.Default.CreateImaginaryFile(); + IDataStoreManager manager = new LiteDBDataStoreManager(tempFile); + IDataStoreCollection collection = manager.GetCollection("TEST"); + + { + collection.Put<int>("int", 10); + int value = collection.Get<int>("int"); + Assert.AreEqual<int>(value, 10); + } + + { + collection.Put<float>("float", 10f); + float value = collection.Get<float>("float"); + Assert.AreEqual<float>(value, 10f); + } + + { + collection.Put<double>("double", 10d); + double value = collection.Get<double>("double"); + Assert.AreEqual<double>(value, 10d); + } + + { + collection.Put<bool>("bool", true); + bool value = collection.Get<bool>("bool"); + Assert.AreEqual<bool>(value, true); + } + + { + collection.Put<string>("string", "some value"); + string value = collection.Get<string>("string"); + Assert.AreEqual<string>(value, "some value"); + } + + { + collection.Put<byte[]>("bytes", new byte[] { 255 }); + byte[] value = collection.Get<byte[]>("bytes"); + Assert.AreEqual<byte>(value[0], 255); + } + + Assert.IsTrue(collection.Count() == 6); + + Assert.ThrowsException<NotSupportedException>(() => collection.Put<DataStore_TST>("somekey", this)); + + collection.Delete("int"); + Assert.ThrowsException<KeyNotFoundException>(() => collection.Get<int>("int")); + + collection.Delete("float"); + Assert.ThrowsException<KeyNotFoundException>(() => collection.Get<float>("float")); + + Assert.IsTrue(collection.Count() == 4); + + collection.DeleteAll(); + Assert.IsTrue(collection.Count() == 0); + + manager.Dispose(); + tempFile.Delete(); + } + } +} diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs index 68232e512..651b46835 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs @@ -56,10 +56,7 @@ namespace Tango.UnitTesting.MachineService }).Result; //Should return setup information - var res5 = client.MachineSetup(new MachineSetupRequest() - { - SerialNumber = "0003", - }).GetAwaiter().GetResult(); + var res5 = client.MachineSetup(new MachineSetupRequest()).GetAwaiter().GetResult(); //Now get DEV data source using the machine studio client in order to validate the setup information. Tango.MachineStudio.Common.Web.MachineStudioWebClient msClient = new Tango.MachineStudio.Common.Web.MachineStudioWebClient(address, null); diff --git a/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs index 0fdd437f0..948bc630b 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs @@ -20,7 +20,7 @@ namespace Tango.UnitTesting { [TestClass] [TestCategory("Remote Runner")] - public class RemoteRunner_TST + public class RemoteRunner_TST { [TestMethod] public void Run_Remote_Runner_Connect_Upload_And_Execute_Process() @@ -80,7 +80,10 @@ namespace Tango.UnitTesting { UploadID = uploadResponse.UploadID, FileName = executeFileName, - }, TimeSpan.FromSeconds(30)).Result.Message; + }, new TransportRequestConfig() + { + Timeout = TimeSpan.FromSeconds(30), + }).Result.Message; Thread.Sleep(5000); diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index 09799c0ed..218652c1b 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -138,6 +138,7 @@ <Compile Include="AdvancedInstaller\AdvancedInstaller_TST.cs" /> <Compile Include="BL\DTO_TST.cs" /> <Compile Include="BL\HardwareConfiguration_TST.cs" /> + <Compile Include="DataStore\DataStore_TST.cs" /> <Compile Include="Integration\JobDescriptionFile_TST.cs" /> <Compile Include="Logging\Parsing_TST.cs" /> <Compile Include="Logging\SessionLoging_TST.cs" /> @@ -212,6 +213,14 @@ <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> </ProjectReference> + <ProjectReference Include="..\Tango.DataStore.LiteDB\Tango.DataStore.Lite.csproj"> + <Project>{fa96bc0c-4055-475c-9dcc-70a5a9436b10}</Project> + <Name>Tango.DataStore.Lite</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> <ProjectReference Include="..\Tango.Documents\Tango.Documents.csproj"> <Project>{ca87a608-7b17-4c98-88f2-42abee10f4c1}</Project> <Name>Tango.Documents</Name> @@ -306,7 +315,7 @@ <Import Project="..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" /> <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 diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 1697248ab..c77985b68 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -419,6 +419,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Git", "Tango.Git\Tang EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.Packages.Auth2", "PPC\UpdatePackages\Tango.PPC.Packages.Auth2\Tango.PPC.Packages.Auth2.csproj", "{EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore", "Tango.DataStore\Tango.DataStore.csproj", "{E0364DFA-0721-4637-9D32-9D22AAC109D6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Lite", "Tango.DataStore.LiteDB\Tango.DataStore.Lite.csproj", "{FA96BC0C-4055-475C-9DCC-70A5A9436B10}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Remote", "Tango.DataStore.Remote\Tango.DataStore.Remote.csproj", "{29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -3946,6 +3952,66 @@ Global {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90}.Release|x64.Build.0 = Release|Any CPU {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90}.Release|x86.ActiveCfg = Release|Any CPU {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90}.Release|x86.Build.0 = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|ARM.ActiveCfg = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|ARM.Build.0 = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|ARM64.Build.0 = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|x64.ActiveCfg = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|x64.Build.0 = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|x86.ActiveCfg = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Debug|x86.Build.0 = Debug|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|Any CPU.Build.0 = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|ARM.ActiveCfg = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|ARM.Build.0 = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|ARM64.ActiveCfg = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|ARM64.Build.0 = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|x64.ActiveCfg = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|x64.Build.0 = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|x86.ActiveCfg = Release|Any CPU + {E0364DFA-0721-4637-9D32-9D22AAC109D6}.Release|x86.Build.0 = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|ARM.ActiveCfg = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|ARM.Build.0 = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|ARM64.Build.0 = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|x64.ActiveCfg = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|x64.Build.0 = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|x86.ActiveCfg = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Debug|x86.Build.0 = Debug|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|Any CPU.Build.0 = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|ARM.ActiveCfg = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|ARM.Build.0 = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|ARM64.ActiveCfg = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|ARM64.Build.0 = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|x64.ActiveCfg = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|x64.Build.0 = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|x86.ActiveCfg = Release|Any CPU + {FA96BC0C-4055-475C-9DCC-70A5A9436B10}.Release|x86.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|ARM64.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x64.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x64.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x86.ActiveCfg = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Debug|x86.Build.0 = Debug|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|Any CPU.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM64.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|ARM64.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x64.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x64.Build.0 = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x86.ActiveCfg = Release|Any CPU + {29448F3C-9B3E-4DA6-8555-46A8B9A6B3AA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4091,12 +4157,12 @@ Global {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90} = {E728CBD9-1AF4-4814-A218-E4BD26E7EDEA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs index a66ed6b7e..b46b89a4a 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs @@ -138,6 +138,8 @@ namespace Tango.MachineEM.UI.ViewModels /// </summary> public RelayCommand AbortJobCommand { get; set; } + public RelayCommand PerformDataStoreTestCommand { get; set; } + #endregion #region Constructors @@ -187,6 +189,8 @@ namespace Tango.MachineEM.UI.ViewModels }; SelectedPort = Ports.First(); + + PerformDataStoreTestCommand = new RelayCommand(Emulator.PerformDataStoreTest); } #endregion diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml index 73a14b5b1..f553ec588 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml @@ -146,7 +146,6 @@ <Popup IsOpen="{Binding ElementName=toggleIFS,Path=IsChecked}" StaysOpen="True" PlacementTarget="{Binding ElementName=toggleIFS}" Placement="Bottom"> <controls:InkFillingStatusView Height="300" Width="210" DataContext="{Binding Emulator.InkFillingStatus}" /> </Popup> - <!--BUTTONS HERE--> <Button Padding="10 0 0 0" Margin="5" Height="45" HorizontalContentAlignment="Left" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding AbortJobCommand}"> <DockPanel> @@ -155,6 +154,14 @@ </DockPanel> </Button> + <Button Padding="10 0 0 0" Margin="5" Height="45" HorizontalContentAlignment="Left" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding PerformDataStoreTestCommand}"> + <DockPanel> + <fa:ImageAwesome Icon="Database" Width="16"></fa:ImageAwesome> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">DATASTORE TEST</TextBlock> + </DockPanel> + </Button> + <!--BUTTONS HERE--> + <DockPanel Margin="5 20 5 0"> <TextBlock FontSize="12" DockPanel.Dock="Top">Thread Loading State</TextBlock> <ComboBox Margin="0 5 0 0" ItemsSource="{Binding Source={x:Type threadLoading:ThreadLoadingState},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding ThreadLoadingState,Mode=OneWayToSource}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"></ComboBox> |
