Added support for signed integer json reading

This commit is contained in:
Trevor Payne
2019-11-09 20:53:04 -06:00
parent fc87dfa6a9
commit 03b1808186

View File

@@ -137,20 +137,22 @@ namespace PepperDash.Core.JsonToSimpl
// OnBoolChange(false, index, JsonToSimplConstants.BoolValueChange); // OnBoolChange(false, index, JsonToSimplConstants.BoolValueChange);
} }
// Processes the path to a ushort, converting to ushort if able, firing off UshrtChange event // Processes the path to a ushort, converting to ushort if able, twos complement if necessary, firing off UshrtChange event
void ProcessUshortPath(ushort index) void ProcessUshortPath(ushort index) {
{ string response;
string response; if (Process(UshortPaths[index], out response)) {
if (Process(UshortPaths[index], out response)) ushort returnVal;
{ short val;
ushort val; try { val = Convert.ToInt16(response); }
try { val = Convert.ToUInt16(response); } catch { val = 0; }
catch { val = 0; }
OnUShortChange(val, index, JsonToSimplConstants.UshortValueChange); returnVal = val < 0 ? (ushort)(val + 65536) : (ushort)val;
}
else { } OnUShortChange(returnVal, index, JsonToSimplConstants.UshortValueChange);
// OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange); }
} else { }
// OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange);
}
// Processes the path to a string property and fires of a StringChange event. // Processes the path to a string property and fires of a StringChange event.
void ProcessStringPath(ushort index) void ProcessStringPath(ushort index)