Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions agent/tauhkagent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
agent_class: 'tauHKAgent'
instance_id: 'tauhk-1'
processes:
advertise:
startup: true
data:
settables:
global_options:
restart: []
rtd_0:
logdac: [int, [0, 15]]
something: [float, [0, 15.1]]
uvolts: [bool, []]
choosable: [enum, {a: 1, b: 2}]
receive_data:
startup: true
data_settings:
timestamp_field: timestamp
data:
timestamp: 1601925677.6914878
rtd_0_logdac: 12.0
tasks:
generic_send: {}
2 changes: 2 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
import HWPSupervisor from './panels/HWPSupervisor.vue';
import CrateAgent from './panels/CrateAgent.vue';
import DS378Agent from './panels/DS378.vue';
import tauHKAgent from './panels/tauHKAgent.vue';

/* Make a map of components to use in activeComp computed property;
see
Expand Down Expand Up @@ -179,6 +180,7 @@
'HWPSupervisor': HWPSupervisor,
'CrateAgent': CrateAgent,
'DS378Agent': DS378Agent,
'tauHKAgent': tauHKAgent,

};

Expand Down
10 changes: 10 additions & 0 deletions src/components/OpDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
</option>
</select>

<!-- options_style='object_transpose' -->
<select class="ocs_double"
:value="modelValue"
@input="emitValue($event.target.value)"
v-if="options_style == 'object_transpose'">
<option v-for="(value, key) in options" v-bind:key="value" :value="value">
{{ key }}
</option>
</select>

</div>
</template>

Expand Down
176 changes: 176 additions & 0 deletions src/panels/tauHKAgent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<template>
<AgentPanelBase @clientConnected="startListening()"/>

<div class="block_holder ocs_ui">

<!-- Left block -->
<div class="block_unit">
<div class="box">
<OcsAgentHeader :panel="panel">tauHKAgent</OcsAgentHeader>
<h2>Connection</h2>
<OpReading
caption="Address"
v-bind:value="address">
</OpReading>
<OpReading
caption="Connection"
mode="ok"
v-bind:value="panel.connection_ok">
</OpReading>
<OpReading
caption="Latest data"
mode="ok_val"
v-bind:value="recent_ok">
</OpReading>
<OpReading
caption="Crate status"
mode="ok_val"
v-bind:value="crate_ok">
</OpReading>
</div>

<div class="box">

<h2>Set Option</h2>
<OpDropdown
caption="Channel"
:options="channels"
v-model="choice.channel" />

<OpDropdown
caption="Option"
:options="options"
v-model="choice.option" />

<OpDropdown
v-if="optionType == 'enum'"
caption="Value"
:options="settables[choice.channel][choice.option][1]"
options_style="object_transpose"
@onUpdated="vChange()"
v-model="choice.value" />

<OpDropdown
v-else-if="optionType == 'bool'"
caption="Value"
:options="[true, false]"
options_style="array"
v-model="choice.value" />

<OpParam
v-else
caption="Value"
v-model="choice.value"/>

<div class="ocs_row">
<label />
<button class="ocs_double"
:disabled="accessLevel < 1"
@click="setValue">Set value</button>
</div>


</div>

<h2>Upload Excitations</h2>
<OcsTask :op_data="ops.load_config">
<OpParam
caption="Config file path"
v-model.string="ops.load_config.params.config_file"/>
</OcsTask>

</div>

<!-- Right block -->
<div class="block_unit">

<OcsOpAutofill
:ops_parent="ops"
/>

</div>
</div>
</template>

<script>
export default {
name: 'tauHKAgent',
props: {
address: String,
},
inject: ['accessLevel'],
data: function () {
return {
panel: {},
ops: window.ocs_bundle.web.ops_data_init({
generic_send: {
auto: true,
params: {
channel: null,
option: null,
value: null,
}
},
receive_data: { auto: true},
start_crate: { auto: true},
}),
first_pop: true,
settables: {},
choice: { channel: null, option: null, value: null }
}
},
computed: {
recent_ok() {
let timestamp = this.ops.receive_data.session.data?.timestamp;
if (timestamp) {
let dt = window.ocs_bundle.util.timestamp_now() - timestamp;
return [dt < 90, window.ocs_bundle.util.human_timespan(dt) + ' ago'];
}
return [false, "No data"];
},
crate_ok() {
let status = this.ops.start_crate.session.data?.is_alive;
if (status === undefined) return [false, "Never Started"];
let message = this.ops.start_crate.session.data?.latest_log;
return [status, message];
},
channels() {
return Object.keys(this.settables);
},
options() {
if (this.choice?.channel)
return Object.keys(this.settables[this.choice.channel]);
return [];
},
optionType() {
if (this.choice?.channel && this.choice.option
&& this.settables[this.choice.channel][this.choice.option])
return this.settables[this.choice.channel][this.choice.option][0];
return 'unknown';
},
},
methods: {
updateSettables(op_name, method, stat, msg, session) {
if (session.data?.settables) {
if (this.first_pop) {
// Change to checking every 10 seconds, after startup.
this.panel.client.clear_watchers(op_name);
this.panel.client.add_watcher(op_name, 10., this.updateSettables);
this.first_pop = false;
}
this.settables = session.data.settables;
}
},
startListening() {
this.panel.client.add_watcher('advertise', 1., this.updateSettables);
},
setValue() {
window.ocs_bundle.ui_run_task(
this.address, 'generic_send', this.choice);
},
},
}
</script>

<style scoped>
</style>