1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using System.Threading;
- using MECF.Framework.Simulator.Core.Driver;
- namespace EfemDualSimulator.Devices
- {
- class SkyPumpMockPMA : SerialPortDeviceSimulator
- {
- public enum SimPumpStatus
- {
- Open,
- Close,
- }
- public static SimPumpStatus _simPumpStatus;
- private const string EOF = "\r";
- private const char MSG_DELIMITER = ' ';
- private const string MOCKUP_PORT = "COM31";
- public SkyPumpMockPMA(string com) : base(com, -1, EOF, MSG_DELIMITER)
- {
- _simPumpStatus = SimPumpStatus.Open;
- }
- 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);
- }
- }
- }
- }
|