From 71c83ac1fb78a23787d947fea0e323f2ecc9a254 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 30 Apr 2022 02:13:38 +0200 Subject: [PATCH] * version 0.3.0 * added unit test --- tools/esp8266/defines.h | 4 +- .../esp8266/test/hmClassTest/hmClassTest.sln | 31 ++++ .../hmClassTest/hmClassTest.vcxproj | 147 ++++++++++++++++++ .../hmClassTest/hmClassTest.vcxproj.filters | 22 +++ .../hmClassTest/hmClassTest.vcxproj.user | 4 + tools/esp8266/test/hmClassTest/src/main.cpp | 105 +++++++++++++ 6 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 tools/esp8266/test/hmClassTest/hmClassTest.sln create mode 100644 tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj create mode 100644 tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj.filters create mode 100644 tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj.user create mode 100644 tools/esp8266/test/hmClassTest/src/main.cpp diff --git a/tools/esp8266/defines.h b/tools/esp8266/defines.h index f5c57530..980447e9 100644 --- a/tools/esp8266/defines.h +++ b/tools/esp8266/defines.h @@ -24,8 +24,8 @@ // VERSION //------------------------------------- #define VERSION_MAJOR 0 -#define VERSION_MINOR 2 -#define VERSION_PATCH 12 +#define VERSION_MINOR 3 +#define VERSION_PATCH 0 //------------------------------------- diff --git a/tools/esp8266/test/hmClassTest/hmClassTest.sln b/tools/esp8266/test/hmClassTest/hmClassTest.sln new file mode 100644 index 00000000..a303a142 --- /dev/null +++ b/tools/esp8266/test/hmClassTest/hmClassTest.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32002.261 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hmClassTest", "hmClassTest\hmClassTest.vcxproj", "{4D899C12-DE0E-4CDB-B48C-FDFEC331F219}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Debug|x64.ActiveCfg = Debug|x64 + {4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Debug|x64.Build.0 = Debug|x64 + {4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Debug|x86.ActiveCfg = Debug|Win32 + {4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Debug|x86.Build.0 = Debug|Win32 + {4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Release|x64.ActiveCfg = Release|x64 + {4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Release|x64.Build.0 = Release|x64 + {4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Release|x86.ActiveCfg = Release|Win32 + {4D899C12-DE0E-4CDB-B48C-FDFEC331F219}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7C291F74-09F6-4C84-99E1-6E7294062385} + EndGlobalSection +EndGlobal diff --git a/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj b/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj new file mode 100644 index 00000000..bbf9cbd2 --- /dev/null +++ b/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + 16.0 + Win32Proj + {4d899c12-de0e-4cdb-b48c-fdfec331f219} + hmClassTest + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj.filters b/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj.filters new file mode 100644 index 00000000..fee0814f --- /dev/null +++ b/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Quelldateien + + + \ No newline at end of file diff --git a/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj.user b/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj.user new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/tools/esp8266/test/hmClassTest/hmClassTest/hmClassTest.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tools/esp8266/test/hmClassTest/src/main.cpp b/tools/esp8266/test/hmClassTest/src/main.cpp new file mode 100644 index 00000000..3b30364d --- /dev/null +++ b/tools/esp8266/test/hmClassTest/src/main.cpp @@ -0,0 +1,105 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include +#include +#include +#include + + +//----------------------------------------------------------------------------- +#define MAX_NUM_INVERTERS 3 +#define MAX_NAME_LENGTH 16 +#define NDEBUG +#define NO_RADIO + +#include "../../../hmDefines.h" +#include "../../../hmInverter.h" +#include "../../../hmSystem.h" + + + +//----------------------------------------------------------------------------- +typedef int RadioType; +typedef int BufferType; +typedef Inverter InverterType; +typedef HmSystem HmSystemType; + + +//----------------------------------------------------------------------------- +void valToBuf(InverterType *iv, uint8_t fld, uint8_t ch, float val, uint8_t bufPos); + + +//----------------------------------------------------------------------------- +int main(int argc, char* argv[]) { + HmSystemType sys; + InverterType *iv0, *iv1; + uint8_t buf[30] = { 0xcc }; + + iv0 = sys.addInverter("HM1200", 0x1122334455ULL, INV_TYPE_HM1200); + iv1 = sys.addInverter("HM600", 0x1234567891ULL, INV_TYPE_HM600); + + valToBuf(iv0, FLD_UDC, CH1, 29.5, 3); + valToBuf(iv0, FLD_UDC, CH3, 30.6, 9); + valToBuf(iv0, FLD_YD, CH1, 1234, 5); + valToBuf(iv0, FLD_YD, CH2, 1199, 7); + valToBuf(iv0, FLD_YD, CH3, 899, 11); + valToBuf(iv0, FLD_YD, CH4, 932, 13); + valToBuf(iv0, FLD_YT, CH1, 40.123, 13); + valToBuf(iv0, FLD_YT, CH2, 57.231, 1); + valToBuf(iv0, FLD_YT, CH3, 59.372, 3); + valToBuf(iv0, FLD_YT, CH4, 43.966, 7); + + iv0->doCalculations(); + for(uint8_t i = 0; i < iv0->listLen; i ++) { + float val = iv0->getValue(i); + if(0.0 != val) { + printf("%10s [CH%d] = %.3f %s\n", iv0->getFieldName(i), iv0->getChannel(i), val, iv0->getUnit(i)); + } + } + + return 0; +} + + +//----------------------------------------------------------------------------- +void valToBuf(InverterType *iv, uint8_t fld, uint8_t ch, float val, uint8_t bufPos) { + uint8_t buf[30] = { 0xcc }; + uint8_t len; + uint16_t factor; + + switch(fld) { + default: len = 2; break; + case FLD_YT: len = 4; break; + } + + switch(fld) { + case FLD_YD: factor = 1; break; + case FLD_UDC: + case FLD_PDC: + case FLD_UAC: + case FLD_PAC: + case FLD_PCT: + case FLD_T: factor = 10; break; + case FLD_IDC: + case FLD_IAC: + case FLD_F: factor = 100; break; + default: factor = 1000; break; + } + + uint8_t *p = &buf[bufPos]; + + uint32_t intval = (uint32_t)(val * factor); + if(2 == len) { + p[0] = (intval >> 8) & 0xff; + p[1] = (intval ) & 0xff; + } + else { + p[0] = (intval >> 24) & 0xff; + p[1] = (intval >> 16) & 0xff; + p[2] = (intval >> 8) & 0xff; + p[3] = (intval ) & 0xff; + } + iv->addValue(iv->getPosByChFld(ch, fld), buf); +}