mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-04-12 12:06:29 +00:00
Added support for signed integer json reading
This commit is contained in:
parent
fc87dfa6a9
commit
03b1808186
1 changed files with 16 additions and 14 deletions
|
|
@ -137,16 +137,18 @@ 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;
|
||||||
ushort val;
|
short val;
|
||||||
try { val = Convert.ToUInt16(response); }
|
try { val = Convert.ToInt16(response); }
|
||||||
catch { val = 0; }
|
catch { val = 0; }
|
||||||
OnUShortChange(val, index, JsonToSimplConstants.UshortValueChange);
|
|
||||||
|
returnVal = val < 0 ? (ushort)(val + 65536) : (ushort)val;
|
||||||
|
|
||||||
|
OnUShortChange(returnVal, index, JsonToSimplConstants.UshortValueChange);
|
||||||
}
|
}
|
||||||
else { }
|
else { }
|
||||||
// OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange);
|
// OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue