Commit f51c30c8 authored by Langston Ball's avatar Langston Ball

Adds scenario activation, rooms, entertain areas, commands backends

parent 24bd07e9
......@@ -158,7 +158,7 @@ class AlexaController extends AppController
$this->set('_serialize', 'reply');
}
function report(){
public function report(){
$deviceTarget = $this->request->params['?']['device'];
$error = "none";
......@@ -188,4 +188,30 @@ class AlexaController extends AppController
$this->set('_serialize', 'reply');
}
public function executescenario(){
$scenario = $this->request->params['?']['scene'];
$error = "none";
$now = Time::now();
$now->format('e');
$status ="";
if(isset($scenario)){
$status = $this->DceCommandExecutor->executeScenario($scenario);
} else {
$error = "no scenario set";
}
$reply= array(
'status' => $status,
'timeSent'=>$now,
'error'=>$error
);
$this->set(compact('reply'));
$this->set('_serialize', 'reply');
}
}
......@@ -118,6 +118,37 @@ class DceCommandExecutorComponent extends Component
return $response;
}
function executeScenario($scenario){
$params=array(
'msgid'=>370,
'params'=>array(
array('28', $scenario)
)
);
$server = "localhost";
$port = 3450;
$timeout = 10;
$errno = 0;
$errstr = "";
$deviceFromID = 8;
$deviceToID = -1000;
$messageType = 1;
$messageID = $params['msgid'];
$parameters = $params['params'];
// commStart($server, $port, $deviceIDFrom)
$socket = $this->commStart($server,$port,$deviceFromID);
$this->myMessageSend($socket, $deviceFromID, $deviceToID ,$messageType,$messageID,$parameters);
$this->commEnd($socket);
return "OK";
}
function executeFormedCommand($device, $params /*array*/){
$server = "localhost";
$port = 3450;
......@@ -138,6 +169,9 @@ class DceCommandExecutorComponent extends Component
return "OK";
}
function examplePlaySecurityMessage() {
......
......@@ -38,7 +38,7 @@ class RoomsController extends AppController
public function view($id = null)
{
$room = $this->Rooms->get($id, [
'contain' => ['RoomType']
'contain' => ['RoomType', 'Commandgroup', 'EntertainArea']
]);
$this->set('room', $room);
......@@ -62,7 +62,8 @@ class RoomsController extends AppController
$this->Flash->error(__('The room could not be saved. Please, try again.'));
}
$roomType = $this->Rooms->RoomType->find('list', ['limit' => 200]);
$this->set(compact('room', 'roomType'));
$commandgroup = $this->Rooms->Commandgroup->find('list', ['limit' => 200]);
$this->set(compact('room', 'roomType', 'commandgroup'));
}
/**
......@@ -75,7 +76,7 @@ class RoomsController extends AppController
public function edit($id = null)
{
$room = $this->Rooms->get($id, [
'contain' => []
'contain' => ['Commandgroup']
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$room = $this->Rooms->patchEntity($room, $this->request->getData());
......@@ -87,7 +88,8 @@ class RoomsController extends AppController
$this->Flash->error(__('The room could not be saved. Please, try again.'));
}
$roomType = $this->Rooms->RoomType->find('list', ['limit' => 200]);
$this->set(compact('room', 'roomType'));
$commandgroup = $this->Rooms->Commandgroup->find('list', ['limit' => 200]);
$this->set(compact('room', 'roomType', 'commandgroup'));
}
/**
......
......@@ -47,7 +47,6 @@ public function initialize(array $config){
'targetForeignKey' => 'FK_DeviceData',
]);
}
......@@ -177,12 +176,58 @@ function findByDeviceCategory(Query $query, array $options){
function alexaDeviceDiscovery(){
$lightList = $this->getAlexaLightList();
$mediaScenarioList = $this->getMediaScenarios();
//$tvList = $this->getAlexaTvList();
$alexaDeviceList = array( array_merge($lightList));
$alexaDeviceList = array( array_merge($lightList, $mediaScenarioList));
return $alexaDeviceList;
}
function getMediaScenarios(){
$ret = array();
$entertainAreas = TableRegistry::get('Entertainarea')
->find('all')
->contain(['Commandgroup']);
foreach($entertainAreas as $entertainArea){
foreach($entertainArea->command_group as $CG){
$appendArray = array(
'endpointId' => $CG->PK_CommandGroup,
'manufacturerName' => 'LinuxMCE',
'friendlyName' => $CG->Description." in ".$entertainArea->Description,
'description' => 'Linuxmce Media Scene',
'displayCategories' => ['ACTIVITY TRIGGER'],
'cookie' => array(
"ismedia"=>"unknown"
),
'capabilities' => [
array(
'type'=>'AlexaInterface',
'interface'=>'Alexa.SceneController',
'version'=>"3",
'supportsDeactivation'=>true,
'proactivelyReported'=>false
)
]
);
$ret[] = $appendArray;
}
}
return $ret;
}
function deviceDataForDevice($deviceId){
......
......@@ -16,6 +16,22 @@ public function initialize(array $config){
'bindingKey' => 'PK_RoomType'
]);
$this->hasMany('EntertainArea',
[
'className' => 'Entertainarea',
'bindingKey' => 'PK_Room' ,
'foreignKey' => 'FK_Room'
]);
$this->belongsToMany('Commandgroup',
[
'through' => 'Commandgrouproom',
'bindingKey' => 'PK_Room' ,
'foreignKey' => 'FK_Room',
'targetForeignKey' => 'FK_CommandGroup'
]);
}
}
......
......@@ -10,6 +10,10 @@
<li><?= $this->Html->link(__('List Rooms'), ['action' => 'index']) ?></li>
<li><?= $this->Html->link(__('List Room Type'), ['controller' => 'Roomtypes', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Room Type'), ['controller' => 'Roomtypes', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Entertain Area'), ['controller' => 'Entertainarea', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Entertain Area'), ['controller' => 'Entertainarea', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Commandgroup'), ['controller' => 'Commandgroup', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Commandgroup'), ['controller' => 'Commandgroup', 'action' => 'add']) ?></li>
</ul>
</nav>
<div class="rooms form large-9 medium-8 columns content">
......@@ -31,6 +35,7 @@
echo $this->Form->control('psc_frozen');
echo $this->Form->control('psc_mod');
echo $this->Form->control('psc_restrict');
echo $this->Form->control('commandgroup._ids', ['options' => $commandgroup]);
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
......
......@@ -16,6 +16,10 @@
<li><?= $this->Html->link(__('List Rooms'), ['action' => 'index']) ?></li>
<li><?= $this->Html->link(__('List Room Type'), ['controller' => 'Roomtypes', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Room Type'), ['controller' => 'Roomtypes', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Entertain Area'), ['controller' => 'Entertainarea', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Entertain Area'), ['controller' => 'Entertainarea', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Commandgroup'), ['controller' => 'Commandgroup', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Commandgroup'), ['controller' => 'Commandgroup', 'action' => 'add']) ?></li>
</ul>
</nav>
<div class="rooms form large-9 medium-8 columns content">
......@@ -37,6 +41,7 @@
echo $this->Form->control('psc_frozen');
echo $this->Form->control('psc_mod');
echo $this->Form->control('psc_restrict');
echo $this->Form->control('commandgroup._ids', ['options' => $commandgroup]);
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
......
......@@ -10,6 +10,10 @@
<li><?= $this->Html->link(__('New Room'), ['action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Room Type'), ['controller' => 'Roomtypes', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Room Type'), ['controller' => 'Roomtypes', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Entertain Area'), ['controller' => 'Entertainarea', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Entertain Area'), ['controller' => 'Entertainarea', 'action' => 'add']) ?></li>
<li><?= $this->Html->link(__('List Commandgroup'), ['controller' => 'Commandgroup', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New Commandgroup'), ['controller' => 'Commandgroup', 'action' => 'add']) ?></li>
</ul>
</nav>
<div class="rooms index large-9 medium-8 columns content">
......
......@@ -13,6 +13,10 @@
<li><?= $this->Html->link(__('New Room'), ['action' => 'add']) ?> </li>
<li><?= $this->Html->link(__('List Room Type'), ['controller' => 'Roomtypes', 'action' => 'index']) ?> </li>
<li><?= $this->Html->link(__('New Room Type'), ['controller' => 'Roomtypes', 'action' => 'add']) ?> </li>
<li><?= $this->Html->link(__('List Entertain Area'), ['controller' => 'Entertainarea', 'action' => 'index']) ?> </li>
<li><?= $this->Html->link(__('New Entertain Area'), ['controller' => 'Entertainarea', 'action' => 'add']) ?> </li>
<li><?= $this->Html->link(__('List Commandgroup'), ['controller' => 'Commandgroup', 'action' => 'index']) ?> </li>
<li><?= $this->Html->link(__('New Commandgroup'), ['controller' => 'Commandgroup', 'action' => 'add']) ?> </li>
</ul>
</nav>
<div class="rooms view large-9 medium-8 columns content">
......@@ -79,4 +83,116 @@
<h4><?= __('FloorplanInfo') ?></h4>
<?= $this->Text->autoParagraph(h($room->FloorplanInfo)); ?>
</div>
<div class="related">
<h4><?= __('Related Commandgroup') ?></h4>
<?php if (!empty($room->commandgroup)): ?>
<table cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><?= __('PK CommandGroup') ?></th>
<th scope="col"><?= __('FK Array') ?></th>
<th scope="col"><?= __('FK Installation') ?></th>
<th scope="col"><?= __('Description') ?></th>
<th scope="col"><?= __('Hint') ?></th>
<th scope="col"><?= __('CanTurnOff') ?></th>
<th scope="col"><?= __('AlwaysShow') ?></th>
<th scope="col"><?= __('CanBeHidden') ?></th>
<th scope="col"><?= __('FK Criteria Orbiter') ?></th>
<th scope="col"><?= __('FK DesignObj') ?></th>
<th scope="col"><?= __('FK Template') ?></th>
<th scope="col"><?= __('AltID') ?></th>
<th scope="col"><?= __('FK Icon') ?></th>
<th scope="col"><?= __('AutoGeneratedDate') ?></th>
<th scope="col"><?= __('Disabled') ?></th>
<th scope="col"><?= __('TemplateParm1') ?></th>
<th scope="col"><?= __('TemplateParm2') ?></th>
<th scope="col"><?= __('FK Text') ?></th>
<th scope="col"><?= __('Psc Id') ?></th>
<th scope="col"><?= __('Psc Batch') ?></th>
<th scope="col"><?= __('Psc User') ?></th>
<th scope="col"><?= __('Psc Frozen') ?></th>
<th scope="col"><?= __('Psc Mod') ?></th>
<th scope="col"><?= __('Psc Restrict') ?></th>
<th scope="col" class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($room->commandgroup as $commandgroup): ?>
<tr>
<td><?= h($commandgroup->PK_CommandGroup) ?></td>
<td><?= h($commandgroup->FK_Array) ?></td>
<td><?= h($commandgroup->FK_Installation) ?></td>
<td><?= h($commandgroup->Description) ?></td>
<td><?= h($commandgroup->Hint) ?></td>
<td><?= h($commandgroup->CanTurnOff) ?></td>
<td><?= h($commandgroup->AlwaysShow) ?></td>
<td><?= h($commandgroup->CanBeHidden) ?></td>
<td><?= h($commandgroup->FK_Criteria_Orbiter) ?></td>
<td><?= h($commandgroup->FK_DesignObj) ?></td>
<td><?= h($commandgroup->FK_Template) ?></td>
<td><?= h($commandgroup->AltID) ?></td>
<td><?= h($commandgroup->FK_Icon) ?></td>
<td><?= h($commandgroup->AutoGeneratedDate) ?></td>
<td><?= h($commandgroup->Disabled) ?></td>
<td><?= h($commandgroup->TemplateParm1) ?></td>
<td><?= h($commandgroup->TemplateParm2) ?></td>
<td><?= h($commandgroup->FK_Text) ?></td>
<td><?= h($commandgroup->psc_id) ?></td>
<td><?= h($commandgroup->psc_batch) ?></td>
<td><?= h($commandgroup->psc_user) ?></td>
<td><?= h($commandgroup->psc_frozen) ?></td>
<td><?= h($commandgroup->psc_mod) ?></td>
<td><?= h($commandgroup->psc_restrict) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Commandgroup', 'action' => 'view', $commandgroup->PK_CommandGroup]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => 'Commandgroup', 'action' => 'edit', $commandgroup->PK_CommandGroup]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => 'Commandgroup', 'action' => 'delete', $commandgroup->PK_CommandGroup], ['confirm' => __('Are you sure you want to delete # {0}?', $commandgroup->PK_CommandGroup)]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
<div class="related">
<h4><?= __('Related Entertainarea') ?></h4>
<?php if (!empty($room->entertain_area)): ?>
<table cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><?= __('PK EntertainArea') ?></th>
<th scope="col"><?= __('FK Room') ?></th>
<th scope="col"><?= __('Only1Stream') ?></th>
<th scope="col"><?= __('Description') ?></th>
<th scope="col"><?= __('Private') ?></th>
<th scope="col"><?= __('FK FloorplanObjectType') ?></th>
<th scope="col"><?= __('FloorplanInfo') ?></th>
<th scope="col"><?= __('Psc Id') ?></th>
<th scope="col"><?= __('Psc Batch') ?></th>
<th scope="col"><?= __('Psc User') ?></th>
<th scope="col"><?= __('Psc Frozen') ?></th>
<th scope="col"><?= __('Psc Mod') ?></th>
<th scope="col"><?= __('Psc Restrict') ?></th>
<th scope="col" class="actions"><?= __('Actions') ?></th>
</tr>
<?php foreach ($room->entertain_area as $entertainArea): ?>
<tr>
<td><?= h($entertainArea->PK_EntertainArea) ?></td>
<td><?= h($entertainArea->FK_Room) ?></td>
<td><?= h($entertainArea->Only1Stream) ?></td>
<td><?= h($entertainArea->Description) ?></td>
<td><?= h($entertainArea->Private) ?></td>
<td><?= h($entertainArea->FK_FloorplanObjectType) ?></td>
<td><?= h($entertainArea->FloorplanInfo) ?></td>
<td><?= h($entertainArea->psc_id) ?></td>
<td><?= h($entertainArea->psc_batch) ?></td>
<td><?= h($entertainArea->psc_user) ?></td>
<td><?= h($entertainArea->psc_frozen) ?></td>
<td><?= h($entertainArea->psc_mod) ?></td>
<td><?= h($entertainArea->psc_restrict) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Entertainarea', 'action' => 'view', $entertainArea->PK_EntertainArea]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => 'Entertainarea', 'action' => 'edit', $entertainArea->PK_EntertainArea]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => 'Entertainarea', 'action' => 'delete', $entertainArea->PK_EntertainArea], ['confirm' => __('Are you sure you want to delete # {0}?', $entertainArea->PK_EntertainArea)]) ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment