PhysicalCheckupLogger.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using FluentFTP;
  2. using GSG.NET.Logging;
  3. using GSG.NET.ObjectBase;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. namespace VehicleControlSystem.Managers
  11. {
  12. /// <summary>
  13. /// 아날로그 입력 정보를 종합하여 로그로 남기는 역할
  14. /// FTP 를 이용하여 파일 전송
  15. /// </summary>
  16. class PhysicalCheckupLogger : SingletonBase<PhysicalCheckupLogger>
  17. {
  18. Logger logger = Logger.GetLogger( "PhysicalCheckup" );
  19. private PhysicalCheckupLogger()
  20. {
  21. }
  22. public void DriveStateLog(string speed, string torque, bool isFront = true )
  23. {
  24. if ( isFront )
  25. logger.I( $"[Front] - Speed : {speed} / Torque : {torque}" );
  26. else
  27. logger.I( $"[Rear] - Speed : {speed} / Torque : {torque}" );
  28. }
  29. //192.168.127.188 Moxa 용성 IP
  30. public async Task UploadPhysicalCheckupLogAsync()
  31. {
  32. var token = new CancellationToken();
  33. using ( var ftp = new FtpClient( "192.168.127.188") )
  34. {
  35. await ftp.ConnectAsync( token );
  36. // upload a folder and all its files
  37. await ftp.UploadDirectoryAsync( @"C:\LOG\OHV\Vehicle\PhysicalCheckup\", @"/DriveInfo", FtpFolderSyncMode.Update );
  38. // upload a folder and all its files, and delete extra files on the server
  39. //ftp.UploadDirectory( @"C:\website\assets\", @"/public_html/assets", FtpFolderSyncMode.Mirror );
  40. }
  41. }
  42. }
  43. }