<?php

require './lib/socket.class.php';
require './lib/socketClient.class.php';
$socket = new socketClient('127.0.0.1', 54321);
$packet = array('controller' => 'index', 'action' => 'index', 'subaction' => '', 'subaction_id' => '', 'time' => time(), 'ip' => $_SERVER['SERVER_ADDR']);
$response = $socket->send(json_encode($packet));
$socket->report();
//echo $response;
//echo '<pre>'.print_r($socket, true).'</pre>';
Exemplo n.º 2
0
<?php

require './socket.php';
require './socketClient.php';
$socket = new socketClient('179.156.26.52', 8001);
//$packet = array('Pablo'    => 'Muito VIADO',
//                );
//$response = $socket->send(json_encode($packet));
//
$packet1 = array('comando' => '0', 'sp' => true, 'pv' => true, 'mv' => true);
print_r($socket->send(json_encode($packet1)));
//$packet2 = array('OP' => '1',
//    'sensor' => '1',
//);
//$response .= $socket->send(json_encode($packet2));
//
//$packet3 = array('OP' => '2',
//    'tanque' => '2',
//    'altura' => '20',
//);
//$response .= $socket->send(json_encode($packet3));
//
//$packet4 = array('OP' => '0',
//    'tensao' => '8.0',
//);
//$response .= $socket->send(json_encode($packet4));
//print_r($conn->comandar("{'OP': '0', 'tensao':'2.3'}"));
//print_r($conn->comandar("{'OP': '1', 'sensor':'1'}"));
//print_r($conn->comandar("{'OP': '2', 'tanque':'2', 'altura':'20'}"));
//print_r($conn->comandar("{'OP': '0', 'tensao':'8.0'}"));
//print_r($conn->comandar("{'OP': '1', 'sensor':'2'}"));
Exemplo n.º 3
0
//        $packet = array(
//            'OP' => '2',
//            'tanque' => '' . $setTanque . '',
//            'altura' => '' . $setPoint . '',
//        );
//        $response = $socket->send(json_encode($packet));
//        $nivel = json_decode($response, true)['response'];
//        echo json_encode(floatVal($nivel));
//    }
//}
//
// --- Novo
// ---------------------------------------- LEITURA DOS DADOS
if (isset($_GET['leitura'])) {
    $packet = array('comando' => 0);
    echo $socket->send(json_encode($packet));
}
// ---------------------------------------- COMANDO NA PLANTA
if (isset($_GET['controle'])) {
    if (isset($_GET['malha'])) {
        //        if (isset($_GET['sinal'])) {
        //Dados do sinal
        $sinal_tipo = $_GET['sgntipo'];
        $amp_max = (double) $_GET['ampmax'];
        $amp_min = (double) $_GET['ampmin'];
        $periodo_max = (double) $_GET['periodomax'];
        $periodo_min = (double) $_GET['periodomin'];
        $offset = (double) $_GET['offset'];
        if ($_GET['malha'] === 'true') {
            //malha aberta
            $packet = array('comando' => 1, 'malha_aberta' => true, 'com_sinal' => true, 'sinal' => array('tipo' => $sinal_tipo, 'amp_max' => $amp_max, 'amp_min' => $amp_min, 'periodo_max' => $periodo_max, 'periodo_min' => $periodo_min, 'offset' => $offset));