Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -u SBFspot/SBFspot.cpp ../SBFspot/SBFspot.cpp
- --- SBFspot/SBFspot.cpp 2016-05-31 23:01:18.000000000 +0200
- +++ ../SBFspot/SBFspot.cpp 2016-11-01 11:59:13.324047366 +0100
- @@ -108,6 +108,8 @@
- char msg[80];
- int rc = 0;
- + int prevJSObj = 0;
- + int prevJSArrayObj = 0;
- Config cfg;
- @@ -255,23 +257,30 @@
- return rc;
- }
- + //json start tag
- + if (cfg.json == 1)
- + printf("{\n");
- +
- // Synchronize plant time with system time
- // Only BT connected devices and if enabled in config _or_ requested by 123Solar
- // Most probably Speedwire devices get their time from the local IP network
- if ((ConnType == CT_BLUETOOTH) && (cfg.synchTime > 0 || cfg.s123 == S123_SYNC ))
- - if ((rc = SetPlantTime(cfg.synchTime, cfg.synchTimeLow, cfg.synchTimeHigh)) != E_OK)
- + if ((rc = SetPlantTime(cfg.synchTime, cfg.synchTimeLow, cfg.synchTimeHigh)) != E_OK && (cfg.json != 1))
- printf("SetPlantTime returned an error: %d\n", rc);
- - if ((rc = getInverterData(Inverters, sbftest)) != 0)
- + if ((rc = getInverterData(Inverters, sbftest)) != 0 && (cfg.json != 1))
- printf("getInverterData(sbftest) returned an error: %d\n", rc);
- - if ((rc = getInverterData(Inverters, SoftwareVersion)) != 0)
- + if ((rc = getInverterData(Inverters, SoftwareVersion)) != 0 && (cfg.json != 1))
- printf("getSoftwareVersion returned an error: %d\n", rc);
- - if ((rc = getInverterData(Inverters, TypeLabel)) != 0)
- + if ((rc = getInverterData(Inverters, TypeLabel)) != 0 && (cfg.json != 1))
- printf("getTypeLabel returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + printf(" \"device\": [\n");
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (VERBOSE_NORMAL)
- @@ -283,13 +292,41 @@
- printf("Software Version: %s\n", Inverters[inv]->SWVersion);
- printf("Serial number: %lu\n", Inverters[inv]->Serial);
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"deviceName\": \"%s\",\n", Inverters[inv]->DeviceName);
- + printf(" \"deviceClass\": \"%s\",\n", Inverters[inv]->DeviceClass);
- + printf(" \"deviceType\": \"%s\",\n", Inverters[inv]->DeviceType);
- + printf(" \"softwareVersion\": \"%s\",\n", Inverters[inv]->SWVersion);
- + printf(" \"serialNumber\": %lu\n", Inverters[inv]->Serial);
- + printf(" }\n");
- + }
- + }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- }
- }
- - if ((rc = getInverterData(Inverters, BatteryChargeStatus)) != 0)
- + if ((rc = getInverterData(Inverters, BatteryChargeStatus)) != 0 && (cfg.json != 1))
- printf("getBatteryChargeStatus returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"batteryChargingStatus\": [\n");
- + else
- + printf(" \"batteryChargingStatus\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (Inverters[inv]->DevClass == BatteryInverter)
- @@ -299,14 +336,42 @@
- printf("SUSyID: %d - SN: %lu\n", Inverters[inv]->SUSyID, Inverters[inv]->Serial);
- printf("Batt. Charging Status: %lu%%\n", Inverters[inv]->BatChaStt);
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0 && prevJSArrayObj)
- + printf(",\n {\n");
- + else
- + {
- + printf(" {\n");
- + prevJSArrayObj = 1;
- + }
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"status\": %lu%%\n", Inverters[inv]->BatChaStt);
- + printf(" }\n");
- + }
- }
- }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- + prevJSArrayObj = 0;
- + }
- }
- - if ((rc = getInverterData(Inverters, BatteryInfo)) != 0)
- + if ((rc = getInverterData(Inverters, BatteryInfo)) != 0 && (cfg.json != 1))
- printf("getBatteryInfo returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"batteryInfo\": [\n");
- + else
- + printf(" \"batteryInfo\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (Inverters[inv]->DevClass == BatteryInverter)
- @@ -318,14 +383,44 @@
- printf("Batt. Voltage : %3.2fV\n", toVolt(Inverters[inv]->BatVol));
- printf("Batt. Current : %2.3fA\n", toAmp(Inverters[inv]->BatAmp));
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0 && prevJSArrayObj)
- + printf(",\n {\n");
- + else
- + {
- + printf(" {\n");
- + prevJSArrayObj = 1;
- + }
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"temperature\": %3.1f,\n", (float)(Inverters[inv]->BatTmpVal / 10));
- + printf(" \"voltage\": %3.2f,\n", toVolt(Inverters[inv]->BatVol));
- + printf(" \"current\": %2.3f\n", toAmp(Inverters[inv]->BatAmp));
- + printf(" }\n");
- + }
- }
- }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- + prevJSArrayObj = 0;
- + }
- }
- - if ((rc = getInverterData(Inverters, DeviceStatus)) != 0)
- + if ((rc = getInverterData(Inverters, DeviceStatus)) != 0 && (cfg.json != 1))
- printf("getDeviceStatus returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"deviceStatus\": [\n");
- + else
- + printf(" \"deviceStatus\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (VERBOSE_NORMAL)
- @@ -333,13 +428,37 @@
- printf("SUSyID: %d - SN: %lu\n", Inverters[inv]->SUSyID, Inverters[inv]->Serial);
- printf("Device Status: %s\n", tagdefs.getDesc(Inverters[inv]->DeviceStatus, "?").c_str());
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"status\": \"%s\"\n", tagdefs.getDesc(Inverters[inv]->DeviceStatus, "?").c_str());
- + printf(" }\n");
- + }
- + }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- }
- }
- - if ((rc = getInverterData(Inverters, InverterTemperature)) != 0)
- + if ((rc = getInverterData(Inverters, InverterTemperature)) != 0 && (cfg.json != 1))
- printf("getInverterTemperature returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"inverterTemperature\": [\n");
- + else
- + printf(" \"inverterTemperature\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (VERBOSE_NORMAL)
- @@ -347,15 +466,39 @@
- printf("SUSyID: %d - SN: %lu\n", Inverters[inv]->SUSyID, Inverters[inv]->Serial);
- printf("Device Temperature: %3.1f%sC\n", ((float)Inverters[inv]->Temperature / 100), SYM_DEGREE); // degree symbol is different on windows/linux
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"deviceTemperature\": %3.1f\n", ((float)Inverters[inv]->Temperature / 100));
- + printf(" }\n");
- + }
- + }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- }
- }
- if (Inverters[0]->DevClass == SolarInverter)
- {
- - if ((rc = getInverterData(Inverters, GridRelayStatus)) != 0)
- + if ((rc = getInverterData(Inverters, GridRelayStatus)) != 0 && (cfg.json != 1))
- printf("getGridRelayStatus returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"gridRelayStatus\": [\n");
- + else
- + printf(" \"gridRelayStatus\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (Inverters[inv]->DevClass == SolarInverter)
- @@ -365,20 +508,48 @@
- printf("SUSyID: %d - SN: %lu\n", Inverters[inv]->SUSyID, Inverters[inv]->Serial);
- printf("GridRelay Status: %s\n", tagdefs.getDesc(Inverters[inv]->GridRelayStatus, "?").c_str());
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0 && prevJSArrayObj)
- + printf(",\n {\n");
- + else
- + {
- + printf(" {\n");
- + prevJSArrayObj = 1;
- + }
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"status\": \"%s\"\n", tagdefs.getDesc(Inverters[inv]->GridRelayStatus, "?").c_str());
- + printf(" }\n");
- + }
- }
- }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- + prevJSArrayObj = 0;
- + }
- }
- }
- - if ((rc = getInverterData(Inverters, MaxACPower)) != 0)
- + if ((rc = getInverterData(Inverters, MaxACPower)) != 0 && (cfg.json != 1))
- printf("getMaxACPower returned an error: %d\n", rc);
- else
- {
- //TODO: REVIEW THIS PART (getMaxACPower & getMaxACPower2 should be 1 function)
- - if ((Inverters[0]->Pmax1 == 0) && (rc = getInverterData(Inverters, MaxACPower2)) != 0)
- + if ((Inverters[0]->Pmax1 == 0) && (rc = getInverterData(Inverters, MaxACPower2)) != 0 && (cfg.json != 1))
- printf("getMaxACPower2 returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"maxACPower\": [\n");
- + else
- + printf(" \"maxACPower\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (VERBOSE_NORMAL)
- @@ -388,17 +559,43 @@
- printf("Pac max phase 2: %luW\n", Inverters[inv]->Pmax2);
- printf("Pac max phase 3: %luW\n", Inverters[inv]->Pmax3);
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"pMaxPhase1\": %lu,\n", Inverters[inv]->Pmax1);
- + printf(" \"pMaxPhase2\": %lu,\n", Inverters[inv]->Pmax2);
- + printf(" \"pMaxPhase3\": %lu\n", Inverters[inv]->Pmax3);
- + printf(" }\n");
- + }
- + }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- }
- }
- }
- - if ((rc = getInverterData(Inverters, EnergyProduction)) != 0)
- + if ((rc = getInverterData(Inverters, EnergyProduction)) != 0 && (cfg.json != 1))
- printf("getEnergyProduction returned an error: %d\n", rc);
- - if ((rc = getInverterData(Inverters, OperationTime)) != 0)
- + if ((rc = getInverterData(Inverters, OperationTime)) != 0 && (cfg.json != 1))
- printf("getOperationTime returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"energyProduction\": [\n");
- + else
- + printf(" \"energyProduction\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (VERBOSE_NORMAL)
- @@ -410,19 +607,46 @@
- printf("\tOperation Time: %.2fh\n", toHour(Inverters[inv]->OperationTime));
- printf("\tFeed-In Time : %.2fh\n", toHour(Inverters[inv]->FeedInTime));
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"eToday\": %lld,\n", Inverters[inv]->EToday);
- + printf(" \"eTotal\": %lld,\n", Inverters[inv]->ETotal);
- + printf(" \"operationTime\": %.2f,\n", toHour(Inverters[inv]->OperationTime));
- + printf(" \"feedInTime\": %.2f\n", toHour(Inverters[inv]->FeedInTime));
- + printf(" }\n");
- + }
- + }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- }
- }
- - if ((rc = getInverterData(Inverters, SpotDCPower)) != 0)
- + if ((rc = getInverterData(Inverters, SpotDCPower)) != 0 && (cfg.json != 1))
- printf("getSpotDCPower returned an error: %d\n", rc);
- - if ((rc = getInverterData(Inverters, SpotDCVoltage)) != 0)
- + if ((rc = getInverterData(Inverters, SpotDCVoltage)) != 0 && (cfg.json != 1))
- printf("getSpotDCVoltage returned an error: %d\n", rc);
- //Calculate missing DC Spot Values
- if (cfg.calcMissingSpot == 1)
- CalcMissingSpot(Inverters[0]);
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"dcSpotData\": [\n");
- + else
- + printf(" \"dcSpotData\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- Inverters[inv]->calPdcTot = Inverters[inv]->Pdc1 + Inverters[inv]->Pdc2;
- @@ -433,21 +657,54 @@
- printf("\tString 1 Pdc: %7.3fkW - Udc: %6.2fV - Idc: %6.3fA\n", tokW(Inverters[inv]->Pdc1), toVolt(Inverters[inv]->Udc1), toAmp(Inverters[inv]->Idc1));
- printf("\tString 2 Pdc: %7.3fkW - Udc: %6.2fV - Idc: %6.3fA\n", tokW(Inverters[inv]->Pdc2), toVolt(Inverters[inv]->Udc2), toAmp(Inverters[inv]->Idc2));
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"string1\": {\n");
- + printf(" \"p\": %ld,\n", Inverters[inv]->Pdc1);
- + printf(" \"u\": %6.2f,\n", toVolt(Inverters[inv]->Udc1));
- + printf(" \"i\": %6.3f\n", toAmp(Inverters[inv]->Idc1));
- + printf(" },\n");
- + printf(" \"string2\": {\n");
- + printf(" \"p\": %ld,\n", Inverters[inv]->Pdc2);
- + printf(" \"u\": %6.2f,\n", toVolt(Inverters[inv]->Udc2));
- + printf(" \"i\": %6.3f\n", toAmp(Inverters[inv]->Idc2));
- + printf(" }\n");
- + printf(" }\n");
- + }
- + }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- }
- - if ((rc = getInverterData(Inverters, SpotACPower)) != 0)
- + if ((rc = getInverterData(Inverters, SpotACPower)) != 0 && (cfg.json != 1))
- printf("getSpotACPower returned an error: %d\n", rc);
- - if ((rc = getInverterData(Inverters, SpotACVoltage)) != 0)
- + if ((rc = getInverterData(Inverters, SpotACVoltage)) != 0 && (cfg.json != 1))
- printf("getSpotACVoltage returned an error: %d\n", rc);
- - if ((rc = getInverterData(Inverters, SpotACTotalPower)) != 0)
- + if ((rc = getInverterData(Inverters, SpotACTotalPower)) != 0 && (cfg.json != 1))
- printf("getSpotACTotalPower returned an error: %d\n", rc);
- //Calculate missing AC Spot Values
- if (cfg.calcMissingSpot == 1)
- CalcMissingSpot(Inverters[0]);
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"acSpotData\": [\n");
- + else
- + printf(" \"acSpotData\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (VERBOSE_NORMAL)
- @@ -459,12 +716,51 @@
- printf("\tPhase 3 Pac : %7.3fkW - Uac: %6.2fV - Iac: %6.3fA\n", tokW(Inverters[inv]->Pac3), toVolt(Inverters[inv]->Uac3), toAmp(Inverters[inv]->Iac3));
- printf("\tTotal Pac : %7.3fkW\n", tokW(Inverters[inv]->TotalPac));
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"phase1\": {\n");
- + printf(" \"p\": %ld,\n", Inverters[inv]->Pac1);
- + printf(" \"u\": %6.2f,\n", toVolt(Inverters[inv]->Uac1));
- + printf(" \"i\": %6.3f\n", toAmp(Inverters[inv]->Iac1));
- + printf(" },\n");
- + printf(" \"phase2\": {\n");
- + printf(" \"p\": %ld,\n", Inverters[inv]->Pac2);
- + printf(" \"u\": %6.2f,\n", toVolt(Inverters[inv]->Uac2));
- + printf(" \"i\": %6.3f\n", toAmp(Inverters[inv]->Iac2));
- + printf(" },\n");
- + printf(" \"phase3\": {\n");
- + printf(" \"p\": %ld,\n", Inverters[inv]->Pac3);
- + printf(" \"u\": %6.2f,\n", toVolt(Inverters[inv]->Uac3));
- + printf(" \"i\": %6.3f\n", toAmp(Inverters[inv]->Iac3));
- + printf(" },\n");
- + printf(" \"pTotal\": %ld\n", Inverters[inv]->TotalPac);
- + printf(" }\n");
- + }
- }
- - if ((rc = getInverterData(Inverters, SpotGridFrequency)) != 0)
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- + }
- +
- + if ((rc = getInverterData(Inverters, SpotGridFrequency)) != 0 && (cfg.json != 1))
- printf("getSpotGridFrequency returned an error: %d\n", rc);
- else
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"gridFrequency\": [\n");
- + else
- + printf(" \"gridFrequency\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (VERBOSE_NORMAL)
- @@ -472,11 +768,35 @@
- printf("SUSyID: %d - SN: %lu\n", Inverters[inv]->SUSyID, Inverters[inv]->Serial);
- printf("Grid Freq. : %.2fHz\n", toHz(Inverters[inv]->GridFreq));
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"frequency\": %.2f\n", toHz(Inverters[inv]->GridFreq));
- + printf(" }\n");
- + }
- + }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- }
- }
- if (Inverters[0]->DevClass == SolarInverter)
- {
- + if (cfg.json == 1)
- + {
- + if (prevJSObj)
- + printf(",\n \"timeInfo\": [\n");
- + else
- + printf(" \"timeInfo\": [\n");
- + }
- +
- for (int inv=0; Inverters[inv]!=NULL && inv<MAX_INVERTERS; inv++)
- {
- if (VERBOSE_NORMAL)
- @@ -491,7 +811,25 @@
- if (Inverters[inv]->SleepTime > 0)
- printf("Inverter Sleep Time : %s\n", strftime_t(cfg.DateTimeFormat, Inverters[inv]->SleepTime));
- }
- + else if (cfg.json == 1)
- + {
- + if (inv > 0)
- + printf(",\n {\n");
- + else
- + printf(" {\n");
- + printf(" \"id\": %d,\n", Inverters[inv]->SUSyID);
- + printf(" \"currentInverterTime\": \"%s\",\n", strftime_t(cfg.DateTimeFormat, Inverters[inv]->InverterDatetime));
- + printf(" \"inverterWakeUpTime\": \"%s\",\n", strftime_t(cfg.DateTimeFormat, Inverters[inv]->WakeupTime));
- + printf(" \"inverterSleepTime\": \"%s\"\n", strftime_t(cfg.DateTimeFormat, Inverters[inv]->SleepTime));
- + printf(" }\n");
- + }
- }
- +
- + if (cfg.json == 1)
- + {
- + printf(" ]");
- + prevJSObj = 1;
- + }
- }
- if (Inverters[0]->DevClass == SolarInverter)
- @@ -521,7 +859,15 @@
- logoffSMAInverter(Inverters[0]);
- freemem(Inverters);
- bthClose();
- - printf("Terminating here... Dealing with Battery Inverter.\n");
- + if (cfg.json == 1)
- + {
- + //json end tag
- + printf("\n}\n");
- + }
- + else
- + {
- + printf("Terminating here... Dealing with Battery Inverter.\n");
- + }
- exit(0);
- }
- }
- @@ -551,7 +897,7 @@
- for (int count=0; count<cfg.archDays; count++)
- {
- - if ((rc = ArchiveDayData(Inverters, arch_time)) != E_OK)
- + if ((rc = ArchiveDayData(Inverters, arch_time)) != E_OK && cfg.json != 1)
- {
- if (rc != E_ARCHNODATA) printf("ArchiveDayData returned an error: %d\n", rc);
- }
- @@ -702,6 +1048,12 @@
- if (VERBOSE_NORMAL) print_error(stdout, PROC_INFO, "Done.\n");
- + if (cfg.json == 1)
- + {
- + //json end tag
- + printf("\n}\n");
- + }
- +
- return 0;
- }
- @@ -1751,6 +2103,7 @@
- cfg->nocsv = 0;
- cfg->nospot = 0;
- cfg->nosql = 0;
- + cfg->json = 0;
- // 123Solar Web Solar logger support(http://www.123solar.org/)
- // This is an undocumented feature and should only be used for 123solar
- cfg->s123 = S123_NOP;
- @@ -1768,6 +2121,17 @@
- }
- }
- + //Set json mode
- + for (int i = 1; i < argc; i++)
- + {
- + if (stricmp(argv[i], "-json") == 0)
- + {
- + cfg->quiet = 1;
- + cfg->json = 1;
- + break;
- + }
- + }
- +
- // Get path of executable
- cfg->AppPath = argv[0];
- size_t pos = cfg->AppPath.find_last_of("/\\");
- @@ -2024,6 +2388,8 @@
- cfg->verbose = 2;
- cfg->forceInq = 1;
- + // Disable json when syncing time
- + cfg->json = 0;
- }
- //Disable verbose/debug modes when silent
- @@ -2033,6 +2399,14 @@
- cfg->debug = 0;
- }
- + //Disable all other output for -json (quite already set to 1 above)
- + if (cfg->json == 1)
- + {
- + cfg->nocsv = 1;
- + cfg->nosql = 1;
- + cfg->nospot = 1;
- + }
- +
- return 0;
- }
- @@ -2075,7 +2449,8 @@
- std::cout << " -password:xxxx Installer password\n";
- std::cout << " -loadlive Use predefined settings for manual upload to pvoutput.org\n";
- std::cout << " -startdate:YYYYMMDD Set start date for historic data retrieval\n";
- - std::cout << " -settime Sync inverter time with host time\n" << std::endl;
- + std::cout << " -settime Sync inverter time with host time\n";
- + std::cout << " -json Print data in json format implies -q, -nocsv, -nosql, -sp0 and -v0\n" << std::endl;
- }
- }
- diff -u SBFspot/SBFspot.h ../SBFspot/SBFspot.h
- --- SBFspot/SBFspot.h 2016-05-20 22:22:28.000000000 +0200
- +++ ../SBFspot/SBFspot.h 2016-11-01 12:13:28.228591256 +0100
- @@ -258,6 +258,7 @@
- int nospot; // -sp0 Disables Spot CSV export
- int nosql; // -nosql Disables SQL export
- int loadlive; // -loadlive Force settings to prepare for live loading to http://pvoutput.org/loadlive.jsp
- + int json; // -json json output to std out
- time_t startdate; // -startdate Start reading of historic data at the given date (YYYYMMDD)
- S123_COMMAND s123; // -123s 123Solar Web Solar logger support(http://www.123solar.org/)
- int settime; // -settime Set plant time
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement