public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log, [Inject] ITransformManager transformManager, [Inject] ILogger <ITransformManager> logger) { logger.LogInformation("Azure Function ExecuteTransform processed a request."); try { dynamic data = await req.Content.ReadAsAsync <object>(); string datastring = data.ToString(); //this data had better be serializable to ImportResultsContainer ImportResultsContainer irc = JsonConvert.DeserializeObject <ImportResultsContainer>(datastring); TransformResultsContainer trc = transformManager.TransformAll(irc); var response = req.CreateResponse(HttpStatusCode.OK, trc); return(response); } catch (System.Exception ex) { logger.LogError(ex, $"Error in Azure Function ExecuteTransform : {ex.Message}"); var response = req.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); return(response); } }
protected void Start() { transformManager = TransformManagerFactory.Instance.CreateInstance(Context.TransformManagerDescriptor, Context.TransformManagerParameters); transformManager.Context = Context; transformManager.ExtElemReferenceTransform = this.transform; transformManager.Update(); }
public void InitializeDataSource() { int SUCCESS = 0; ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.AccessCoarseLocation }, SUCCESS); // Load your license and key files // This tutorial assumes you have them contained in embedded resources named PublicKey.lic and License.lic, as part of // a solution with an output executable called AndroidSample. var assembly = Assembly.GetExecutingAssembly(); string key; using (Stream stream = assembly.GetManifestResourceStream("AndroidSample.APIKey.lic")) // Change the name of the .lic file accordingly { StreamReader sr = new StreamReader(stream); key = sr.ReadLine(); } string lic; using (Stream stream = assembly.GetManifestResourceStream("AndroidSample.License.lic")) // Change the name of the .lic file accordingly { StreamReader sr = new StreamReader(stream); lic = sr.ReadToEnd(); } // The API uses a factory method to create the data source of your application. // This creates the factory method, which will then give the data source for your platform. // In this case the platform is BT. var deviceSourceCreator = new DelsysAPI.Android.DeviceSourcePortable(key, lic); // Sets the output stream for debugging information from the API. This could be a file stream, // but in this example we simply use the Console.WriteLine output stream. deviceSourceCreator.SetDebugOutputStream(Console.WriteLine); // Here is where we tell the factory method what type of data source we want to receive, // which we then set a reference to for future use. DeviceSource = deviceSourceCreator.GetDataSource(SourceType.TRIGNO_BT); // Here we use the key and license we previously loaded. DeviceSource.Key = key; DeviceSource.License = lic; //Load source LoadDataSource(DeviceSource); // Create a reference to the first Pipeline (which was generated by the factory method above) // for easier access to various objects within the API. BTPipeline = PipelineController.Instance.PipelineIds[0]; TransformManager = PipelineController.Instance.PipelineIds[0].TransformManager; // Just setting up some of the necessary callbacks from the API. BTPipeline.CollectionStarted += CollectionStarted; BTPipeline.CollectionDataReady += CollectionDataReady; BTPipeline.CollectionComplete += CollectionComplete; BTPipeline.TrignoBtManager.ComponentAdded += ComponentAdded; BTPipeline.TrignoBtManager.ComponentLost += ComponentLost; BTPipeline.TrignoBtManager.ComponentRemoved += ComponentRemoved; BTPipeline.TrignoBtManager.ComponentScanComplete += ComponentScanComplete; // The component manager is how you reference specific / individual sensors so creating // a reference to it will shorten a lot of calls. var ComponentManager = PipelineController.Instance.PipelineIds[0].TrignoBtManager; }
protected void Start() { Hint = GameObject.Instantiate(Resources.Load <GameObject>("Hint"), this.transform); Hint.transform.localPosition = new Vector3(0, 0, 0); Hint.SetActive(false); transformManager = TransformManagerFactory.Instance.CreateInstance(Context.TransformManagerDescriptor, Context.TransformManagerParameters); transformManager.Context = Context; transformManager.ExtElemReferenceTransform = this.transform; transformManager.Update(); UpdateConditions(); }
public void LoadDataSource(IDelsysDevice ds) { PipelineController.Instance.AddPipeline(ds); BTPipeline = PipelineController.Instance.PipelineIds[0]; TransformManager = PipelineController.Instance.PipelineIds[0].TransformManager; BTPipeline.CollectionStarted += CollectionStarted; BTPipeline.CollectionDataReady += CollectionDataReady; BTPipeline.CollectionComplete += CollectionComplete; BTPipeline.TrignoBtManager.ComponentScanComplete += ComponentScanComplete; }
public void LoadDataSource(IDelsysDevice ds) { PipelineController.Instance.AddPipeline(ds); RFPipeline = PipelineController.Instance.PipelineIds[0]; TransformManager = PipelineController.Instance.PipelineIds[0].TransformManager; RFPipeline.TrignoRfManager.ComponentScanComplete += ComponentScanComplete; RFPipeline.CollectionStarted += CollectionStarted; RFPipeline.CollectionDataReady += CollectionDataReady; RFPipeline.CollectionComplete += CollectionComplete; RFPipeline.TrignoRfManager.ComponentAdded += ComponentAdded; RFPipeline.TrignoRfManager.ComponentLost += ComponentLost; RFPipeline.TrignoRfManager.ComponentRemoved += ComponentRemoved; }
public void LoadDataSource(IDelsysDevice ds) { PipelineController.Instance.AddPipeline(ds); BTPipeline = PipelineController.Instance.PipelineIds[0]; TransformManager = PipelineController.Instance.PipelineIds[0].TransformManager; // Device Filters allow you to specify which sensors to connect to foreach (var filter in DeviceFilters) { BTPipeline.TrignoBtManager.AddDeviceIDFilter(filter); } BTPipeline.CollectionComplete += CollectionComplete; BTPipeline.CollectionStarted += CollectionStarted; BTPipeline.CollectionDataReady += CollectionDataReady; BTPipeline.TrignoBtManager.ComponentScanComplete += ComponentScanComplete; }
public void LoadDataSource(IDelsysDevice ds) { PipelineController.Instance.AddPipeline(ds); SimulatedPipeline = PipelineController.Instance.PipelineIds[0]; TransformManager = PipelineController.Instance.PipelineIds[0].TransformManager; SimulatedPipeline.CollectionStarted += CollectionStarted; SimulatedPipeline.CollectionDataReady += CollectionDataReady; SimulatedPipeline.CollectionComplete += CollectionComplete; SimulatedPipeline.TrignoSimulatedManager.ComponentAdded += ComponentAdded; SimulatedPipeline.TrignoSimulatedManager.ComponentLost += ComponentLost; SimulatedPipeline.TrignoSimulatedManager.ComponentRemoved += ComponentRemoved; SimulatedPipeline.TrignoSimulatedManager.ComponentScanComplete += ComponentScanComplete; SimulatedPipeline.TrignoSimulatedManager.SimulatedTimeEventCallback += TrignoSimulatedManager_SimulatedTimeEventCallback;; SimulatedPipeline.Scan(); // Scan time in seconds ConfigureDataSource(); }
public void LoadDataSource(IDelsysDevice ds) { PipelineController.Instance.AddPipeline(ds); BTPipeline = PipelineController.Instance.PipelineIds[0]; TransformManager = PipelineController.Instance.PipelineIds[0].TransformManager; // Device Filters allow you to specify which sensors to connect to foreach (var filter in DeviceFilters) { BTPipeline.TrignoBtManager.AddDeviceIDFilter(filter); } // This is an important line of code! It lets through peripherals that have Jamar in their name. BTPipeline.TrignoBtManager.AllowPeripheralDevice("Jamar"); BTPipeline.CollectionStarted += CollectionStarted; BTPipeline.CollectionDataReady += CollectionDataReady; BTPipeline.CollectionComplete += CollectionComplete; // Our custom peripheral callback bleAdapter.DeviceConnected += BleAdapter_DeviceConnected; BTPipeline.TrignoBtManager.ComponentScanComplete += ComponentScanComplete; }
public void Run() { try { Stopwatch stopwatchFull = Stopwatch.StartNew(); _logger.LogInformation($"{nameof(Application)}.{nameof(Run)} execution invoked"); _importValidator = _serviceProvider.GetService <IImportValidator>(); _typeListValidator = _serviceProvider.GetService <ITypeListValidator>(); _importManager = _serviceProvider.GetService <IImportManager>(); _importStorageProvider = _serviceProvider.GetService <IImportStorageProvider>(); _transformManager = _serviceProvider.GetService <ITransformManager>(); _transformStorageProvider = _serviceProvider.GetService <ITransformStorageProvider>(); _mergeManager = _serviceProvider.GetService <IMergeManager>(); _mergeStorageProvider = _serviceProvider.GetService <IMergeStorageProvider>(); //uncomment below to actually run import and transform stages - file based string formattedDateString = DateTime.UtcNow.ToString(DateFormatSpecifier); //Import Stopwatch stopwatchImport = Stopwatch.StartNew(); string failureInfo; //Before we take the overhead of downloading all the import data, check that the data has the right overall structure bool isDataSourceValid = _importValidator.TryValidateDataSource(out failureInfo); if (!isDataSourceValid) { _logger.LogWarning("Enlir Import Data not in Expected Format: \n" + failureInfo); throw new ValidationException("Enlir Import Data not in Expected Format: \n" + failureInfo); } ImportResultsContainer importResultsContainer = _importManager.ImportAll(); string importStoragePath = _importStorageProvider.StoreImportResults(importResultsContainer, formattedDateString); stopwatchImport.Stop(); //cheat data setup for testing - comment out when doing full run for real //string importStoragePath = @"D:\Temp\FFRKApi\ImportResults-2018-12-21_09-48-46.json"; //string transformStoragePath = @"D:\Docs\Personal\FFRKLinqQuery\TransformResults-Latest.json"; //string formattedDateString = "2018-12-21_09-48-46"; //string importContents = File.ReadAllText(importStoragePath); //ImportResultsContainer importResultsContainer = JsonConvert.DeserializeObject<ImportResultsContainer>(importContents); ////Now that we have the import data, we need to check whether our TypeLists (used to convert staring data into ids) ////is still accurate. If the source data has changed their list of values for each type, we need to stop and correct the TypeLists IEnumerable <TypeListDifferences> typeListDifferences = _typeListValidator.TryValidateTypeLists(importResultsContainer); if (typeListDifferences.Any(t => t.IsIdListDifferentFromSource)) { _logger.LogWarning("Enlir TypeList Data differs from coded TypeLists."); //write validation failure data to log for easy perusal string typeListDifferencesLogPath = $"{AppContext.BaseDirectory}\\TypeListDifferencesLog.json"; string typeListDifferencesLogContents = JsonConvert.SerializeObject(typeListDifferences); File.WriteAllText(typeListDifferencesLogPath, typeListDifferencesLogContents); _logger.LogWarning("Enlir TypeList differences written to file: " + typeListDifferencesLogPath); throw new ValidationException("Enlir Type List Data differs from coded TypeLists"); } //Transform Stopwatch stopwatchTransform = Stopwatch.StartNew(); TransformResultsContainer transformResultsContainer = _transformManager.TransformAll(importStoragePath); string transformStoragePath = _transformStorageProvider.StoreTransformResults(transformResultsContainer, formattedDateString); stopwatchTransform.Stop(); //Merge Stopwatch stopwatchMerge = Stopwatch.StartNew(); MergeResultsContainer mergeResultsContainer = _mergeManager.MergeAll(transformStoragePath); string mergeStoragePath = _mergeStorageProvider.StoreMergeResults(mergeResultsContainer, formattedDateString); stopwatchMerge.Stop(); //test merge storage MergeResultsContainer testMergeResultsContainer = _mergeStorageProvider.RetrieveMergeResults(mergeStoragePath); stopwatchFull.Stop(); _logger.LogInformation("Import Completed in {ImportTime} seconds", stopwatchImport.Elapsed.Seconds); _logger.LogInformation("Transform Completed in {TransformTime} seconds", stopwatchTransform.Elapsed.Seconds); _logger.LogInformation("Merge Completed in {MergeTime} seconds", stopwatchMerge.Elapsed.Seconds); _logger.LogInformation("Full Run Completed in {FullRunTime} seconds", stopwatchFull.Elapsed.Seconds); int aggregateTime = stopwatchImport.Elapsed.Seconds + stopwatchMerge.Elapsed.Seconds + stopwatchFull.Elapsed.Seconds; _logger.LogInformation("Full Run Aggregate Time in {AggregateTime} seconds", aggregateTime); } catch (Exception ex) { _logger.LogError(ex, ex.Message); _logger.LogInformation("Error in Top Level Application execution. Validate, Import, Transform, and Merge operations were NOT successfully completed. Previously existing data is unchanged"); throw; } }