Skip to content

Commit

Permalink
Merge pull request #57 from simonsobs/synaccess-new-schema
Browse files Browse the repository at this point in the history
Synaccess agent -- mods to support old and new acq process
  • Loading branch information
mhasself authored Feb 2, 2024
2 parents 26f7864 + 35fc43c commit 9ca4239
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 23 deletions.
34 changes: 20 additions & 14 deletions agent/synaccessagent.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
agent_class: 'SynaccessAgent'
instance_id: 'synacc-1'
instance_id: 'synacc-2'
processes:
status_acq:
acq:
startup: true
data_settings: {
'timestamp_field': 'timestamp'
}
data: {
'fields': {
'synaccess': {
0: 1,
1: 0,
2: 0,
3: 1,
4: 0,
},
},
"timestamp": 1601925677.6914878,
}
data:
fields:
0:
status: 1
name: OUTLETA
1:
status: 1
name: OUTLETB
2:
status: 0
name: OUTLETC
3:
status: 1
name: OUTLETD
4:
status: 0
name: OUTLETE
timestamp: 1601925677.6914878
tasks:
set_outlet: {}
reboot: {}
Expand Down
25 changes: 25 additions & 0 deletions agent/synaccessagent_old.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
agent_class: 'SynaccessAgent'
instance_id: 'synacc-1'
processes:
status_acq:
startup: true
data_settings: {
'timestamp_field': 'timestamp'
}
data: {
'fields': {
'synaccess': {
0: 1,
1: 0,
2: 0,
3: 1,
4: 0,
},
},
"timestamp": 1601925677.6914878,
}
tasks:
set_outlet: {}
reboot: {}
set_all: {}
get_status: {}
57 changes: 48 additions & 9 deletions src/panels/SynaccessAgent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<!-- Right block -->
<div class="block_unit">
<OcsProcess
v-if="acq_op_name && acq_op_name=='acq'"
:op_data="ops.acq">
</OcsProcess>

<OcsProcess
v-if="acq_op_name && acq_op_name=='status_acq'"
:op_data="ops.status_acq">
</OcsProcess>

Expand Down Expand Up @@ -114,19 +120,29 @@
outlet_warning: null,
outlets: {},
ops: window.ocs_bundle.web.ops_data_init({
'status_acq': {},
'status_acq': {}, // socs <= 0.4.5
'acq': {}, // socs >= 0.4.6 (?)
'set_outlet': {params: {}},
'get_status': {},
'set_all': {},
'reboot': {},
}),
// Transitional ... once we see data from either acq or
// status_acq, write that here and start ignoring the other one.
// If it is after Jan 1 2025, you can probably remove this generality!
acq_op_name: null,
}
},
props: {
address: String,
},
methods: {
update_outlet_states(op_name, method, stat, msg, session) {
if (this.acq_op_name && (this.acq_op_name != op_name)) {
this.panel.client.clear_watchers(op_name);
return;
}
if (!this.panel.connection_ok) {
this.outlets = {};
this.outlet_warning = 'No connection to agent!';
Expand All @@ -144,15 +160,34 @@
return;
}
if (!this.acq_op_name)
this.acq_op_name = op_name;
// Process data to look like ibootbar...
let new_info = {};
for (const [sidx, state] of Object.entries(session.data.fields.synaccess)) {
let idx = parseInt(sidx);
new_info[idx] = {
name: 'outlet' + (idx + 1),
description: ['off', 'on'][state],
idx: idx,
};
if (op_name == 'status_acq') {
// Old format
for (const [sidx, state] of Object.entries(session.data.fields.synaccess)) {
let idx = parseInt(sidx);
new_info[idx] = {
name: 'outlet' + (idx + 1),
description: ['off', 'on'][state],
idx: idx,
};
}
} else {
// New format
[0,1,2,3,4,5,6,7].map( idx => {
let v = session.data.fields[idx];
if (v) {
new_info[idx] = v;
new_info[idx].idx = idx;
new_info[idx].description = ['off', 'on'][v.status];
}
});
}
this.outlets = new_info;
this.outlet_warning = null;
},
Expand All @@ -172,15 +207,19 @@
return window.ocs.connection.isConnected;
case 'acq':
{
let session = this.ops.status_acq.session;
if (!this.acq_op_name)
return false
let session = this.ops[this.acq_op_name].session;
return (session.status == 'running' ||
session.status == 'starting');
}
}
return false;
},
startListening() {
// Subscribe to old and new processes for now.
this.panel.client.add_watcher('status_acq', 5., this.update_outlet_states);
this.panel.client.add_watcher('acq', 5., this.update_outlet_states);
},
},
}
Expand Down

0 comments on commit 9ca4239

Please sign in to comment.