public static async Task Init(CoreDispatcher dispatcher) { sensorWatcher = new SensorWatcher(dispatcher, 100); sensorWatcher.LoadSettings(); ImuSensorWatcher = new ImuSensorWatcher(dispatcher, 10); SensorAccess = new SensorAccess(sensorWatcher); SensorTriggerAccess = new SensorTriggerAccess(db); MachineAccess = new MachineAccess(db); SeedMachines(); CreateCloudClient(); if (cloud != null && useLiveCloud) { FaultReportAccess = new FaultReportAccess(cloud, db); } else { FaultReportAccess = new MockFaultReportAccess(); } InstallSensorFaultHandler(); await ConnectToCloud(); await FillCaches(); }
public static async Task FillCaches() { ShellPage.SetSpinner(LoadingState.Loading); if (cloud != null) { await FaultReportAccess.FillCaches(); } ShellPage.SetSpinner(LoadingState.Finished); }
private static async Task <FaultReport> SendFaultReport(Sensor sensor, SensorFault fault, DateTime timestamp) { if (fault.Type == SensorFaultType.FromTrigger) { try { var trigger = await SensorTriggerAccess.FindSensorTrigger(fault.Id); var template = await FaultReportAccess.FindFaultReportTemplate(trigger.TemplateId); var machine = await MachineAccess.FindMachine(DeviceSettings.ObjectID); var report = new FaultReport { MchCode = machine.MchCode, MchCodeContract = machine.MchCodeContract, ErrDescr = template.Directive, ErrDescrLo = template.FaultDescr, ErrDiscoverCode = template.DiscCode, ErrSymptom = template.SymptCode, PriorityId = template.PrioCode, OrgCode = machine.OrgCode }; report = await FaultReportAccess.SetFaultReport(report); DocumentString document = new DocumentString(); SensorToDocumentString(document, sensor, trigger); var docFileData = await createDocument(report.WoNo, $"report_{sensor.Id}", document); if (dialogCount == 0) { await ShowDialog(sensor, fault, report, docFileData).ContinueWith(task => { Interlocked.Decrement(ref dialogCount); }); } return(report); } catch (Exception) { return(null); } } return(null); }