public PaceUnitsEnum ReadUnit(int channel = 0) { try { string req = AddChannelToCommandStr(":UNIT{0}?", channel); string received = exchange.Request(req); string parametr = AddChannelToCommandStr(":UNIT{0}:PRES ", channel); string strValue = ParseStringValue(parametr, received); PaceUnitsEnum result = PaceUnitsEnum.NotDefined; for (int i = 0; i < 3; i++) { if (((PaceUnitsEnum)i).ToString() == strValue) { result = (PaceUnitsEnum)i; break; } } Units[channel] = result; return(result); } catch (Exception ex) { throw new PaceExchException("ReadUnitError", ex, channel); } }
public void WriteUnitWithCheck(PaceUnitsEnum unit, int channel = 0) { WriteUnit(unit.ToString(), channel); var readUnit = ReadUnit(channel); if (readUnit != unit) { throw new PaceExchException("WriteUnitError", channel); } }
private void WriteUnit(int attempts, PaceUnitsEnum unit, int channel) { try { pace.WriteUnitWithCheck(unit, channel); } catch { attempts -= 1; if (attempts <= 0) { throw; } WriteUnit(attempts, unit, channel); } }