Skip to content

Commit

Permalink
add numericValue to persistence previous state value
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Höhn <[email protected]>
  • Loading branch information
stefan-hoehn committed Nov 18, 2023
1 parent b4128cb commit f0057ef
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function defineOHBlocks_Persistence (f7, isGraalJs, persistenceSe
['state average', 'averageSince'], ['state delta', 'deltaSince'],
['state deviation', 'deviationSince'], ['state variance', 'varianceSince'], ['evolution rate', 'evolutionRateSince'],
['state minimum', 'minimumSince'], ['state maximum', 'maximumSince'], ['state sum', 'sumSince'],
['previous state value', 'previousState'], ['previous state value time', 'previousStateTime'],
['previous state value', 'previousState'], ['previous state numeric value', 'previousNumericState'], ['previous state value time', 'previousStateTime'],
['historic state', 'historicState']
], this.handleTypeSelection.bind(this)
), 'methodName')
Expand Down Expand Up @@ -49,6 +49,7 @@ export default function defineOHBlocks_Persistence (f7, isGraalJs, persistenceSe
'maximumSince': 'Gets the maximum value of the State of a persisted Item since a certain point in time',
'sumSince': 'Gets the sum of the previous States of a persisted Item since a certain point in time',
'previousState': 'Gets the previous state with option to skip to different value as current',
'previousNumericState': 'Gets the previous state without the unit with option to skip to different value as current',
'previousStateTime': 'Gets the time when previous state last occurred with option to skip to different value as current',
'historicState': 'Gets the historic state at a certain point in time'
}
Expand All @@ -67,7 +68,7 @@ export default function defineOHBlocks_Persistence (f7, isGraalJs, persistenceSe
if (!persistenceNameInput.getShadowDom()) {
persistenceNameInput.setShadowDom(Blockly.Xml.textToDom('<shadow type="oh_persistence_dropdown" />'))
}
if (this.methodName === 'previousState' || this.methodName === 'previousStateTime') {
if (this.methodName === 'previousState' || this.methodName === 'previousNumericState' || this.methodName === 'previousStateTime') {
if (this.getInput('dayInfo')) {
this.removeInput('dayInfo')
}
Expand Down Expand Up @@ -126,6 +127,10 @@ export default function defineOHBlocks_Persistence (f7, isGraalJs, persistenceSe
code = (isGraalJs) ? `${itemCode}.history.previousState(${skipPrevious}${persistenceExtension})?.state` : `${persistence}.previousState(${itemCode},${skipPrevious}${persistenceExtension}).getState()`
break

case 'previousNumericState':
code = (isGraalJs) ? `${itemCode}.history.previousState(${skipPrevious}${persistenceExtension})?.numericState` : `${persistence}.previousState(${itemCode},${skipPrevious}${persistenceExtension}).getNumericState()`
break

case 'previousStateTime':
code = (isGraalJs) ? `${itemCode}.history.previousState(${skipPrevious}${persistenceExtension})?.timestamp` : `${persistence}.previousState(${itemCode},${skipPrevious}${persistenceExtension}).getTimestamp()`
break
Expand Down

0 comments on commit f0057ef

Please sign in to comment.