123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.IO.Ports;
- using System.Threading;
- using MECF.Framework.Simulator.Core.Driver;
- namespace EfemDualSimulator.Devices
- {
- class SkyPumpMock : SerialPortDeviceSimulator
- {
- public enum SimPumpStatus
- {
- Open,
- Close,
- }
- public static SimPumpStatus _simPumpStatus;
- private const string EOF = "\r\n";
- private const char MSG_DELIMITER = ' ';
- private const string MOCKUP_PORT = "COM33";
- public SkyPumpMock() : base(MOCKUP_PORT, -1, EOF, MSG_DELIMITER,true)
- {
- _simPumpStatus = SimPumpStatus.Close;
- }
- protected override void ProcessUnsplitMessage(string message)
- {
- if (string.IsNullOrEmpty(message))
- throw new ArgumentException("Hardware command message is invalid");
- string[] strs = message.Split('\r');
- string sRes = string.Empty;
- foreach (var s2 in strs)
- {
- if (s2.Length < 1) continue;
- switch (s2)
- {
- case "@00READ_RUN_PARA":
- if (_simPumpStatus == SimPumpStatus.Open)
- sRes = "@00RUN_PARA050308804314101000003\0\0hh\0\0\r\n";
- else if (_simPumpStatus == SimPumpStatus.Close)
- sRes = "@00RUN_PARA050308804314101000003\0\0??\0\0\r\n";
- break;
- case "@00CON_FDP_ON":
- _simPumpStatus = SimPumpStatus.Open;
- sRes = "@00FDP_ONOK" + "\0\r\n";
- break;
- case "@00CON_FDP_OFF":
- _simPumpStatus = SimPumpStatus.Close;
- sRes = "@00FDP_OFFOK" + "\0\r\n";
- break;
- default:
- break;
- }
- OnWriteMessage(sRes);
- }
- }
- }
- }
|