Make 'chips' and 'states' global, not of rfid-read
This commit is contained in:
parent
69758aead6
commit
010ed78bd2
|
@ -70,21 +70,20 @@
|
|||
|
||||
/* [1] On récupére la liste des actions
|
||||
=========================================================*/
|
||||
/* (1) On récupère les actions */
|
||||
$actionsReq = new Repo('action/getAll');
|
||||
$actions = ($actionsReq->error->get()==Err::Success) ? $actionsReq->answer() : [];
|
||||
// var_dump($actionsReq->answer());
|
||||
|
||||
|
||||
/* [2] On regroupe les actions par TIMEOUT
|
||||
=========================================================*/
|
||||
/* (2) On regroupe les actions par TIMEOUT */
|
||||
$sorted_actions = [];
|
||||
|
||||
foreach($actions as $a=>$action){
|
||||
/* (1) Si aucune valeur pour ce TIMEOUT, on crée un tableau vide */
|
||||
/* (3) Si aucune valeur pour ce TIMEOUT, on crée un tableau vide */
|
||||
if( !isset($sorted_actions[$action['timeout']]) )
|
||||
$sorted_actions[$action['timeout']] = [];
|
||||
|
||||
/* (2) On ajoute l'action au TIMEOUT */
|
||||
/* (4) On ajoute l'action au TIMEOUT */
|
||||
$sorted_actions[$action['timeout']][] = [
|
||||
'id_action' => intval($action['id_action']),
|
||||
'name' => strtolower($action['name']),
|
||||
|
@ -94,47 +93,8 @@
|
|||
}
|
||||
|
||||
|
||||
/* [3] On récupère la liste des états
|
||||
=========================================================*/
|
||||
$globalStatesReq = new Repo('global_state/getAll');
|
||||
$globalStates = ($globalStatesReq->error->get()==Err::Success) ? $globalStatesReq->answer() : [];
|
||||
|
||||
|
||||
/* [4] On récupère la liste des MODULES (puces)
|
||||
=========================================================*/
|
||||
$chipsReq = new Repo('chip/getForMachine', [$_SESSION['WAREHOUSE']['id'], $_SESSION['SATS']['id']]);
|
||||
$chips = ($chipsReq->error->get()==Err::Success) ? $chipsReq->answer() : [];
|
||||
|
||||
|
||||
foreach($chips as &$chip){
|
||||
/* (1) On récupére la liste des PINS de chaque PUCE
|
||||
---------------------------------------------------------*/
|
||||
|
||||
$chip['pins'] = explode(',', $chip['pins']);
|
||||
|
||||
if( !is_array($chip['pins']) )
|
||||
$chip['pins'] = [];
|
||||
|
||||
/* (2) On récupère valeurs pour chaque état de chaque PUCE
|
||||
---------------------------------------------------------*/
|
||||
$chip['states'] = [];
|
||||
|
||||
$statesReq = new Repo('state/getForChip', [$chip['id_chip']]);
|
||||
$states = ($statesReq->error->get()==Err::Success) ? $statesReq->answer() : [];
|
||||
|
||||
// On met en forme les données : "val1,val2,val3" -> [val1, val2, val3]
|
||||
foreach($states as $s=>$state){
|
||||
|
||||
$chip['states'][$state['state']] = explode(',', $state['value']);
|
||||
|
||||
foreach($chip['states'][$state['state']] as $s2=>$state2)
|
||||
$chip['states'][$state['state']][$s2] = intval($state2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* [5] On récupère les utilisateurs + accès sur la machine
|
||||
/* [2] On récupère les utilisateurs + accès sur la machine
|
||||
=========================================================*/
|
||||
/* (1) On récupère les utilisateurs et leurs permissions */
|
||||
$permissionsReq = new Repo('action_merge/getAccess', [
|
||||
|
@ -166,8 +126,6 @@
|
|||
/* (3) Retourne les données récupérées */
|
||||
return [ 'data' => [
|
||||
'actions' => $sorted_actions,
|
||||
'states' => $globalStates,
|
||||
'chips' => $chips,
|
||||
'permissions' => $indexed_permissions
|
||||
] ];
|
||||
|
||||
|
|
|
@ -508,7 +508,59 @@
|
|||
|
||||
|
||||
|
||||
/* [2] On récupère les données de chaque feature
|
||||
/* [2] On récupère les données globales
|
||||
=========================================================*/ {
|
||||
|
||||
/* (1) On récupère la liste des états
|
||||
---------------------------------------------------------*/ {
|
||||
|
||||
$globalStatesReq = new Repo('global_state/getAll');
|
||||
$globalStates = ($globalStatesReq->error->get()==Err::Success) ? $globalStatesReq->answer() : [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (2) On récupère la liste des composants (chip)
|
||||
---------------------------------------------------------*/ {
|
||||
|
||||
/* (1) On récupère les composants disponibles */
|
||||
$chipsReq = new Repo('chip/getForMachine', [$_SESSION['WAREHOUSE']['id'], $_SESSION['SATS']['id']]);
|
||||
$chips = ($chipsReq->error->get()==Err::Success) ? $chipsReq->answer() : [];
|
||||
|
||||
|
||||
foreach($chips as &$chip){
|
||||
|
||||
/* (2) On récupére la liste des PINS de chaque COMPOSANT */
|
||||
$chip['pins'] = explode(',', $chip['pins']);
|
||||
|
||||
if( !is_array($chip['pins']) )
|
||||
$chip['pins'] = [];
|
||||
|
||||
/* (3) On récupère valeurs pour chaque état de chaque COMPOSANT */
|
||||
$chip['states'] = [];
|
||||
|
||||
$statesReq = new Repo('state/getForChip', [$chip['id_chip']]);
|
||||
$states = ($statesReq->error->get()==Err::Success) ? $statesReq->answer() : [];
|
||||
|
||||
/* (4) On met en forme les données : "val1,val2,val3" -> [val1, val2, val3] */
|
||||
foreach($states as $s=>$state){
|
||||
|
||||
$chip['states'][$state['state']] = explode(',', $state['value']);
|
||||
|
||||
foreach($chip['states'][$state['state']] as $s2=>$state2)
|
||||
$chip['states'][$state['state']][$s2] = intval($state2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* [3] On récupère les données de chaque feature
|
||||
=========================================================*/
|
||||
$features = [];
|
||||
|
||||
|
@ -540,7 +592,9 @@
|
|||
=========================================================*/
|
||||
return [
|
||||
'etrees' => $etrees,
|
||||
'feature' => $features
|
||||
'feature' => $features,
|
||||
'chips' => $chips,
|
||||
'states' => $globalStates
|
||||
];
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue