Add ReturnStruct to return error message
This commit is contained in:
@@ -59,11 +59,11 @@ namespace AnyType.Controllers
|
||||
returnValues =>
|
||||
{
|
||||
//唯一的参数包含返回值,是一个唯一标识符(machine的第二个参数),返回值(类型ReturnUnit)的键值对。
|
||||
if (returnValues.ReturnValues != null)
|
||||
if (returnValues.ReturnValues.Datas != null)
|
||||
{
|
||||
lock (values)
|
||||
{
|
||||
var unitValues = from val in returnValues.ReturnValues
|
||||
var unitValues = from val in returnValues.ReturnValues.Datas
|
||||
select
|
||||
new Tuple<AddressUnit, double?>(
|
||||
addressUnits.FirstOrDefault(p => p.CommunicationTag == val.Key)!, val.Value.DeviceValue);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace CrossLamp.Controllers
|
||||
await _utility.ConnectAsync();
|
||||
}
|
||||
Lamp light = new Lamp();
|
||||
object[] lampsbyte = await _utility.GetDatasAsync("0X 1", new KeyValuePair<Type, int>(typeof(bool), 7));
|
||||
object[] lampsbyte = (await _utility.GetDatasAsync("0X 1", new KeyValuePair<Type, int>(typeof(bool), 7))).Datas;
|
||||
bool[] lamps = BigEndianValueHelper.Instance.ObjectArrayToDestinationArray<bool>(lampsbyte);
|
||||
if (lamps[0])
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace MachineJob.Service
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task OnFailure(string machineId)
|
||||
public Task OnFailure(string machineId, int errorCode, string errorMsg)
|
||||
{
|
||||
_logger.LogError("Machine {0} set failure", machineId);
|
||||
return Task.CompletedTask;
|
||||
@@ -72,7 +72,7 @@ namespace MachineJob.Service
|
||||
|
||||
private Dictionary<string, double> QueryConsole(DataReturnDef dataReturnDef)
|
||||
{
|
||||
var values = dataReturnDef.ReturnValues;
|
||||
var values = dataReturnDef.ReturnValues.Datas;
|
||||
foreach (var value in values)
|
||||
{
|
||||
_logger.LogInformation(dataReturnDef.MachineId + " " + value.Key + " " + value.Value.DeviceValue);
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace TripleAdd.Controllers
|
||||
utility.AddressTranslator = new AddressTranslatorModbus();
|
||||
await utility.ConnectAsync();
|
||||
}
|
||||
object[] getNum = await utility.GetDatasAsync("4X 1", new KeyValuePair<Type, int>(typeof(ushort), 4));
|
||||
object[] getNum = (await utility.GetDatasAsync("4X 1", new KeyValuePair<Type, int>(typeof(ushort), 4))).Datas;
|
||||
ushort[] getNumUshorts = BigEndianValueHelper.Instance.ObjectArrayToDestinationArray<ushort>(getNum);
|
||||
return SetValue(getNumUshorts);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace TripleAdd.Controllers
|
||||
machine.AddressCombiner = new AddressCombinerContinus(machine.AddressTranslator, 100000);
|
||||
machine.AddressCombinerSet = new AddressCombinerContinus(machine.AddressTranslator, 100000);
|
||||
}
|
||||
var resultFormat = (await machine.GetDatasAsync(MachineDataType.CommunicationTag)).MapGetValuesToSetValues();
|
||||
var resultFormat = (await machine.GetDatasAsync(MachineDataType.CommunicationTag)).Datas.MapGetValuesToSetValues();
|
||||
return SetValue(new ushort[4] { (ushort)resultFormat["Add1"], (ushort)resultFormat["Add2"], (ushort)resultFormat["Add3"], (ushort)resultFormat["Ans"] });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user