Modification des valeurs en BDD + Gestion de la méthode 'machineDefault/init' avec toutes les valeurs utiles au fonctionnement de la machine
This commit is contained in:
parent
159a77b0eb
commit
a778bac165
|
@ -3,7 +3,7 @@
|
||||||
-- http://www.phpmyadmin.net
|
-- http://www.phpmyadmin.net
|
||||||
--
|
--
|
||||||
-- Host: localhost
|
-- Host: localhost
|
||||||
-- Generation Time: Jul 19, 2016 at 10:51 AM
|
-- Generation Time: Jul 19, 2016 at 11:26 AM
|
||||||
-- Server version: 5.7.12-0ubuntu1.1
|
-- Server version: 5.7.12-0ubuntu1.1
|
||||||
-- PHP Version: 7.0.4-7ubuntu2.1
|
-- PHP Version: 7.0.4-7ubuntu2.1
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ INSERT INTO `chip` (`id_chip`, `name`, `position`, `type`) VALUES
|
||||||
|
|
||||||
CREATE TABLE `global_state` (
|
CREATE TABLE `global_state` (
|
||||||
`id_global_state` int(11) NOT NULL,
|
`id_global_state` int(11) NOT NULL,
|
||||||
`state` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
|
`global_state` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
|
||||||
`chips` varchar(30) COLLATE utf8_unicode_ci NOT NULL
|
`chips` varchar(30) COLLATE utf8_unicode_ci NOT NULL
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
|
|
||||||
|
@ -119,11 +119,11 @@ CREATE TABLE `global_state` (
|
||||||
-- Dumping data for table `global_state`
|
-- Dumping data for table `global_state`
|
||||||
--
|
--
|
||||||
|
|
||||||
INSERT INTO `global_state` (`id_global_state`, `state`, `chips`) VALUES
|
INSERT INTO `global_state` (`id_global_state`, `global_state`, `chips`) VALUES
|
||||||
(1, '0X0', '00x'),
|
(1, '0X0', '00x'),
|
||||||
(2, '100', '11x'),
|
(2, '100', 'G1x'),
|
||||||
(3, '110', '21x'),
|
(3, '110', 'B1x'),
|
||||||
(4, 'XX1', '30x');
|
(4, 'XX1', 'R0x');
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
@ -354,11 +354,11 @@ CREATE TABLE `pin_merge` (
|
||||||
--
|
--
|
||||||
|
|
||||||
INSERT INTO `pin_merge` (`id_pin_merge`, `id_chip`, `pin`, `type`) VALUES
|
INSERT INTO `pin_merge` (`id_pin_merge`, `id_chip`, `pin`, `type`) VALUES
|
||||||
(1, 1, 1, 'LED_R'),
|
(1, 1, 1, 'SERIAL'),
|
||||||
(2, 1, 2, 'LED_G'),
|
(2, 1, 2, 'SERIAL'),
|
||||||
(3, 1, 3, 'LED_B'),
|
(3, 1, 3, 'SERIAL'),
|
||||||
(4, 2, 4, 'RELAY'),
|
(4, 2, 4, 'SERIAL'),
|
||||||
(5, 3, 5, 'RELAY');
|
(5, 3, 5, 'SERIAL');
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
@ -381,15 +381,15 @@ INSERT INTO `state` (`id_state`, `id_pin_merge`, `state`, `value`) VALUES
|
||||||
(1, 1, '0', 0),
|
(1, 1, '0', 0),
|
||||||
(2, 2, '0', 0),
|
(2, 2, '0', 0),
|
||||||
(3, 3, '0', 0),
|
(3, 3, '0', 0),
|
||||||
(4, 1, '1', 0),
|
(4, 1, 'G', 0),
|
||||||
(5, 2, '1', 255),
|
(5, 2, 'G', 255),
|
||||||
(6, 3, '1', 0),
|
(6, 3, 'G', 0),
|
||||||
(7, 1, '2', 0),
|
(7, 1, 'B', 0),
|
||||||
(8, 2, '2', 0),
|
(8, 2, 'B', 0),
|
||||||
(9, 3, '2', 255),
|
(9, 3, 'B', 255),
|
||||||
(10, 1, '3', 255),
|
(10, 1, 'R', 255),
|
||||||
(11, 2, '3', 0),
|
(11, 2, 'R', 0),
|
||||||
(12, 3, '3', 0),
|
(12, 3, 'R', 0),
|
||||||
(13, 4, '0', 0),
|
(13, 4, '0', 0),
|
||||||
(14, 4, '1', 1),
|
(14, 4, '1', 1),
|
||||||
(15, 5, '0', 0),
|
(15, 5, '0', 0),
|
||||||
|
@ -717,7 +717,7 @@ ALTER TABLE `action`
|
||||||
-- AUTO_INCREMENT for table `action_merge`
|
-- AUTO_INCREMENT for table `action_merge`
|
||||||
--
|
--
|
||||||
ALTER TABLE `action_merge`
|
ALTER TABLE `action_merge`
|
||||||
MODIFY `id_action_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
MODIFY `id_action_merge` int(11) NOT NULL AUTO_INCREMENT;
|
||||||
--
|
--
|
||||||
-- AUTO_INCREMENT for table `admin`
|
-- AUTO_INCREMENT for table `admin`
|
||||||
--
|
--
|
||||||
|
@ -747,12 +747,12 @@ ALTER TABLE `machine`
|
||||||
-- AUTO_INCREMENT for table `machine_cluster`
|
-- AUTO_INCREMENT for table `machine_cluster`
|
||||||
--
|
--
|
||||||
ALTER TABLE `machine_cluster`
|
ALTER TABLE `machine_cluster`
|
||||||
MODIFY `id_machine_cluster` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
MODIFY `id_machine_cluster` int(11) NOT NULL AUTO_INCREMENT;
|
||||||
--
|
--
|
||||||
-- AUTO_INCREMENT for table `machine_cluster_merge`
|
-- AUTO_INCREMENT for table `machine_cluster_merge`
|
||||||
--
|
--
|
||||||
ALTER TABLE `machine_cluster_merge`
|
ALTER TABLE `machine_cluster_merge`
|
||||||
MODIFY `id_machine_cluster_merge` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
|
MODIFY `id_machine_cluster_merge` int(11) NOT NULL AUTO_INCREMENT;
|
||||||
--
|
--
|
||||||
-- AUTO_INCREMENT for table `module`
|
-- AUTO_INCREMENT for table `module`
|
||||||
--
|
--
|
||||||
|
@ -767,7 +767,7 @@ ALTER TABLE `pin_merge`
|
||||||
-- AUTO_INCREMENT for table `state`
|
-- AUTO_INCREMENT for table `state`
|
||||||
--
|
--
|
||||||
ALTER TABLE `state`
|
ALTER TABLE `state`
|
||||||
MODIFY `id_state` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
|
MODIFY `id_state` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||||
--
|
--
|
||||||
-- AUTO_INCREMENT for table `user`
|
-- AUTO_INCREMENT for table `user`
|
||||||
--
|
--
|
||||||
|
|
|
@ -98,14 +98,11 @@
|
||||||
"getByIdTarget"
|
"getByIdTarget"
|
||||||
],
|
],
|
||||||
|
|
||||||
"action": [
|
"action": [ "getAll", "getById" ],
|
||||||
"getAll",
|
"global_state": [ "getAll" ],
|
||||||
"getById"
|
"chip": [ "getAll" ],
|
||||||
],
|
"pin_merge": [ "getAll", "getByIdChip" ],
|
||||||
|
"state": [ "getForChip" ],
|
||||||
"global_state": [
|
|
||||||
"getAll"
|
|
||||||
],
|
|
||||||
|
|
||||||
"permission": [
|
"permission": [
|
||||||
"getAll",
|
"getAll",
|
||||||
|
|
|
@ -380,15 +380,47 @@
|
||||||
|
|
||||||
/* [2] On récupère la liste des états
|
/* [2] On récupère la liste des états
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$statesReq = new Repo('global_state/getAll');
|
$globalStatesReq = new Repo('global_state/getAll');
|
||||||
$states = ($statesReq->error==0) ? $statesReq->answer() : [];
|
$globalStates = ($globalStatesReq->error==0) ? $globalStatesReq->answer() : [];
|
||||||
|
|
||||||
|
/* [3] On récupère la liste des MODULES (puces)
|
||||||
|
=========================================================*/
|
||||||
|
$chipsReq = new Repo('chip/getAll');
|
||||||
|
$chips = ($chipsReq->error==0) ? $chipsReq->answer() : [];
|
||||||
|
|
||||||
|
|
||||||
|
foreach($chips as $c=>$chip){
|
||||||
|
/* [4] On récupére la liste des PINS de chaque PUCE
|
||||||
|
=========================================================*/
|
||||||
|
$pinsReq = new Repo('pin_merge/getByIdChip', [$chip['id_chip']]);
|
||||||
|
$pins = ($pinsReq->error==0) ? $pinsReq->answer() : [];
|
||||||
|
|
||||||
|
$chips[$c]['pins'] = [];
|
||||||
|
foreach($pins as $p=>$pin)
|
||||||
|
$chips[$c]['pins'][$p] = $pin['pin'];
|
||||||
|
|
||||||
|
|
||||||
|
/* [5] On récupère valeurs pour chaque état de chaque PUCE
|
||||||
|
=========================================================*/
|
||||||
|
$chips[$c]['states'] = [];
|
||||||
|
|
||||||
|
$statesReq = new Repo('state/getForChip', [$chip['id_chip']]);
|
||||||
|
$states = ($statesReq->error==0) ? $statesReq->answer() : [];
|
||||||
|
|
||||||
|
// On met en forme les données : "val1,val2,val3" -> [val1, val2, val3]
|
||||||
|
foreach($states as $s=>$state)
|
||||||
|
$chips[$c]['states'][$state['state']] = explode(',', $state['pin_values']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] Retorne les données
|
/* [3] Retorne les données
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return [
|
return [
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
'states' => $states
|
'globalStates' => $globalStates,
|
||||||
|
'chips' => $chips
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace manager\repo;
|
||||||
|
use \manager\Database;
|
||||||
|
use \manager\Repo;
|
||||||
|
use \manager\ManagerError;
|
||||||
|
use \manager\repo\cluster as clusterRepo;
|
||||||
|
|
||||||
|
class chip extends parentRepo{
|
||||||
|
|
||||||
|
protected static function table_name(){ static $table_name = 'chip'; return $table_name; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace manager\repo;
|
||||||
|
use \manager\Database;
|
||||||
|
use \manager\Repo;
|
||||||
|
use \manager\ManagerError;
|
||||||
|
use \manager\repo\cluster as clusterRepo;
|
||||||
|
|
||||||
|
class pin_merge extends parentRepo{
|
||||||
|
|
||||||
|
protected static function table_name(){ static $table_name = 'pin_merge'; return $table_name; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace manager\repo;
|
||||||
|
use \manager\Database;
|
||||||
|
use \manager\Repo;
|
||||||
|
use \manager\ManagerError;
|
||||||
|
use \manager\repo\cluster as clusterRepo;
|
||||||
|
|
||||||
|
class state extends parentRepo{
|
||||||
|
|
||||||
|
protected static function table_name(){ static $table_name = 'state'; return $table_name; }
|
||||||
|
|
||||||
|
|
||||||
|
/* RETOURNE LES VALEURS DE CHAQUE PIN POUR CHAQUE ETAT POUR UNE PUCE EN PARTICULIER
|
||||||
|
*
|
||||||
|
* @id_chip<int> UID de la puce
|
||||||
|
*
|
||||||
|
* @return states<Array> Retourne les données sous forme de tableau de la forme (state, chip, pin, value)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getForChip($id_chip){
|
||||||
|
|
||||||
|
$req = Database::getPDO()->prepare("SELECT s.state, pm.id_chip, GROUP_CONCAT(s.value) as pin_values
|
||||||
|
FROM state as s, pin_merge as pm
|
||||||
|
WHERE s.id_pin_merge = pm.id_pin_merge
|
||||||
|
AND pm.id_chip = :id_chip
|
||||||
|
GROUP BY s.state, pm.id_chip");
|
||||||
|
$req->execute([
|
||||||
|
':id_chip' => $id_chip
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
return $req->fetchAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue