From cbecbaf1f347d5dda6db0c5d53cad4b885a7fe95 Mon Sep 17 00:00:00 2001
From: Juliano Murari <juliano.murari@ess.eu>
Date: Thu, 28 Jul 2022 11:24:25 +0200
Subject: [PATCH] Fix units to calculate auto flattop current

---
 sis8300bcmApp/src/sis8300bcm.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sis8300bcmApp/src/sis8300bcm.cpp b/sis8300bcmApp/src/sis8300bcm.cpp
index 7da1cf5..de3bb24 100644
--- a/sis8300bcmApp/src/sis8300bcm.cpp
+++ b/sis8300bcmApp/src/sis8300bcm.cpp
@@ -1276,11 +1276,8 @@ int sis8300bcm::deviceDone()
             getDoubleParam(addr, BCMAcctAutoFlatTopStart, &autoFlattopStart);
             getDoubleParam(addr, BCMAcctAutoFlatTopEnd, &autoFlattopEnd);
             getDoubleParam(addr, BCMAcctTriggerWidth, &triggerWidth);
-            printf("Channel %d auto flattop start %f\n", addr, autoFlattopStart);
-            printf("Channel %d auto flattop end   %f\n", addr, autoFlattopEnd);
-            printf("Channel %d auto trigger width %f\n", addr, triggerWidth);
-            // calculate the average current over automatic flattop
-            ret = sis8300drvbcm_get_channel_flattop_current(mDeviceHandle, addr, triggerWidth - autoFlattopStart + autoFlattopEnd, flattopCharge, &doubleValue);
+            // calculate the average current over automatic flattop (window in ms)
+            ret = sis8300drvbcm_get_channel_flattop_current(mDeviceHandle, addr, triggerWidth - (autoFlattopStart + autoFlattopEnd)/10e6, flattopCharge, &doubleValue);
             if (ret) {
                 asynPrintError(pasynUserSelf, "sis8300drvbcm_get_channel_flattop_current auto returned %d", ret);
                 return ret;
-- 
GitLab