public override void ReadInit(ILambdaWorker worker) { try { var tryCount = 2; do { _unit.ClearMeasuredParameters(); var result = _protocol.Dvc(_unit.ExpectedIdentifier, _unit.Address, _unit.Voltage); _unit.MeasuredParameters(result[0], result[1], result[2], result[3], result[4], result[5]); if (!Process()) { break; } tryCount--; Thread.Sleep(100); } while (tryCount >= 0); if (tryCount < 0) { throw new LambdaFailureException( string.Format(Properties.Resources.UnableToEstablishVaotageOrCurrent, _unit.Voltage, _unit.Current)); } worker.Goto(worker.StateRead); } catch (Exception) { worker.Goto(worker.StateFailure); throw; } }
public override void Read(ILambdaWorker worker) { try { _unit.ClearMeasuredParameters(); var result = _protocol.Dvc(_unit.ExpectedIdentifier, _unit.Address, _unit.Voltage); _unit.MeasuredParameters(result[0], result[1], result[2], result[3], result[4], result[5]); Process(); } catch (Exception) { worker.Goto(worker.StateFailure); throw; } }
public static float[] Dvc(this ILambdaProtocol lambdaProtocol, string identifier, byte address, float voltage) { var response = lambdaProtocol.Dvc(); if (response.Error != null) { throw new LambdaFailureException(string.Format(Properties.Resources.NotFoundPowerSource, identifier, address, VoltageRound(voltage)), response.Error); } var strings = response.Response.Split(','); return(new[] { ConvertToFloat(strings[0]), ConvertToFloat(strings[1]), ConvertToFloat(strings[2]), ConvertToFloat(strings[3]), ConvertToFloat(strings[4]), ConvertToFloat(strings[5]) }); }