123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.PLC;
- using Aitex.Jet.RT.Simulator;
- using Aitex.Triton160.RT.Module;
- using Aitex.Triton160.RT.PLC;
- namespace Aitex.Triton160.RT.Simulator
- {
- public class SimulatorFinsDataDevice : IDataDevice
- {
- private ISimulatorManager _simulator;
- private bool _isOpened = true;
- public bool IsOpened { get { return _isOpened; } }
- private List<string> _types = new List<string> {"local", "remote"};
- public bool Open()
- {
- //if (SystemConfigManager.Instance.GetSystemType().ToLower() == "patronmax")
- //{
- // _simulator = new SimulatorPatronMax();
- // _types = new List<string> {"local"};
- //}
- //else if (SystemConfigManager.Instance.GetSystemType().ToLower() == "patron")
- //{
- // _simulator = new SimulatorPatron();
- //}
- //else
- //if (SystemConfigManager.Instance.GetSystemType().ToLower() == "hz")
- {
- _simulator = new SimulatorTriton160();
- _types = new List<string> {"local"};
- }
- //else
- //{
- // _simulator = new SimulatorTriton();
- //}
- return true;
- }
- public void Close()
- {
- ;
- }
- public object Read<T>(string type)
- {
- try
- {
- return _simulator.Read(type);
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- return null;
- }
- public bool Write<T>(string type, T buffer)
- {
- try
- {
- _simulator.Write(type, (PLC_OUTPUT_DATA)(object)buffer);
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- return true;
- }
- public List<string> GetTypes()
- {
- return _types;
- }
- public bool IsOpen(string type)
- {
- return IsOpened;
- }
- public bool Open(string type)
- {
- return Open();
- }
- public void Close(string type)
- {
- Close();
- }
- }
- }
|