From 09e991c48a07b57430ad6a328128d26159cd0adb Mon Sep 17 00:00:00 2001 From: uholeschak Date: Mon, 9 Dec 2024 21:00:45 +0100 Subject: [PATCH] Added 64 bit formats --- EdiabasLib/ApiInternal/ApiInternal.cs | 43 ++++++++++++++++++++------ EdiabasLib/EdiabasLib/EdiabasNet.cs | 2 ++ EdiabasLib/EdiabasTest/Program.cs | 8 +++++ EdiabasLib/Test/EdiabasCall/Program.cs | 8 ++--- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/EdiabasLib/ApiInternal/ApiInternal.cs b/EdiabasLib/ApiInternal/ApiInternal.cs index 28dd3442a..0bcfd900b 100644 --- a/EdiabasLib/ApiInternal/ApiInternal.cs +++ b/EdiabasLib/ApiInternal/ApiInternal.cs @@ -586,18 +586,25 @@ public bool apiResultLongLong(out long buffer, string result, ushort rset) } setLocalError(EDIABAS_ERR_NONE); - if (!getResultInt64(out Int64 int64Buffer, out EdiabasLib.EdiabasNet.ResultType resultType, result, rset)) + if (!getResultInt64(out Int64 int64Buffer, out EdiabasNet.ResultType resultType, result, rset)) { return false; } - if (resultType == EdiabasNet.ResultType.TypeD) + switch (resultType) { - buffer = (uint)int64Buffer; - } - else - { - buffer = (int)int64Buffer; + case EdiabasNet.ResultType.TypeQ: + case EdiabasNet.ResultType.TypeLL: + buffer = int64Buffer; + break; + + case EdiabasNet.ResultType.TypeD: + buffer = (uint)int64Buffer; + break; + + default: + buffer = (int)int64Buffer; + break; } logFormat(ApiLogLevel.Normal, "={0} ({1})", true, buffer); @@ -616,12 +623,22 @@ public bool apiResultQWord(out ulong buffer, string result, ushort rset) } setLocalError(EDIABAS_ERR_NONE); - if (!getResultInt64(out Int64 int64Buffer, out EdiabasLib.EdiabasNet.ResultType resultType, result, rset)) + if (!getResultInt64(out Int64 int64Buffer, out EdiabasNet.ResultType resultType, result, rset)) { return false; } - buffer = (uint)int64Buffer; + switch (resultType) + { + case EdiabasNet.ResultType.TypeQ: + case EdiabasNet.ResultType.TypeLL: + buffer = (ulong)int64Buffer; + break; + + default: + buffer = (uint)int64Buffer; + break; + } logFormat(ApiLogLevel.Normal, "={0} ({1})", true, buffer); return true; @@ -839,6 +856,10 @@ public bool apiResultFormat(out int buffer, string result, ushort rset) buffer = APIFORMAT_DWORD; break; + case EdiabasNet.ResultType.TypeQ: + buffer = APIFORMAT_QWORD; + break; + case EdiabasNet.ResultType.TypeC: buffer = APIFORMAT_CHAR; break; @@ -851,6 +872,10 @@ public bool apiResultFormat(out int buffer, string result, ushort rset) buffer = APIFORMAT_LONG; break; + case EdiabasNet.ResultType.TypeLL: + buffer = APIFORMAT_LONGLONG; + break; + case EdiabasNet.ResultType.TypeR: buffer = APIFORMAT_REAL; break; diff --git a/EdiabasLib/EdiabasLib/EdiabasNet.cs b/EdiabasLib/EdiabasLib/EdiabasNet.cs index a9161899c..b75e2daa8 100644 --- a/EdiabasLib/EdiabasLib/EdiabasNet.cs +++ b/EdiabasLib/EdiabasLib/EdiabasNet.cs @@ -1411,9 +1411,11 @@ public enum ResultType : byte TypeB, // 8 bit TypeW, // 16 bit TypeD, // 32 bit + TypeQ, // 64 bit TypeC, // 8 bit char TypeI, // 16 bit signed TypeL, // 32 bit signed + TypeLL, // 64 bit signed TypeR, // float TypeS, // string TypeY, // array diff --git a/EdiabasLib/EdiabasTest/Program.cs b/EdiabasLib/EdiabasTest/Program.cs index 870f6c475..52d0c3f41 100644 --- a/EdiabasLib/EdiabasTest/Program.cs +++ b/EdiabasLib/EdiabasTest/Program.cs @@ -387,6 +387,14 @@ static void PrintResults(List formatList, bool printAllTypes, List formatList, bool printAllTypes) __api32ResultLongLong(_apiHandle, out resultLong, resultName, set); if (apiResultLL) { - sbResult.Append(string.Format(Culture, "LL: {0}", resultLong)); + sbResult.Append(string.Format(Culture, "LL: {0} 0x{0:X016}", resultLong)); } } catch (Exception ex) @@ -490,7 +490,7 @@ static void PrintResults(List formatList, bool printAllTypes) __api32ResultQWord(_apiHandle, out resultUlong, resultName, set); if (apiResultQW) { - sbResult.Append(string.Format(Culture, "QW: {0}", resultUlong)); + sbResult.Append(string.Format(Culture, "QW: {0} 0x{0:X016}", resultUlong)); } } catch (Exception ex) @@ -504,7 +504,7 @@ static void PrintResults(List formatList, bool printAllTypes) { if (API.apiResultLongLong(out long resultLong, resultName, set)) { - sbResult.Append(string.Format(Culture, "LL: {0}", resultLong)); + sbResult.Append(string.Format(Culture, "LL: {0} 0x{0:X016}", resultLong)); } break; } @@ -513,7 +513,7 @@ static void PrintResults(List formatList, bool printAllTypes) { if (API.apiResultQWord(out ulong resultUlong, resultName, set)) { - sbResult.Append(string.Format(Culture, "QW: {0}", resultUlong)); + sbResult.Append(string.Format(Culture, "QW: {0} 0x{0:X016}", resultUlong)); } break; }