Skip to content

Commit

Permalink
Merge pull request #24 from percival-detector/dev
Browse files Browse the repository at this point in the history
Updates requested from Percival application testing.
  • Loading branch information
ajgdls committed Oct 24, 2017
2 parents d31249f + ecc411f commit e0ec6e9
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 27 deletions.
8 changes: 4 additions & 4 deletions percival/carrier/registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ def __init__(self):
"PGA_GAIN_Reset": MapField("PGA_GAIN_Reset", 6, 2, 12),
"PGA_GAIN_SR": MapField("PGA_GAIN_SR", 6, 2, 14),
"DURATION_Sampling_prep_phase": MapField("DURATION_Sampling_prep_phase", 7, 16, 0),
"DURATION_Sampling_phase": MapField("DURATION_Sampling_phase", 7, 16, 15),
"DURATION_Sampling_phase": MapField("DURATION_Sampling_phase", 7, 16, 16),
"DURATION_ADC_prep_phase": MapField("DURATION_ADC_prep_phase", 8, 16, 0),
"DURATION_Reset_phase": MapField("DURATION_Reset_phase", 8, 16, 15),
"DURATION_Reset_phase": MapField("DURATION_Reset_phase", 8, 16, 16),
"SAMPLING_PREP_step1": MapField("SAMPLING_PREP_step1", 9, 8, 0),
"SAMPLING_PREP_step2": MapField("SAMPLING_PREP_step2", 9, 8, 8),
"SAMPLING_PREP_step3": MapField("SAMPLING_PREP_step3", 9, 8, 16),
Expand Down Expand Up @@ -554,8 +554,8 @@ def __init__(self):
"ADC_RAMPS_PHASE_CConvEn_fall": MapField("ADC_RAMPS_PHASE_CConvEn_fall", 23, 16, 16),
"ADC_RAMPS_PHASE_FConvEn_rise": MapField("ADC_RAMPS_PHASE_FConvEn_rise", 24, 16, 0),
"ADC_RAMPS_PHASE_FConvEn_fall": MapField("ADC_RAMPS_PHASE_FConvEn_fall", 24, 16, 16),
"STREAMOUT_PHASE_LoadDO_rise": MapField("STREAMOUT_PHASE_LoadDO_rise", 25, 16, 0),
"STREAMOUT_PHASE_sr7CDNin_rise": MapField("STREAMOUT_PHASE_sr7CDNin_rise", 25, 16, 16),
"STREAMOUT_PHASE_sr7CDNin_rise": MapField("STREAMOUT_PHASE_sr7CDNin_rise", 25, 16, 0),
"STREAMOUT_PHASE_LoadDO_rise": MapField("STREAMOUT_PHASE_LoadDO_rise", 25, 16, 16),
"MISC_Force_DebugSel": MapField("MISC_Force_DebugSel", 26, 1, 0),
"MISC_PrstCol_options": MapField("MISC_PrstCol_options", 26, 2, 1),
"MISC_Switch_off_ClkADC_intg": MapField("MISC_Switch_off_ClkADC_intg", 26, 1, 3),
Expand Down
42 changes: 25 additions & 17 deletions percival/carrier/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,30 +267,38 @@ def _serve(self):
# Simply send back the registers
client_sock.send(encode_message(a, self.registers[a]))

if CONTROL_SETTINGS_CARRIER.start_address <= a < MONITORING_SETTINGS_CARRIER.start_address:
log.debug("***** SETTING VALUE: 0x%04X = 0x%04X", a, w)
self.registers[READ_ECHO_WORD.start_address] = w

if CONTROL_SETTINGS_BOTTOM.start_address <= a < MONITORING_SETTINGS_BOTTOM.start_address:
log.debug("***** SETTING VALUE: 0x%04X = 0x%04X", a, w)
self.registers[READ_ECHO_WORD.start_address] = w

# Implementation of some expected results
# If set value called for VCH device then the next read echo
# is happy if it sees the same value
if a == 0x022E or\
a == 0x0232 or\
a == 0x0236 or\
a == 0x023A or\
a == 0x023E or\
a == 0x0242 or\
a == 0x0246 or\
a == 0x0250:
log.debug("***** SETTING VALUE: 0x%04X", a)
self.registers[READ_ECHO_WORD.start_address] = w
#if a == 0x022E or\
# a == 0x0232 or\
# a == 0x0236 or\
# a == 0x023A or\
# a == 0x023E or\
# a == 0x0242 or\
# a == 0x0246 or\
# a == 0x0250:
# log.debug("***** SETTING VALUE: 0x%04X", a)
# self.registers[READ_ECHO_WORD.start_address] = w

# Implementation of some expected results
# If set value called for DPOT device then the next read echo
# is happy if it sees the same value without the flag for power
if a == 0x0254 or\
a == 0x0258 or\
a == 0x025C or\
a == 0x0260 or\
a == 0x0264 or\
a == 0x0268:
self.registers[READ_ECHO_WORD.start_address] = w & 0x0FFFF
#if a == 0x0254 or\
# a == 0x0258 or\
# a == 0x025C or\
# a == 0x0260 or\
# a == 0x0264 or\
# a == 0x0268:
# self.registers[READ_ECHO_WORD.start_address] = w & 0x0FFFF

chunk = client_sock.recv(block_read_bytes)

Expand Down
1 change: 1 addition & 0 deletions percival/detector/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def parse_parameters(self, param_string):
params = param_string.split("&")
for param in params:
pv = param.split("=")
pv[0] = pv[0].replace("[]", "")
# Check if the parameter already exists
if pv[0] in self._parameters:
# It does, so check if it is a list
Expand Down
3 changes: 3 additions & 0 deletions percival/detector/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ def execute_command(self, command):
if command.has_param('steps'):
steps = int(command.get_param('steps'))
self._setpoint_control.scan_set_points(setpoints, steps, dwell)
self._active_command.complete(success=True)
else:
raise PercivalDetectorError("Number of scan steps required to scan")
else:
Expand Down Expand Up @@ -1105,6 +1106,8 @@ def read(self, parameter):
reply["setpoints"] = []
for name in self._setpoint_control.set_points:
reply["setpoints"].append(name)
reply["status"] = self._setpoint_control.get_status()
self._log.info("Setpoints: %s", reply)

elif parameter == "controls":
reply = {}
Expand Down
6 changes: 4 additions & 2 deletions percival/detector/set_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ def scan_loop(self):
def get_status(self):
status = {
"scanning": self._scanning,
"scan_index": self._scan_index,
"scan": self._scan_points
"scan_index": self._scan_index
}
if self._scan_points:
status["scan"] = str(self._scan_points)
self._log.info("Status: %s", status)
return status
38 changes: 37 additions & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,47 @@ <h3>Control</h3>
<div class="row sidebar-row vertical-align">
<div class="col-xs-2">&nbsp;</div>
</div>
<div class="row sidebar-row vertical-align">
<div class="col-xs-2">Scan Set Points:</div>
<div class="col-xs-5 status vertical-align">
<small>Initial setpoint:<div class="dropdown">
<select id="scan-set-point-start">
</select>
</div></small>
<small>Final setpoint:<div class="dropdown">
<select id="scan-set-point-end">
</select>
</div></small>
<span>Number of steps:<input type="text" id="scan-sp-steps" value="10"></input></span>
<span>Dwell time (ms):<input type="text" id="scan-sp-dwell" value="1000"></input></span>
<span><button id="server-scan-set-point-cmd">Execute</button></span>
</div>
<div class="col-xs-3 status vertical-align">
<div id="sp-scan-response" class="panel panel-default">
<table>
<tr valign="top">
<td style="padding:0 15px 0 15px;">Scanning:</td><td id="sp-scan-scanning"></td>
</tr><tr>
<td style="padding:0 15px 0 15px;">Index:</td><td id="sp-scan-index"></td>
</tr><tr>
<td style="padding:0 15px 0 15px;">Scan:</td><td id="sp-scan-scanpoints"></td>
</tr>
</table>
<!--<div class="panel-heading clearfix">
<span class="panel-title pull-left">Status</span>
</div>-->
</div>
</div>

</div>
<div class="row sidebar-row vertical-align">
<div class="col-xs-2">&nbsp;</div>
</div>
<div class="row sidebar-row vertical-align">
<div class="col-xs-2">Upload Configuration File:</div>
<div class="col-xs-5 status vertical-align">
<small>
<input type="file" id="select-config-file" size="50">
<input type="file" id="select-config-file" size="500">
</input>
<div class="dropdown">
<select id="select-config">
Expand Down
48 changes: 45 additions & 3 deletions static/js/percival.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ class Monitor
this.extreme_low_threshold = lolo_val;
this.safety_exception = safety;
this.i2c_comms_error = comms;
if (hihi_val == 1 || lolo_val == 1 || safety == 1 || comms == 1){
//if (hihi_val == 1 || lolo_val == 1 || safety == 1 || comms == 1){
if (comms == 1){
$(this.parent).addClass("panel-danger");
} else {
$(this.parent).removeClass("panel-danger");
Expand Down Expand Up @@ -245,6 +246,9 @@ $( document ).ready(function()
$('#server-set-point-cmd').click(function(){
send_set_point_command();
});
$('#server-scan-set-point-cmd').click(function(){
send_scan_command();
});
$('#server-config-cmd').click(function(){
send_config_command();
});
Expand Down Expand Up @@ -318,6 +322,31 @@ function send_set_point_command()
$.put('/api/' + api_version + '/percival/cmd_apply_setpoint?setpoint=' + set_name, process_cmd_response);
}

function send_scan_command()
{
//data = {}
sp = [$('#scan-set-point-start').find(":selected").text(),$('#scan-set-point-end').find(":selected").text()];
//data = {'setpoints': sp};
//alert(data)
steps = $('#scan-sp-steps').val();
dwell = $('#scan-sp-dwell').val();
//$.put('/api/' + api_version + '/percival/cmd_scan_setpoints?dwell=' + dwell + '&steps=' + steps, data, process_cmd_response, 'json');
//alert('/api/' + api_version + '/percival/cmd_scan_setpoints?dwell=' + dwell + '&steps=' + steps);
$.ajax({
url: '/api/' + api_version + '/percival/cmd_scan_setpoints',
type: 'PUT',
dataType: 'json',
data: {
'dwell' : dwell,
'steps' : steps,
'setpoints' : sp
},
headers: {'Content-Type': 'application/json',
'Accept': 'application/json'},
success: process_cmd_response
});
}

function process_cmd_response(response)
{
}
Expand Down Expand Up @@ -434,7 +463,7 @@ function update_server_setup() {
}
});
$.getJSON('/api/' + api_version + '/percival/commands/', function(response) {
percival.sys_commands = response.commands
percival.sys_commands = response.commands;
html = "";
for (var index=0; index < percival.sys_commands.length; index++){
html += "<option role=\"presentation\">" + percival.sys_commands[index] + "</option>";
Expand All @@ -444,14 +473,27 @@ function update_server_setup() {
}
});
$.getJSON('/api/' + api_version + '/percival/setpoints/', function(response) {
percival.set_points = response.setpoints
//alert(response);
percival.set_points = response.setpoints;
html = "";
for (var index=0; index < percival.set_points.length; index++){
html += "<option role=\"presentation\">" + percival.set_points[index] + "</option>";
}
//alert(html);
if (html != $('#select-set-point').html()){
$('#select-set-point').html(html);
}
if (html != $('#scan-set-point-start').html()){
$('#scan-set-point-start').html(html);
}
if (html != $('#scan-set-point-end').html()){
$('#scan-set-point-end').html(html);
}
$('#sp-scan-scanning').text(response.status.scanning);
$('#sp-scan-index').text(response.status.scan_index);
if (response.status.scan){
$('#sp-scan-scanpoints').text(response.status.scan);
}
});
}

Expand Down

0 comments on commit e0ec6e9

Please sign in to comment.