25 lines
653 B
JavaScript
25 lines
653 B
JavaScript
// Toy DER/Storage bridge adapter for EnergiBridge canonical path
|
|
class DerBridgeAdapter {
|
|
constructor(id) {
|
|
this.id = id;
|
|
}
|
|
|
|
// Simple solve that models a local demand/consumption signal
|
|
solve(localProblem, /* sharedVariables */) {
|
|
const target = (localProblem && localProblem.vars && typeof localProblem.vars.value === 'number')
|
|
? localProblem.vars.value
|
|
: 0;
|
|
// Produce a modest consumption to demonstrate delta-sync behavior
|
|
const consumptionW = Math.max(0, target * 0.2);
|
|
return {
|
|
generationW: 0,
|
|
consumptionW,
|
|
netFlowW: -consumptionW
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
DerBridgeAdapter
|
|
};
|