|
@@ -6,6 +6,7 @@
|
|
|
*/
|
|
|
#include "Module_DcMeter.h"
|
|
|
#include "meterComm.h"
|
|
|
+#include "Module_RatedCurrent.h"
|
|
|
|
|
|
/**
|
|
|
* Initial share memory
|
|
@@ -52,8 +53,10 @@ int InitShareMemory()
|
|
|
//==========================================
|
|
|
int main(void)
|
|
|
{
|
|
|
- Meter_Info meter_info;
|
|
|
+ ParsingRatedCur modelnameInfo = {0};
|
|
|
+ Meter_Info meter_info = {0};
|
|
|
uint8_t pollingIndex = 0;
|
|
|
+ uint8_t meterIndex = 0;
|
|
|
uint8_t failCount = 0;
|
|
|
|
|
|
#ifndef DEBUG_STANDALONG
|
|
@@ -69,6 +72,8 @@ int main(void)
|
|
|
sleep(5);
|
|
|
return -1;
|
|
|
}
|
|
|
+
|
|
|
+ RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo);
|
|
|
#endif//DEBUG_STANDALONG
|
|
|
|
|
|
// Initialize DC meter model
|
|
@@ -81,113 +86,126 @@ int main(void)
|
|
|
// Main loop
|
|
|
for(;;)
|
|
|
{
|
|
|
- switch(pollingIndex)
|
|
|
+ for(uint8_t gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
|
|
|
{
|
|
|
- case 0:
|
|
|
- if(readCurrent(&meter_info))
|
|
|
- {
|
|
|
-#ifndef DEBUG_STANDALONG
|
|
|
- /*
|
|
|
- * TODO:
|
|
|
- * 1. Synchronize data to share memory
|
|
|
- */
|
|
|
-#else
|
|
|
- DEBUG_INFO("Output current: %.3f A\n", meter_info.presentCurrent);
|
|
|
-#endif//DEBUG_STANDALONG
|
|
|
- pollingIndex++;
|
|
|
- failCount = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(failCount < 10)
|
|
|
- failCount++;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- if(readVoltage(&meter_info))
|
|
|
- {
|
|
|
-#ifndef DEBUG_STANDALONG
|
|
|
- /*
|
|
|
- * TODO:
|
|
|
- * 1. Synchronize data to share memory
|
|
|
- */
|
|
|
-#else
|
|
|
- DEBUG_INFO("Output voltage: %.3f V\n", meter_info.presetVoltage);
|
|
|
-#endif//DEBUG_STANDALONG
|
|
|
- pollingIndex++;
|
|
|
- failCount = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(failCount < 10)
|
|
|
- failCount++;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- if(readPower(&meter_info))
|
|
|
- {
|
|
|
-#ifndef DEBUG_STANDALONG
|
|
|
- /*
|
|
|
- * TODO:
|
|
|
- * 1. Synchronize data to share memory
|
|
|
- */
|
|
|
-#else
|
|
|
- DEBUG_INFO("Output power: %.3f kw\n", meter_info.presentPower);
|
|
|
-#endif//DEBUG_STANDALONG
|
|
|
- pollingIndex++;
|
|
|
- failCount = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(failCount < 10)
|
|
|
- failCount++;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- if(readEnergy(&meter_info))
|
|
|
+ if(gun_index == 0)
|
|
|
+ meterIndex = 0;
|
|
|
+
|
|
|
+ if(modelnameInfo.ParsingInfo[gun_index].GunType != Gun_Type_AC)
|
|
|
+ {
|
|
|
+ meterApiAssign(meterIndex);
|
|
|
+ switch(pollingIndex)
|
|
|
{
|
|
|
-#ifndef DEBUG_STANDALONG
|
|
|
- /*
|
|
|
- * TODO:
|
|
|
- * 1. Synchronize data to share memory
|
|
|
- */
|
|
|
-#else
|
|
|
- DEBUG_INFO("Totalize import energy: %.3f kwh\n", meter_info.totlizeImportEnergy);
|
|
|
- DEBUG_INFO("Totalize export energy: %.3f kwh\n", meter_info.totlizeExportEnergy);
|
|
|
-#endif//DEBUG_STANDALONG
|
|
|
- pollingIndex++;
|
|
|
- failCount = 0;
|
|
|
+ case 0:
|
|
|
+ if(readCurrent(&meter_info))
|
|
|
+ {
|
|
|
+ #ifndef DEBUG_STANDALONG
|
|
|
+ /*
|
|
|
+ * TODO:
|
|
|
+ * 1. Synchronize data to share memory
|
|
|
+ */
|
|
|
+ #else
|
|
|
+ DEBUG_INFO("Output current: %.3f A\n", meter_info.presentCurrent);
|
|
|
+ #endif//DEBUG_STANDALONG
|
|
|
+ pollingIndex++;
|
|
|
+ failCount = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(failCount < 10)
|
|
|
+ failCount++;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ if(readVoltage(&meter_info))
|
|
|
+ {
|
|
|
+ #ifndef DEBUG_STANDALONG
|
|
|
+ /*
|
|
|
+ * TODO:
|
|
|
+ * 1. Synchronize data to share memory
|
|
|
+ */
|
|
|
+ #else
|
|
|
+ DEBUG_INFO("Output voltage: %.3f V\n", meter_info.presetVoltage);
|
|
|
+ #endif//DEBUG_STANDALONG
|
|
|
+ pollingIndex++;
|
|
|
+ failCount = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(failCount < 10)
|
|
|
+ failCount++;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if(readPower(&meter_info))
|
|
|
+ {
|
|
|
+ #ifndef DEBUG_STANDALONG
|
|
|
+ /*
|
|
|
+ * TODO:
|
|
|
+ * 1. Synchronize data to share memory
|
|
|
+ */
|
|
|
+ #else
|
|
|
+ DEBUG_INFO("Output power: %.3f kw\n", meter_info.presentPower);
|
|
|
+ #endif//DEBUG_STANDALONG
|
|
|
+ pollingIndex++;
|
|
|
+ failCount = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(failCount < 10)
|
|
|
+ failCount++;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ if(readEnergy(&meter_info))
|
|
|
+ {
|
|
|
+ #ifndef DEBUG_STANDALONG
|
|
|
+ /*
|
|
|
+ * TODO:
|
|
|
+ * 1. Synchronize data to share memory
|
|
|
+ */
|
|
|
+ #else
|
|
|
+ DEBUG_INFO("Totalize import energy: %.3f kwh\n", meter_info.totlizeImportEnergy);
|
|
|
+ DEBUG_INFO("Totalize export energy: %.3f kwh\n", meter_info.totlizeExportEnergy);
|
|
|
+ #endif//DEBUG_STANDALONG
|
|
|
+ pollingIndex++;
|
|
|
+ failCount = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(failCount < 10)
|
|
|
+ failCount++;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ pollingIndex = 0;
|
|
|
+ break;
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ meterIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(failCount >= 10)
|
|
|
+ {
|
|
|
+ #ifndef DEBUG_STANDALONG
|
|
|
+ if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout)
|
|
|
{
|
|
|
- if(failCount < 10)
|
|
|
- failCount++;
|
|
|
+ DEBUG_ERROR("Meter communication timeout");
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = ON;
|
|
|
}
|
|
|
- break;
|
|
|
- default:
|
|
|
- pollingIndex = 0;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if(failCount >= 10)
|
|
|
- {
|
|
|
-#ifndef DEBUG_STANDALONG
|
|
|
- if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout)
|
|
|
+ #endif//DEBUG_STANDALONG
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- DEBUG_ERROR("Meter communication timeout");
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = ON;
|
|
|
+ #ifndef DEBUG_STANDALONG
|
|
|
+ ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = OFF;
|
|
|
+ #endif//DEBUG_STANDALONG
|
|
|
}
|
|
|
-#endif//DEBUG_STANDALONG
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-#ifndef DEBUG_STANDALONG
|
|
|
- ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = OFF;
|
|
|
-#endif//DEBUG_STANDALONG
|
|
|
+ usleep(500000);
|
|
|
}
|
|
|
-
|
|
|
- usleep(500000);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
return -1;
|
|
|
}
|