Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIMS-697: Use more specific PVs for puck names #712

Merged
merged 4 commits into from
Feb 5, 2024
Merged
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
7 changes: 3 additions & 4 deletions api/config_sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,9 @@
),
);

# Map of beamlinename to pv prefix
$bl_pv_map = array(
'i02' => 'BL02I',
'i03' => 'BL03I',
# Map of beamlinename to puck name pv
$bl_puck_names = array(
'i03' => "BL03I-MO-ROBOT-01:PUCK_%02d_NAME"
);

# Dials server values
Expand Down
16 changes: 8 additions & 8 deletions api/src/Controllers/AssignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,21 @@ function getBeamlineVisits($visit = null)
# BL03I-MO-ROBOT-01:PUCK_01_NAME
function getPuckNames()
{
global $bl_pv_map;
global $bl_puck_names;
session_write_close();
if (!$this->has_arg('prop'))
$this->_error('No proposal specified');

if (!$this->has_arg('bl'))
$this->_error('No beamline specified');
if (!array_key_exists($this->arg('bl'), $bl_pv_map))
if (!array_key_exists($this->arg('bl'), $bl_puck_names))
$this->_error('No such beamline');
$pv_prefix = $bl_pv_map[$this->arg('bl')];
$pv_names = $bl_puck_names[$this->arg('bl')];

$pvs = array();
for ($i = 1; $i < 38; $i++)
{
$id = $i < 10 ? '0' . $i : $i;
array_push($pvs, $pv_prefix . '-MO-ROBOT-01:PUCK_' . $id . '_NAME');
array_push($pvs, sprintf($pv_names, $i));
}

$rows = $this->assignData->getContainerBarcodesForProposal($this->proposalid);
Expand All @@ -132,18 +131,19 @@ function getPuckNames()
$vals = $this->pv(array_values($pvs), true, true);
foreach ($vals as $k => $v)
{
if (preg_match('/PUCK_(\d+)_NAME/', $k, $mat))
$zero_id = array_search($k, $pvs);
if ($zero_id !== false)
{
if (is_array($v) && sizeof($v))
{
$val = (!in_array($v[0], $codes) && !$this->staff) ? '[Loaded]' : $v[0];
}
else
$val = '';
array_push($return, array('id' => intval($mat[1]), 'name' => $val));
array_push($return, array('id' => $zero_id+1, 'name' => $val));
}
}

$this->_output($return);
}
}
}
15 changes: 7 additions & 8 deletions api/tests/Controllers/AssignControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ protected function setUp(): void
global $ip2bl;
$ip2bl = array(103 => 'i03');

global $bl_pv_map;
$bl_pv_map = array(
'i02' => 'BL02I',
'i03' => 'BL03I',
global $bl_puck_names;
$bl_puck_names = array(
'i03' => "BL03I-MO-ROBOT-01:PUCK_%'02d_NAME",
);
global $bl_pv_env;
$bl_pv_env = 'EPICS_CA_ADDR_LIST_TEST=666.45.678.9';
Expand Down Expand Up @@ -241,7 +240,7 @@ public function testGetPuckNamesWithPropAndValidBlSingleValReturnsData(): void
$this->assignController->args['prop'] = 3;
$this->assignController->args['bl'] = 'i03';
$this->assignController->proposalid = 3;
$this->assignController->shouldReceive('pv')->times(1)->andReturn(array('PUCK_1_NAME' => 'puck1', 'PUCK_12_NAME' => 'puck12'));
$this->assignController->shouldReceive('pv')->times(1)->andReturn(array('BL03I-MO-ROBOT-01:PUCK_01_NAME' => 'puck1', 'BL03I-MO-ROBOT-01:PUCK_12_NAME' => 'puck12'));
$this->dataLayerStub->expects($this->exactly(1))->method('getContainerBarcodesForProposal')->with(3)->willReturn(array(['BARCODE' => 1230, 'BL' => 'test03']));

$this->assignController->getPuckNames();
Expand All @@ -254,7 +253,7 @@ public function testGetPuckNamesWithPropAndValidBlArrayWithNoDataValReturnsObfus
$this->assignController->args['prop'] = 3;
$this->assignController->args['bl'] = 'i03';
$this->assignController->proposalid = 3;
$this->assignController->shouldReceive('pv')->times(1)->andReturn(array('PUCK_1_NAME' => array(11), 'PUCK_12_NAME' => array(12)));
$this->assignController->shouldReceive('pv')->times(1)->andReturn(array('BL03I-MO-ROBOT-01:PUCK_01_NAME' => array(11), 'BL03I-MO-ROBOT-01:PUCK_12_NAME' => array(12)));
$this->dataLayerStub->expects($this->exactly(1))->method('getContainerBarcodesForProposal')->with(3)->willReturn(array(['BARCODE' => 1230, 'BL' => 'test03']));

$this->assignController->getPuckNames();
Expand All @@ -267,7 +266,7 @@ public function testGetPuckNamesWithPropAndValidBlArrayWithMatchingDataValReturn
$this->assignController->args['prop'] = 3;
$this->assignController->args['bl'] = 'i03';
$this->assignController->proposalid = 3;
$this->assignController->shouldReceive('pv')->times(1)->andReturn(array('PUCK_1_NAME' => array(11), 'PUCK_12_NAME' => array(1230)));
$this->assignController->shouldReceive('pv')->times(1)->andReturn(array('BL03I-MO-ROBOT-01:PUCK_01_NAME' => array(11), 'BL03I-MO-ROBOT-01:PUCK_12_NAME' => array(1230)));
$this->dataLayerStub->expects($this->exactly(1))->method('getContainerBarcodesForProposal')->with(3)->willReturn(array(['BARCODE' => 1230, 'BL' => 'test03']));

$this->assignController->getPuckNames();
Expand All @@ -281,7 +280,7 @@ public function testGetPuckNamesWithPropAndValidBlArrayForStaffMemberReturnsReal
$this->assignController->args['bl'] = 'i03';
$this->assignController->proposalid = 3;
$this->assignController->staff = true;
$this->assignController->shouldReceive('pv')->times(1)->andReturn(array('PUCK_1_NAME' => array(11), 'PUCK_12_NAME' => array(1231)));
$this->assignController->shouldReceive('pv')->times(1)->andReturn(array('BL03I-MO-ROBOT-01:PUCK_01_NAME' => array(11), 'BL03I-MO-ROBOT-01:PUCK_12_NAME' => array(1231)));
$this->dataLayerStub->expects($this->exactly(1))->method('getContainerBarcodesForProposal')->with(3)->willReturn(array(['BARCODE' => 1230, 'BL' => 'test03']));

$this->assignController->getPuckNames();
Expand Down
Loading