Fixed issues with parsing large ushort values

This commit is contained in:
Trevor Payne
2019-11-09 21:14:39 -06:00
parent 03b1808186
commit c59608d7b9

View File

@@ -141,14 +141,11 @@ namespace PepperDash.Core.JsonToSimpl
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.ToInt32(response) < 0 ? (ushort)(Convert.ToInt16(response) + 65536) : Convert.ToUInt16(response); }
try { val = Convert.ToInt16(response); }
catch { val = 0; } catch { val = 0; }
returnVal = val < 0 ? (ushort)(val + 65536) : (ushort)val; OnUShortChange(val, index, JsonToSimplConstants.UshortValueChange);
OnUShortChange(returnVal, index, JsonToSimplConstants.UshortValueChange);
} }
else { } else { }
// OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange); // OnUShortChange(0, index, JsonToSimplConstants.UshortValueChange);