Creating State Machine and using simulated data help

Hello again community!

I’m creating a package for my project using OpenEms and I require some help with the coding part.

I have now created a State Machine that does a simple discerning process : To turn on a diesel generator or not. The idea behind this is to use 2 values to compare: Forecasted power vs Actual active power. If the forecasted one is less than the actual power, then my diesel generator should turn on. The other way around leads to the diesel generator to be off, as expected.

Now, since I’m not a expert in programming in this language I’m having some hard time. The forecasted values for now will be simulated and loaded in a csv file. My question now is how should my state machine work to load this csv file.

I tried using the same concept that io.openems.edge.simulator uses, but I’m not sure about it.

Below is one of the States of my State Machine where it decides to change or not to the next state which is turning on or not the engine.

package io.openems.edge.dieselgenerator.statemachine;

import java.io.IOException;

import io.openems.common.exceptions.InvalidValueException;
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
import io.openems.edge.common.startstop.StartStop;
import io.openems.edge.common.statemachine.StateHandler;
import io.openems.edge.dieselgenerator.DieselGenerator;
import io.openems.edge.dieselgenerator.statemachine.StateMachine.State;
import io.openems.edge.meter.api.SymmetricMeter;
import io.openems.edge.simulator.forecast.predefined.Config;



public class PredictionCheckHandler extends StateHandler<State,Context>{


	private Config config;
	
	// Gets the actual active power
	
	private State predictionCheck(SymmetricMeter meter, CsvUtils data) throws InvalidValueException{
		float actualActivePower = meter.getActivePower().getOrError();
		
    //Here I'm trying to get the data from the csv, nonetheless I know that this returns me an array of data and not the specific one I require//
    DataContainer forecastedPower = CsvUtils.readCsvFileFromResource(ForecastPredefined.class, this.config.source().filename,
				this.config.format(), this.config.factor());
		
		if(actualActivePower < forecastedPower) {
			return State.START_ENGINE;
		}else {
			return State.PREDICTION_MISSMATCH;
			}
		}

	@Override
	protected State runAndGetNextState(Context context) throws OpenemsNamedException {
		// TODO Auto-generated method stub
		return null;
	}

}

Any suggestions? I’d appreciate it a lot!

Regards

Hello again,

I found out some errors in my code and other details, but now I have an issue resolving my new bundle. The message that shows is the following:

Resolution failed. Capabilities satisfying the following requirements could not be found:
[<<INITIAL>>]
  ⇒ osgi.identity: (osgi.identity=io.openems.edge.dieselgenerator)
      ⇒ [io.openems.edge.dieselgenerator version=1.0.0.202107150519]
          ⇒ osgi.wiring.package: (osgi.wiring.package=io.openems.edge.simulator)
[osgi.cmpn version=7.0.0.201802012110]
  ⇒ osgi.unresolvable: (&(must.not.resolve=*)(!(must.not.resolve=*)))
[ch.qos.logback.classic version=1.2.3]
  ⇒ osgi.wiring.package: (&(osgi.wiring.package=ch.qos.logback.core.util)(version>=1.2.0)(!(version>=2.0.0)))
[org.eclipse.jetty.alpn.server version=9.4.35.v20201120]
  ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.eclipse.jetty.alpn)(version>=1.1.3))

Do you know why is this happening?