1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Adapt naming of type and category to VILLAScontroller protocol; make signal auto config usable #224

This commit is contained in:
Sonja Happ 2020-11-12 15:11:50 +01:00
parent f110a9c5e7
commit a947226778
5 changed files with 48 additions and 50 deletions

View file

@ -119,20 +119,20 @@ class EditICDialog extends React.Component {
render() {
let typeOptions = [];
switch(this.state.category){
case "Simulator":
typeOptions = ["Dummy","Generic","DPsim","RTLAB","RSCAD"];
break;
case "Controller":
typeOptions = ["Kubernetes","VILLAS-controller"];
case "simulator":
typeOptions = ["dummy","generic","dpsim","rtlab","rscad"];
break;
case "Gateway":
typeOptions = ["VILLASnode","VILLASrelay"];
case "controller":
typeOptions = ["kubernetes","villas-controller"];
break;
case "Service":
typeOptions = ["EMS","Custom"];
case "gateway":
typeOptions = ["villas-node","villas-relay"];
break;
case "Equipment":
typeOptions = ["Chroma-emulator","Chroma-loads","SMA-sunnyboy","FLEPS","Sonnenbatterie"];
case "service":
typeOptions = ["ems","custom"];
break;
case "equipment":
typeOptions = ["chroma-emulator","chroma-loads","sma-sunnyboy","fleps","sonnenbatterie"];
break;
default:
typeOptions =[];
@ -157,11 +157,11 @@ class EditICDialog extends React.Component {
<FormGroup controlId="category">
<FormLabel column={false}>Category</FormLabel>
<FormControl as="select" value={this.state.category} onChange={(e) => this.handleChange(e)}>
<option>Simulator</option>
<option>Controller</option>
<option>Service</option>
<option>Gateway</option>
<option>Equipment</option>
<option>simulator</option>
<option>controller</option>
<option>service</option>
<option>gateway</option>
<option>equipment</option>
</FormControl>
</FormGroup>
<FormGroup controlId="type">

View file

@ -118,20 +118,20 @@ class NewICDialog extends React.Component {
render() {
let typeOptions = [];
switch(this.state.category){
case "Simulator":
typeOptions = ["Dummy","Generic","DPsim","RTLAB","RSCAD"];
case "simulator":
typeOptions = ["dummy","generic","dpsim","rtlab","rscad"];
break;
case "Controller":
typeOptions = ["Kubernetes","VILLAS-controller"];
case "controller":
typeOptions = ["kubernetes","villas-controller"];
break;
case "Gateway":
typeOptions = ["VILLAS-node","VILLAS-relay"];
case "gateway":
typeOptions = ["villas-node","villas-relay"];
break;
case "Service":
typeOptions = ["EMS","Custom"];
case "service":
typeOptions = ["ems","custom"];
break;
case "Equipment":
typeOptions = ["Chroma-emulator","Chroma-loads","SMA-sunnyboy","FLEPS","Sonnenbatterie"];
case "equipment":
typeOptions = ["chroma-emulator","chroma-loads","sma-sunnyboy","fleps","sonnenbatterie"];
break;
default:
typeOptions =[];
@ -155,11 +155,11 @@ class NewICDialog extends React.Component {
<FormLabel>Category of component</FormLabel>
<FormControl as="select" value={this.state.category} onChange={(e) => this.handleChange(e)}>
<option default>Select category</option>
<option>Simulator</option>
<option>Controller</option>
<option>Service</option>
<option>Gateway</option>
<option>Equipment</option>
<option>simulator</option>
<option>controller</option>
<option>service</option>
<option>gateway</option>
<option>equipment</option>
</FormControl>
</FormGroup>
<FormGroup controlId="type">

View file

@ -465,7 +465,7 @@ class Scenario extends React.Component {
let componentConfig = this.state.configs[index];
// determine apiurl of infrastructure component
let ic = this.state.ics.find(ic => ic.id === componentConfig.icID)
if(!ic.type.includes("VILLASnode") && !ic.type.includes("villasnode") && !ic.type.includes("VILLASNODE")){
if(!ic.type.includes("villas-node")){
let message = "Cannot autoconfigure signals for IC type " + ic.type + " of category " + ic.category + ". This is only possible for gateway ICs of type 'VILLASnode'."
console.warn(message);
@ -479,14 +479,10 @@ class Scenario extends React.Component {
}
let splitWebsocketURL = ic.websocketurl.split("/")
let request = {};
request["id"] = this.uuidv4();
request["action"] = "nodes"
AppDispatcher.dispatch({
type: 'signals/start-autoconfig',
data: request,
url: ic.apiurl,
url: ic.apiurl+"/nodes",
socketname: splitWebsocketURL[splitWebsocketURL.length -1],
token: this.state.sessionToken,
configID: componentConfig.id

View file

@ -34,12 +34,11 @@ class SignalStore extends ArrayStore{
return super.reduce(state, action);
case 'signals/start-autoconfig':
this.dataManager.startAutoConfig(action.data, action.url, action.socketname, action.token, action.configID)
this.dataManager.startAutoConfig(action.url, action.socketname, action.token, action.configID)
return super.reduce(state, action);
case 'signals/autoconfig-loaded':
console.log("AutoConfig Loaded: ", action.data)
// TODO save signal config contained in action.data
this.dataManager.saveSignals(action.data, action.token, action.configID, action.socketname);
return super.reduce(state, action);

View file

@ -37,13 +37,13 @@ class SignalsDataManager extends RestDataManager{
}
startAutoConfig(data, url, socketname, token, configID){
startAutoConfig(url, socketname, token, configID){
// This function queries the VILLASnode API to obtain the configuration of the VILLASnode located at url
// Endpoint: http[s]://server:port/api/v1 (to be generated based on IC API URL, port 4000)
// data contains the request data: { action, id, (request)}
// See documentation of VILLASnode API: https://villas.fein-aachen.org/doc/node-dev-api-node.html
RestAPI.post(url, data).then(response => {
RestAPI.get(url, null).then(response => {
AppDispatcher.dispatch({
type: 'signals/autoconfig-loaded',
data: response,
@ -59,13 +59,12 @@ class SignalsDataManager extends RestDataManager{
})
}
saveSignals(data, token, configID, socketname){
// data.response contains the response from the VILLASnode API, an array of node configurations
saveSignals(nodes, token, configID, socketname){
if(!data.hasOwnProperty("response")){
if(nodes.length === 0){
const SIGNAL_AUTOCONF_ERROR_NOTIFICATION = {
title: 'Failed to load signal config ',
message: 'VILLASnode returned no response field.',
title: 'Failed to load nodes ',
message: 'VILLASnode returned empty response',
level: 'error'
};
NotificationsDataManager.addNotification(SIGNAL_AUTOCONF_ERROR_NOTIFICATION);
@ -74,7 +73,8 @@ class SignalsDataManager extends RestDataManager{
let configured = false;
let error = false;
for(let nodeConfig of data.response){
for(let nodeConfig of nodes){
console.log("parsing node config: ", nodeConfig)
if(!nodeConfig.hasOwnProperty("name")){
console.warn("Could not parse the following node config because it lacks a name parameter:", nodeConfig);
} else if(nodeConfig.name === socketname){
@ -88,7 +88,6 @@ class SignalsDataManager extends RestDataManager{
continue;
}
// signals are not yet configured:
console.log("Adding signals of websocket: ", nodeConfig);
let index_in = 1
let index_out = 1
@ -104,9 +103,10 @@ class SignalsDataManager extends RestDataManager{
// add all in signals
for(let inSig of nodeConfig.in.signals) {
console.log("adding input signal:", inSig);
if (inSig.enabled) {
console.log("adding input signal:", inSig);
let newSignal = {
configID: configID,
direction: 'in',
@ -140,9 +140,9 @@ class SignalsDataManager extends RestDataManager{
// add all out signals
for (let outSig of nodeConfig.out.signals) {
console.log("adding output signal:", outSig);
if (outSig.enabled) {
console.log("adding output signal:", outSig);
let newSignal = {
configID: configID,
direction: 'out',
@ -165,8 +165,11 @@ class SignalsDataManager extends RestDataManager{
console.log("Configured", index_in-1, "input signals and", index_out-1, "output signals");
configured=true;
} else {
console.log("ignoring node with name ",nodeConfig.name, " expecting ", socketname )
}
}
if(!error) {