Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

62 rindas
1.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using HBLConsole.Abstract;
  8. using HBLConsole.Service;
  9. using HBLConsole.Factory;
  10. using HBLConsole.Model;
  11. namespace HBLConsole.Business.AbstractServer
  12. {
  13. public class ControlBase : ControlAbstract
  14. {
  15. public override void Init()
  16. {
  17. Main();
  18. ReadData();
  19. ResetProgram();
  20. }
  21. public override void Main()
  22. {
  23. ThreadManage.GetInstance.StartLong(new Action(() =>
  24. {
  25. if (MainAction != null) MainAction();
  26. Thread.Sleep(100);
  27. }), "MainTask");
  28. }
  29. public override void ReadData()
  30. {
  31. ThreadManage.GetInstance.StartLong(new Action(() =>
  32. {
  33. if (ReadDataAction != null) ReadDataAction();
  34. Thread.Sleep(100);
  35. }), "ReadPLCData");
  36. }
  37. public override void ResetProgram()
  38. {
  39. ThreadManage.GetInstance.StartLong(new Action(() =>
  40. {
  41. if (RTrig.GetInstance("ResetProgram").Start(DeviceData.Initing))
  42. {
  43. ThreadManage.GetInstance.StopTask("MainTask", new Action(() =>
  44. {
  45. ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() =>
  46. {
  47. SimpleFactory.GetInstance.CreateGvl();
  48. ReadData();
  49. Main();
  50. }));
  51. }));
  52. }
  53. Thread.Sleep(10);
  54. }), "ResetProgram");
  55. }
  56. }
  57. }