public override void ReadAync(ISettingItem[] items, IReporter reporter = null, int timeout = 100, int retryLimit = 3) { CheckConnection(); List <ISettingValue> settings = GetAllValues(items); lock (readWriteLock) { if (IsRunningReadWrite_NoLock == true) { throw new Exception("Already running a " + currentProcess.Mode + " async process."); } reporterWrapper = new ReporterWrapper(reporter); currentProcess = new SettingProcess(Connection, reporterWrapper, settings, timeout, retryLimit); try { reporterWrapper.Completed += CurrentProcess_Completed; currentProcess.ReadAsync(); } catch (Exception ex) { reporterWrapper.Completed -= CurrentProcess_Completed; throw ex; } } }
public static CommunicationProcessResult WriteSingle <T>(Connection connection, IReporter reporter, int timeout, int retryLimit, ISettingValue <T> setting, T value) { setting.Value = value; SettingProcess process = new SettingProcess(connection, reporter, setting, timeout, retryLimit); CommunicationProcessResult result = process.Write(); return(result); }
public static CommunicationProcessResult WriteSingle <T>(Connection connection, IReporter reporter, ISettingValue <T> setting, T value) { setting.Value = value; SettingProcess process = new SettingProcess(connection, reporter, new ISettingValue[] { setting }, 100, 3); CommunicationProcessResult result = process.Write(); return(result); }
void CurrentProcess_Completed(object sender, EventArgs e) { lock (readWriteLock) { reporterWrapper.Completed -= CurrentProcess_Completed; reporterWrapper = null; currentProcess = null; } }
public override CommunicationProcessResult Read(ISettingItem[] items, IReporter reporter = null, int timeout = 100, int retryLimit = 3) { CheckConnection(); List <ISettingValue> settings = GetAllValues(items); SettingProcess process = new SettingProcess(Connection, reporter, settings, timeout, retryLimit); lock (readWriteLock) { return(process.Read()); } }
/// <summary> /// Reads a single <see cref="ISettingValue"/>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="connection">The connection.</param> /// <param name="reporter">The reporter.</param> /// <param name="timeout">The timeout.</param> /// <param name="retryLimit">The retry limit.</param> /// <param name="setting">The setting.</param> /// <param name="value">The value.</param> /// <returns>ImuAsyncProcessResult.</returns> public static CommunicationProcessResult ReadSingle <T>(Connection connection, IReporter reporter, int timeout, int retryLimit, ISettingValue <T> setting, out T value) { SettingProcess process = new SettingProcess(connection, reporter, setting, timeout, retryLimit); CommunicationProcessResult result = process.Read(); switch (result) { case CommunicationProcessResult.Success: value = setting.RemoteValue; break; default: value = default(T); break; } return(result); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="connection"></param> /// <param name="reporter">Progress reporter.</param> /// <param name="muteToStart"></param> /// <param name="message"></param> /// <param name="value"></param> /// <returns></returns> public static CommunicationProcessResult ReadSingle <T>(Connection connection, IReporter reporter, ISettingValue <T> setting, out T value) // bool muteToStart, { SettingProcess process = new SettingProcess(connection, reporter, new ISettingValue[] { setting }, 100, 3); // muteToStart CommunicationProcessResult result = process.Read(); switch (result) { case CommunicationProcessResult.Success: value = setting.RemoteValue; break; default: value = default(T); break; } return(result); }