public static MasterThread Create(IReadOnlyCollection <NandakaDevice> slaveDevices, IProtocol protocol, IDeviceUpdatePolicy updatePolicy, ILog log) { var threadLog = new PrefixLog(log, "[Master]"); var dispatcher = MasterDeviceDispatcher.Create(slaveDevices, updatePolicy, threadLog); return(new MasterThread(dispatcher, protocol, threadLog)); }
public MasterSession(IProtocol protocol, NandakaDevice slaveDevice, MasterDeviceDispatcher dispatcher, ILog log) { _log = new PrefixLog(log, $"[{slaveDevice.Name} Session]"); _protocol = protocol; _slaveDevice = slaveDevice; _registersUpdatePolicy = slaveDevice.UpdatePolicy; _dispatcher = dispatcher; }
private MasterThread(MasterDeviceDispatcher dispatcher, IProtocol protocol, ILog log) { _dispatcher = dispatcher; _log = log; _deviceSessions = dispatcher.SlaveDevices.ToDictionary(device => device.Address, device => new MasterSession(protocol, device, dispatcher, _log)); _thread = new Thread(Routine) { IsBackground = true }; }