Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving the charging summary #299

Open
chandan-ultraviolette opened this issue May 15, 2024 · 10 comments
Open

Saving the charging summary #299

chandan-ultraviolette opened this issue May 15, 2024 · 10 comments

Comments

@chandan-ultraviolette
Copy link

I want to save the charging summary, basically one .jsn should be created at every new charging session and periodically gets updated while charging. I think something similar is already done with s-.jsn file, I enabled below but the stack is not creating the file sd-.jsn. Any suggestion.

image

image

image

@matth-x
Copy link
Owner

matth-x commented May 18, 2024

Are you sure the value of StopTxnSampledData was applied correcly? You can verify it with a GetConfiguration command from the server. Otherwise, I would believe that the microcontroller runs out of flash memory and therefore, the creation of the StopData JSON files fails. I verified this function here and couldn't reproduce the issue.

@matth-x
Copy link
Owner

matth-x commented May 18, 2024

By default, the number of StopData measurements is limited to 4 which could be too restrictive in your scenario. I quickly changed the corresponding definition. To keep more than 4 elements on flash, set the build flag MO_MAX_STOPTXDATA_LEN to a higher value.

@chandan-ultraviolette
Copy link
Author

@matth-x I am bit confusion, I thought after 4 elements, code will erase the older ones and keep creating new log?

@chandan-ultraviolette
Copy link
Author

@matth-x I recompiled my entire code working fine now, seems very strange. Also I don't want to create new file periodically, basically one file sd-connector_id-txNr-0 should update periodically so I can access only 1 file to know the history.

Also I checked the JSON sd-*.jsn, I was looking for JSON which has start time, end time (or duaration) and energy consumed wh till now, Arre you creating any such .jsn or any suggestion where to modify for same.

@matth-x
Copy link
Owner

matth-x commented May 21, 2024

The current strategy is to make a consecutive record of up to MO_MAX_STOPTXDATA_LEN -1 sd files and then to keep the most recent readings in the last sd file which gets updated afterwards. So the sd file with the highest sequence number always contains the most recent measurements.

@chandan-ultraviolette
Copy link
Author

Understood, How can I access txNr so application can access the logs.

@matth-x
Copy link
Owner

matth-x commented May 22, 2024

The transaction store keeps track of all currently stored transactions. You can retrieve the range of corresponding txNr like that:

//necessary include
#include <MicroOcpp/Model/Transactions/TransactionStore.h>


if (auto context = getOcppContext()) {
    auto& model = context->getModel();

    if (auto txStore = model.getTransactionStore()) {
        int txNrBegin = txStore->getTxBegin(1 /* connectorId */); //first possible txNr
        unsigned int txNrCount= txStore->size(1 /* connectorId */); //number of stored transactions

        //iterate through all stored transactions by txNr
        for (unsigned int i = 0; i < txNrCount; i++) {
            int txNr = (txNrBegin + (int)i) % MAX_TX_CNT;
            //...
        }
    }
}

Edit: handle roll-over of txNrs, i.e. ranges like (99998, 99999, 0, 1)

@chandan-ultraviolette
Copy link
Author

Thanks @matth-x , One doubt as post reboot if last state was charging, it continues the charging. I think mocpp also storing the energy consumed wh so how to fetch that number from mocpp stack so can start increasing the energy consumption from that number.

@chandan-ultraviolette
Copy link
Author

@matth-x I noticed one bug related to SD files in 1.6.0 stack. Suppose StopTxnSampledData is false initially and after we do multiple transaction & enable enable StopTxnSampledData to true. It will not create the SD file for future transaction.

@matth-x
Copy link
Owner

matth-x commented Jun 14, 2024

Hi @chandan-ultraviolette, MicroOcpp does not terminate running transactions automatically when being initialized. This needs to be explicitly done by calling endTransaction() after mocpp_initialize() (not required to terminate it, but most chargers do it). Although the Start-/StopTx energy values are being stored by MicroOcpp once the operation has been initiated, that's not the case for the EnergyMeterInput over reboots. In general, the MeterValues, Start- and StopTx operations will always capture the original value of the EnergyMeterInput, there is no processing / correction step in between. It's the responsibility of the firmware to persist the energy register over reboots.

StopTxnSampledData should contain the measurands, like "Energy.Active.Import.Register".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants