Skip to content
Snippets Groups Projects
Commit ad81c7d5 authored by Antônio Augusto Fröhlich's avatar Antônio Augusto Fröhlich
Browse files

Cleaning up import

parent eb3e6cb7
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 539 deletions
<?php
namespace SmartData;
require_once( __DIR__ . '/Exception.php');
require_once( __DIR__ . '/Packable.php');
class Series extends Packable
{
public $version;
private $unit;
public $x;
public $y;
public $z;
public $r;
public $t0;
public $t1;
public static function fields() : array {
return array(
'version' => Unpack::VERSION,
'unit' => Unpack::UNIT,
'x' => Unpack::DIMENSION,
'y' => Unpack::DIMENSION,
'z' => Unpack::DIMENSION,
'r' => Unpack::DIMENSION,
't0' => Unpack::TIME,
't1' => Unpack::TIME
);
}
public function __construct($v, $u, $x,$y,$z, $r, $t0, $t1){
// Conditions for a valid series.
//TODO: Check the maximum value comparison
//if ((gmp_cmp(gmp_init($t0), gmp_init($t1)) > 0) or ($r < 0)){
if (($t0 > $t1) or ($t0 < 0) or ($t1 < 0) or ($r < 0)){
throw new Exception\BadRequestException("Invalid series");
}
$this->version = $v;
$this->unit = ($u instanceof Unit) ? $u : Unit::interpret($u);
//$this->unit = $u;
$this->x = $x;
$this->y = $y;
$this->z = $z;
$this->r = $r;
$this->t0 = $t0;
$this->t1 = $t1;
}
public function unit(){
return $this->unit;
}
public function contains_point($x, $y, $z) {
return ( sqrt(pow($this->x - $x, 2) + pow($this->y - $y, 2) + pow($this->z - $z, 2)) <= $this->r );
}
public function contains_time($time) {
return ( $this->t0 <= $time && $time <= $this->t1 );
}
public function __get($property){
if (property_exists($this, $property)) {
switch ($property) {
case 'unit':
if($this->unit instanceof Unit)
return $this->unit->cod;
else
return $this->unit;
default:
return $this->$property;
}
}
}
public function __toString() {
$string = "{";
$string .= "v={$this->version}, ";
$string .= "u={$this->unit}, ";
$string .= "x={$this->x}, ";
$string .= "y={$this->y}, ";
$string .= "z={$this->z}, ";
$string .= "r={$this->r}, ";
$string .= "t0={$this->t0}, ";
$string .= "t1={$this->t1}";
$string .= '}';
return $string;
}
}
\ No newline at end of file
<?php
namespace SmartData;
require_once( __DIR__ . '/Exception.php');
require_once( __DIR__ . '/Packable.php');
abstract class SmartData extends Packable
{
const STATIC_VERSION = "1.1";
const MOBILE_VERSION = "1.2";
public $version;
private $unit;
public $value;
public $error;
public $confidence;
public $x;
public $y;
public $z;
public $time;
public static function fields() : array {
return array(
'unit' => Unpack::UNIT,
'value' => Unpack::VALUE,
'error' => Unpack::BYTE,
'confidence' => Unpack::BYTE,
'x' => Unpack::DIMENSION,
'y' => Unpack::DIMENSION,
'z' => Unpack::DIMENSION,
'time' => Unpack::TIME,
'd' => Unpack::DIMENSION
);
}
public $gw;
public function __construct($u, $v, $e, $c, $x,$y,$z, $t, $d){
$this->unit = ($u instanceof Unit) ? $u : Unit::interpret($u);
$this->value = $v;
$this->error = $e;
$this->confidence = $c;
$this->x = $x;
$this->y = $y;
$this->z = $z;
$this->time = $t;
$this->d = $d;
if((Config::DEBUGGED[__CLASS__] ?? false) || Config::HYSTERICALLY_DEBUGGED)
Logger::debug(__CLASS__.": $this");
}
public function toArray(){
$json = array();
$json['timestamp'] = $this->time;
$json['value'] = $this->value;
$json['error'] = $this->error;
$json['confidence'] = $this->confidence;
$json['x'] = $this->x;
$json['y'] = $this->y;
$json['z'] = $this->z;
$json['d'] = $this->d;
return $json;
}
public function toJson(){
$json = json_encode($this->toArray());
$json = preg_replace('/\"timestamp\":\"/', "\"timestamp\":", $json);
$json = preg_replace('/\",\"value\":/', ",\"value\":", $json);
return $json;
}
public function unit(){
return $this->unit;
}
public function __get($property){
if (property_exists($this, $property)) {
switch ($property) {
case 'unit':
if($this->unit instanceof Unit)
return $this->unit->cod;
else
return $this->unit;
default:
return $this->$property;
}
}
}
public function __toString() {
$string = "u={$this->unit}, ";
$string .= "v={$this->value}, ";
$string .= "e={$this->error}, ";
$string .= "c={$this->confidence}, ";
$string .= "x={$this->x}, ";
$string .= "y={$this->y}, ";
$string .= "z={$this->z}, ";
$string .= "t={$this->time}, ";
$string .= "d={$this->d}";
$string .= '}';
return $string;
}
}
class StaticSmartData extends SmartData {
public function __construct($u, $v, $e, $c, $x,$y,$z, $t, $d) {
parent::__construct($u, $v, $e, $c, $x,$y,$z, $t, $d);
$this->version = SmartData::STATIC_VERSION;
}
public function __toString() {
return '{S, '.(string)parent::__toString();
}
}
class MobileSmartData extends SmartData
{
public $signature;
public function __construct($u, $v, $e, $c, $x,$y,$z, $t, $d, $signature=0) {
parent::__construct($u, $v, $e, $c, $x,$y,$z, $t, $d);
$this->signature = $signature;
$this->version = SmartData::MOBILE_VERSION;
}
public function __toString() {
return '{M, '.(string)parent::__toString();
}
}
\ No newline at end of file
<?php
namespace SmartData;
abstract class Unit
{
// Formats
// Bit 31 16 0
// +--+----------------------------------+-------------------------------------+
// Digital |0 | type | lenght |
// +--+----------------------------------+-------------------------------------+
// Bit 31 29 27 24 21 18 15 12 9 6 3 0
// +--+----+----+------+------+------+------+------+------+------+------+------+
// SI |1 |NUM |MOD |sr+4 |rad+4 |m+4 |kg+4 |s+4 |A+4 |K+4 |mol+4 |cd+4 |
// +--+----+----+------+------+------+------+------+------+------+------+------+
// Bits 1 2 2 3 3 3 3 3 3 3 3 3
// Valid values for field SI
public const DIGITAL = 0 << 31;
public const SI = 1 << 31;
// Valid values for field NUM
public const I32 = 0 << 29; // Value is an integral number stored in the 32 last significant bits of a 32-bit little-endian integer.
public const I64 = 1 << 29; // Value is an integral number stored in the 64 last significant bits of a 64-bit little-endian integer.
public const F32 = 2 << 29; // Value is a real number stored as an IEEE 754 binary32 little-endian floating point.
public const D64 = 3 << 29; // Value is a real number stored as an IEEE 754 binary64 little-endian double precision floating point.
public const NUM = self::D64; // AND mask to select NUM bits
// Valid values for field MOD
public const DIR = 0 << 27; // Unit is described by the product of SI base units raised to the powers recorded in the remaining fields.
public const DIV = 1 << 27; // Unit is U/U, where U is described by the product SI base units raised to the powers recorded in the remaining fields.
public const LOG = 2 << 27; // Unit is log_e(U), where U is described by the product of SI base units raised to the powers recorded in the remaining fields.
public const LOG_DIV = 3 << 27; // Unit is log_e(U/U), where U is described by the product of SI base units raised to the powers recorded in the remaining fields.
public const MOD = self::D64; // AND mask to select MOD bits
// Masks to select the SI units
public const SR = 7 << 24;
public const RAD = 7 << 21;
public const M = 7 << 18;
public const KG = 7 << 15;
public const S = 7 << 12;
public const A = 7 << 9;
public const K = 7 << 6;
public const MOL = 7 << 3;
public const CD = 7 << 0;
// Masks to digital fields
public const LENGHT = (0xFFFF);
public const TYPE = (self::LENGHT << 16);
public const SIZE = 4; // bytes
public function __construct($u){
$this->_unit = $u;
}
public static function interpret($u) {
switch ($u & (1 << 31)) {
case self::DIGITAL:
return new Digital_Unit($u);
break;
case self::SI:
return new SI_Unit($u);
break;
default:
throw new InvalidUnitException("Invalid Unit: ".$u);
}
return null;
}
public static function unpack($u) {
return self::interpret(unpack('V', $u)[1]);
}
public function is_digital() : bool {
return (($this->_unit & (1 << 31)) == self::DIGITAL);
}
protected $_unit;
}
// Typical SI Quantities
final class TypicalUnit extends Unit
{
// si | mod | sr | rad | m | kg | s | A | K | mol | cd
const Length = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+1)<<18 | (4+0)<<15 | (4+0)<<12 | (4+0)<<9 | (4+0)<<6 | (4+0)<<3 | (4+0);
const Mass = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+0)<<18 | (4+1)<<15 | (4+0)<<12 | (4+0)<<9 | (4+0)<<6 | (4+0)<<3 | (4+0);
const Time = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+0)<<18 | (4+0)<<15 | (4+1)<<12 | (4+0)<<9 | (4+0)<<6 | (4+0)<<3 | (4+0);
const Current = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+0)<<18 | (4+0)<<15 | (4+0)<<12 | (4+1)<<9 | (4+0)<<6 | (4+0)<<3 | (4+0);
const Electric_Current = Typical::Current;
const Temperature = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+0)<<18 | (4+0)<<15 | (4+0)<<12 | (4+0)<<9 | (4+1)<<6 | (4+0)<<3 | (4+0);
const Amount_of_Substance = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+0)<<18 | (4+0)<<15 | (4+0)<<12 | (4+0)<<9 | (4+0)<<6 | (4+1)<<3 | (4+0);
const Luminous_Intensity = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+0)<<18 | (4+0)<<15 | (4+0)<<12 | (4+0)<<9 | (4+0)<<6 | (4+0)<<3 | (4+1);
const Area = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+2)<<18 | (4+0)<<15 | (4+0)<<12 | (4+0)<<9 | (4+0)<<6 | (4+0)<<3 | (4+0);
const Volume = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+3)<<18 | (4+0)<<15 | (4+0)<<12 | (4+0)<<9 | (4+0)<<6 | (4+0)<<3 | (4+0);
const Speed = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+1)<<18 | (4+0)<<15 | (4-1)<<12 | (4+0)<<9 | (4+0)<<6 | (4+0)<<3 | (4+0);
const Velocity = Typical::Speed;
const Acceleration = 1<<31 | 0<<27 | (4+0)<<24 | (4+0)<<21 | (4+1)<<18 | (4+0)<<15 | (4-2)<<12 | (4+0)<<9 | (4+0)<<6 | (4+0)<<3 | (4+0);
}
class Digital_Unit extends Unit
{
public function __get($property) {
switch ($property) {
case 'cod':
return $this->_unit;
case 'type':
return (($this->_unit & self::TYPE) >> 16);
case 'lenght':
return ($this->_unit & self::LENGHT);
default:
return null;
}
}
public function __toString() {
return "{{$this->unit}, D, t={$this->type}, l={$this->lenght}}";
}
}
class SI_Unit extends Unit
{
public function __get($property) {
switch ($property) {
case 'cod':
return $this->_unit;
case 'num':
return (($this->_unit & self::NUM) >> 29);
case 'mod':
return (($this->_unit & self::MOD) >> 27);
case 'sr':
return (($this->_unit & self::SR) >> 24) - 4;
case 'rad':
return (($this->_unit & self::RAD) >> 21) - 4;
case 'm':
return (($this->_unit & self::M) >> 18) - 4;
case 'kg':
return (($this->_unit & self::KG) >> 15) - 4;
case 's':
return (($this->_unit & self::S) >> 12) - 4;
case 'a':
return (($this->_unit & self::A) >> 9) - 4;
case 'k':
return (($this->_unit & self::K) >> 6) - 4;
case 'mol':
return (($this->_unit & self::MOL) >> 3) - 4;
case 'cd':
return (($this->_unit & self::CD) >> 0) - 4;
default:
return null;
}
}
public function __toString() {
$string = "{{$this->cod}, SI, n={$this->num}, m={$this->mod}, ";
$string .= ($this->sr != 0) ? "sr^{$this->sr}" : '';
$string .= ($this->rad != 0) ? "rad^{$this->rad}" : '';
$string .= ($this->m != 0) ? "m^{$this->m}" : '';
$string .= ($this->kg != 0) ? "kg^{$this->kg}" : '';
$string .= ($this->s != 0) ? "s^{$this->s}" : '';
$string .= ($this->a != 0) ? "A^{$this->a}" : '';
$string .= ($this->k != 0) ? "K^{$this->k}" : '';
$string .= ($this->mol != 0) ? "mol^{$this->mol}" : '';
$string .= ($this->cd != 0) ? "cd^{$this->cd}" : '';
$string .= '}';
return $string;
}
}
\ No newline at end of file
Dear admin, a fatal error occurred on the IoT server.
[2018-09-22 02:17:34] File: /smartdata/bin/smartdata/Backend.php (108) Message: Uncaught Error: Undefined class constant 'DEFAULT_USERNAME' in /smartdata/bin/smartdata/Backend.php:108
Stack trace:
#0 /smartdata/bin/smartdata/SmartAPI.php(22): SmartData\Backend_Common->__construct(Object(SmartData\Credentials))
#1 /smartdata/api/get.php(17): SmartData\SmartAPI\get('{"series":{"ver...')
#2 {main}
thrown
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-19 01:06:45] File: /smartdata/bin/smartdata/Backend.php (114) Message: Uncaught Error: Call to private method SmartData\Deployed_Backend::_checkCertificate() from context 'SmartData\Backend_Common' in /smartdata/bin/smartdata/Backend.php:114
Stack trace:
#0 /smartdata/bin/smartdata/SmartAPI.php(59): SmartData\Backend_Common->__construct(Object(SmartData\Credentials))
#1 /smartdata/api/put.php(13): SmartData\SmartAPI\put('{"smartdata": [...')
#2 {main}
thrown
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-19 01:06:36] File: /smartdata/bin/smartdata/Backend.php (1183) Message: Uncaught TypeError: Argument 3 passed to SmartData\Deployed_Backend::_cassandraConnect() must be of the type string
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-19 04:00:02] File: /smartdata/bin/smartdata/Backend.php (143) Message: Uncaught SmartData\Exception\BadRequestException> /smartdata/bin/smartdata/Backend.php:143 > HTTP:{local} crt:{} crd:{cassandra@public
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-20 04:00:01] File: /smartdata/bin/smartdata/Backend.php (146) Message: Uncaught SmartData\Exception\BadRequestException> /smartdata/bin/smartdata/Backend.php:146 > HTTP:{local} crt:{} crd:{cassandra@public
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-22 10:40:48] File: /smartdata/bin/smartdata/Backend.php (148) Message: Uncaught SmartData\Exception\BadRequestException> /smartdata/bin/smartdata/Backend.php:148 > HTTP:{local} crt:{} crd:{cassandra@smartlisha
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-23 01:23:12] File: /smartdata/bin/smartdata/Backend.php (153) Message: Uncaught SmartData\Exception\BadRequestException> /smartdata/bin/smartdata/Backend.php:153 > Incorrect use of protocol and options {cassandra@
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-22 04:00:01] File: /smartdata/bin/smartdata/Backend.php (154) Message: Uncaught SmartData\Exception\BadRequestException> /smartdata/bin/smartdata/Backend.php:154 > HTTP:{local} crt:{} crd:{cassandra@public
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-10-23 01:19:57] File: /smartdata/bin/smartdata/Backend.php (1599) Message: Uncaught Error: Call to undefined function SmartData\_workflow() in /smartdata/bin/smartdata/Backend.php:1599
Stack trace:
#0 /smartdata/bin/smartdata/Backend.php(1327): SmartData\Backend_V1_1->_insertStaticSmartData(Object(SmartData\StaticSmartData))
#1 /smartdata/bin/smartdata/SmartAPI.php(94): SmartData\Backend_V1_1->insert(Object(SmartData\StaticSmartData))
#2 /smartdata/api/put.php(13): SmartData\SmartAPI\put('{"smartdata":[{...')
#3 {main}
thrown
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2019-10-14 04:10:40] File: /smartdata/bin/smartdata/Backend.php (190) Message: Uncaught TypeError: Argument 1 passed to SmartData\Backend_Common::_checkCertificate() must be of the type string
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-19 02:39:45] File: /smartdata/bin/smartdata/Backend.php (1942) Message: Uncaught Error: Call to a member function fetchAll() on null in /smartdata/bin/smartdata/Backend.php:1942
Stack trace:
#0 /smartdata/bin/smartdata/SmartAPI.php(28): SmartData\Development_Backend->query(Object(SmartData\Series)
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-19 02:48:58] File: /smartdata/bin/smartdata/Backend.php (1946) Message: Uncaught Error: Call to a member function fetchAll() on null in /smartdata/bin/smartdata/Backend.php:1946
Stack trace:
#0 /smartdata/bin/smartdata/SmartAPI.php(28): SmartData\Development_Backend->query(Object(SmartData\Series)
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-20 04:43:12] File: /smartdata/bin/smartdata/Backend.php (1961) Message: Uncaught Error: Call to undefined function SmartData\int() in /smartdata/bin/smartdata/Backend.php:1961
Stack trace:
#0 /smartdata/bin/smartdata/SmartAPI.php(26): SmartData\Backend_V2_0->query(Object(SmartData\Series)
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-22 10:52:03] File: /smartdata/bin/smartdata/Backend.php (198) Message: Uncaught Error: Class name must be a valid object or a string in /smartdata/bin/smartdata/Backend.php:198
Stack trace:
#0 /smartdata/bin/smartdata/Backend.php(128): SmartData\Backend_Common->_checkCertificate('A7B64D415BD3E97...'
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-19 03:05:10] File: /smartdata/bin/smartdata/Backend.php (2032) Message: Uncaught Error: Call to a member function nextPage() on null in /smartdata/bin/smartdata/Backend.php:2032
Stack trace:
#0 /smartdata/bin/smartdata/SmartAPI.php(28): SmartData\Development_Backend->query(Object(SmartData\Series)
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-19 03:06:14] File: /smartdata/bin/smartdata/Backend.php (2033) Message: Uncaught Error: Call to a member function nextPage() on null in /smartdata/bin/smartdata/Backend.php:2033
Stack trace:
#0 /smartdata/bin/smartdata/SmartAPI.php(28): SmartData\Development_Backend->query(Object(SmartData\Series)
Best Regards,
SV3
Dear admin, a fatal error occurred on the IoT server.
[2018-09-20 10:26:14] File: /smartdata/bin/smartdata/Backend.php (2061) Message: Uncaught Error: Class 'SmartData\Config_Common' not found in /smartdata/bin/smartdata/Backend.php:2061
Stack trace:
#0 /smartdata/bin/smartdata/SmartAPI.php(7): require_once()
#1 /smartdata/api/get.php(4): require_once('/smartdata/bin/...')
#2 {main}
thrown
Best Regards,
SV3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment