CameraApp.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Edge.Core.Processor;using Edge.Core.IndustryStandardInterface.Pump;
  2. using Microsoft.AspNetCore.Hosting;
  3. using NoName_CarplateRecognizeCamera_Lab.Controllers;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Threading.Tasks;
  8. using Wayne.FDCPOSLibrary;
  9. namespace NoName_CarplateRecognizeCamera_Lab
  10. {
  11. public class CameraApp : IAppProcessor, IFdcCommunicableController
  12. {
  13. public static string SmsServiceUrl;
  14. private string httpServerListenUrl;
  15. private IWebHost webHost;
  16. public string MetaConfigName { get; set; }
  17. public string SerialNumber { get { return "7C4412DD-FBE8-4A51-9E11-1E64D371612D"; } set {; } }
  18. public Func<string, bool> BroadcastMessageViaFdc { get; set; }
  19. public Func<string, string, string, bool> SendMessageViaFdc { get; set; }
  20. public Func<string, Tuple<string, OverallResult>> OnMessageReceivedViaFdc { get; set; }
  21. public CameraApp(string httpServerListenUrl, string smsServiceUrl)
  22. {
  23. this.httpServerListenUrl = httpServerListenUrl;
  24. CameraApp.SmsServiceUrl = smsServiceUrl;
  25. this.webHost = new WebHostBuilder()
  26. //.UseConfiguration(config)
  27. .UseKestrel()
  28. .UseContentRoot(Directory.GetCurrentDirectory())
  29. .UseIISIntegration()
  30. .UseUrls(this.httpServerListenUrl)
  31. .UseStartup<Startup>()
  32. .Build();
  33. this.webHost.RunAsync();
  34. CameraDataController.OnCarPlateRead = (result) =>
  35. {
  36. var carPlateNumber = result.AlarmInfoPlate.result.PlateResult.license;
  37. this.BroadcastMessageViaFdc("{source : 'CameraApp', data: { carPlateNumber: '" + carPlateNumber + "'}}");
  38. };
  39. }
  40. public void Init(IEnumerable<IProcessor> processors)
  41. {
  42. //throw new NotImplementedException();
  43. }
  44. public Task<bool> Start()
  45. {
  46. return Task.FromResult(true);
  47. }
  48. public Task<bool> Stop()
  49. {
  50. this.webHost.StopAsync();
  51. return Task.FromResult(true);
  52. }
  53. }
  54. }