Skip to content
Snippets Groups Projects
Commit b1a24f79 authored by Manuel Krombholz's avatar Manuel Krombholz
Browse files

Added StateData to Item

parent 98d56fe6
No related branches found
No related tags found
2 merge requests!12Resolve "Cleanup parser",!11Resolve "Add processing frequency option for items"
......@@ -296,6 +296,8 @@ aspect ItemHandling {
try {
// sendState() refined in MQTT and Influx aspect
sendState();
} catch (Exception e) {
logger.catching(e);
}
......@@ -458,6 +460,11 @@ aspect ItemHandling {
}
//--- onReceiveStateChange ---
protected void Item.onReceiveStateChange() {
//Instant lastChange = this.
}
......
aspect StateData {
public void StateData.afterStateChangeApplied() {
}
public void StateData.checkStateTransitionTime() {
}
}
\ No newline at end of file
......@@ -86,6 +86,9 @@ Comment = "//" [^\n\r]+
"incoming" { return sym(Terminals.INCOMING); }
"items" { return sym(Terminals.ITEMS); }
"itemType" { return sym(Terminals.ITEM_TYPE); }
"ItemPerformance" { return sym(Terminals.ITEM_PERFORMANCE); }
"performance" { return sym(Terminals.PERFORMANCE); }
"procFreq" { return sym(Terminals.PROCESS_FREQUENCY); }
"label" { return sym(Terminals.LABEL); }
"links" { return sym(Terminals.LINKS); }
"metaData" { return sym(Terminals.META_DATA); }
......
......@@ -50,6 +50,7 @@ Root goal =
| influx_root.ir {: return eph.createRoot(ir); :}
| machine_learning_root.ml {: return eph.createRoot(ml); :}
| rule.rule {: return eph.createRoot(rule); :}
| item_performance.ip {: return eph.createRoot(ip); :}
;
%left RB_ROUND;
......@@ -132,6 +133,7 @@ Item item_body =
| STATE EQUALS TEXT.n item_body.i {: i.setStateFromString(n); return i; :}
| TOPIC EQUALS TEXT.n item_body.i {: return eph.setTopic(i, n); :}
| CATEGORY EQUALS TEXT.n item_body.i {: return eph.setCategory(i, n); :}
| PERFORMANCE EQUALS TEXT.n item_body.i {: return eph.setPerformance(i, n); :}
| META_DATA EQUALS string_map.md item_body.i
{: return eph.setMetaData(i, md); :}
| {: return eph.createItem(); :}
......@@ -328,3 +330,14 @@ IntegerKeyMap integer_map_body =
return result;
:}
;
ItemPerformance item_performance =
ITEM_PERFORMANCE COLON item_performance_body.ipb SEMICOLON {: return ipb; :}
;
// ItemPerformance: id="" procFreq="" persFreq="";
ItemPerformance item_performance_body =
ID EQUALS TEXT.n item_performance_body.ip {: return eph.setID(ip, n); :}
| PROCESS_FREQUENCY EQUALS TEXT.n item_performance_body.ip {: ip.setEventProcessingFrequency(Double.parseDouble(n)); return ip; :}
| {: return new ItemPerformance(); :}
;
\ No newline at end of file
......@@ -25,9 +25,9 @@ rel Channel.LinkedItem* <-> Item.Channel? ;
Parameter : DescribableModelElement ::= <Type:ParameterValueType> [DefaultValue:ParameterDefaultValue] <Context:String> <Required:boolean> ;
ParameterDefaultValue ::= <Value:String> ;
abstract Item : LabelledModelElement ::= <_fetched_data:boolean> MetaData:ItemMetaData* [ItemObserver] ;
abstract Item : LabelledModelElement ::= <_fetched_data:boolean> MetaData:ItemMetaData* [ItemObserver] [StateData];
rel Item.Category? -> ItemCategory ;
rel Item.ItemPerformance -> ItemPerformance ;
abstract ItemWithBooleanState : Item ::= <_state:boolean> ;
abstract ItemWithStringState : Item ::= <_state:String> ;
......@@ -50,6 +50,9 @@ ItemMetaData ::= <Key:String> <Value:String> ;
ItemCategory ::= <Name:String> ;
StateData ::= <lastChangeDate:Instant> ;
rel StateData.ItemPerformance -> ItemPerformance ;
Group : LabelledModelElement ::= Group* Item* [AggregationFunction:GroupAggregationFunction] ;
abstract GroupAggregationFunction ;
SimpleGroupAggregationFunction : GroupAggregationFunction ::= <FunctionName:SimpleGroupAggregationFunctionName> ;
......
......@@ -24,11 +24,13 @@ public class EraserParserHelper {
private Map<String, Parameter> parameterMap = new HashMap<>();
private Map<String, Item> itemMap = new HashMap<>();
private Map<String, Group> groupMap = new HashMap<>();
private Map<String, ItemPerformance> itemPerformanceMap = new HashMap<>();
private Map<Thing, String> missingThingTypeMap = new HashMap<>();
private Map<Channel, String> missingChannelTypeMap = new HashMap<>();
private Map<Item, String> missingTopicMap = new HashMap<>();
private Map<Item, String> missingItemCategoryMap = new HashMap<>();
private Map<Designator, String> missingItemForDesignator = new HashMap<>();
private Map<Thing, Iterable<String>> missingChannelListMap = new HashMap<>();
......@@ -36,6 +38,7 @@ public class EraserParserHelper {
private Map<Item, Iterable<String>> missingControllingListMap = new HashMap<>();
private Map<Group, Iterable<String>> missingSubGroupListMap = new HashMap<>();
private Map<Group, Iterable<String>> missingItemListMap = new HashMap<>();
private Map<Item, String> missingItemPerformanceMap = new HashMap<>();
private Map<ThingType, Iterable<String>> missingChannelTypeListMap = new HashMap<>();
private Map<ThingType, Iterable<String>> missingParameterListMap = new HashMap<>();
......@@ -93,6 +96,7 @@ public class EraserParserHelper {
resolveList(itemMap, missingItemLinkListMap, Channel::addLinkedItem);
resolveList(groupMap, missingSubGroupListMap, Group::addGroup);
resolveList(itemMap, missingItemListMap, this::addItemToGroup);
resolve(itemPerformanceMap, missingItemPerformanceMap, this::setPerformanceOnItem);
resolveList(channelTypeMap, missingChannelTypeListMap, ThingType::addChannelType);
resolveList(parameterMap, missingParameterListMap, ThingType::addParameter);
resolveList(itemMap, missingControllingListMap, Item::addControlling);
......@@ -100,6 +104,7 @@ public class EraserParserHelper {
createUnknownGroupIfNecessary();
createChannelCategories();
createItemCategories();
if (checkUnusedElements) {
checkUnusedElements();
}
......@@ -110,6 +115,12 @@ public class EraserParserHelper {
group.addItem(item);
}
private void setPerformanceOnItem(Item item, ItemPerformance itemPerformance) {
StateData stateData = item.getStateData();
ItemObserver itemObserver = item.getItemObserver();
item.getStateData().setItemPerformance(itemPerformance);
}
private void fillUnused() {
unusedElements.addAll(thingTypeMap.values());
unusedElements.addAll(channelTypeMap.values());
......@@ -222,6 +233,12 @@ public class EraserParserHelper {
return thing;
}
public ItemPerformance setID(ItemPerformance itemPerformance, String id) {
itemPerformance.setID(id);
itemPerformanceMap.put(id,itemPerformance);
return itemPerformance;
}
public ThingType setID(ThingType thingType, String id) {
thingType.setID(id);
thingTypeMap.put(id, thingType);
......@@ -255,6 +272,7 @@ public class EraserParserHelper {
return c;
}
public Channel setLinks(Channel c, StringList linkNames) {
missingItemLinkListMap.put(c, linkNames);
return c;
......@@ -285,6 +303,11 @@ public class EraserParserHelper {
return item;
}
public Item setPerformance(Item item, String performanceName) {
missingItemPerformanceMap.put(item, performanceName);
return item;
}
public Item setMetaData(Item item, StringKeyMap metaData) {
for (AbstractMap.SimpleEntry<String, String> entry : metaData) {
item.addMetaData(new ItemMetaData(entry.getKey(), entry.getValue()));
......@@ -471,6 +494,12 @@ public class EraserParserHelper {
return result;
}
public Root createRoot(ItemPerformance itemPerformance) {
Root result = createRoot();
result.addItemPerformance(itemPerformance);
return result;
}
//+++ newStuff (to be categorized) +++
public Designator createDesignator(String itemName) {
Designator result = new Designator();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment