????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.57 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/appsrv.astacus.se/rock_backup/modbus_swegon/ |
Upload File : |
<?php
require 'vendor/autoload.php';
use ModbusTcpClient\Network\BinaryStreamConnection;
use ModbusTcpClient\Packet\ModbusFunction\ReadHoldingRegistersRequest;
use ModbusTcpClient\Packet\ModbusFunction\ReadHoldingRegistersResponse;
use ModbusTcpClient\Packet\ModbusFunction\ReadInputRegistersRequest;
use ModbusTcpClient\Packet\ResponseFactory;
use ModbusTcpClient\Utils\Endian;
$quantity = 1;
$input = 3;
$holdning = 4;
$outdoor_temp = getValue($connection, 73, $input);
$airsuplly = getValue($connection, 86, $input);
$exhaust = getValue($connection, 67, $input);
$SFP = getValue($connection, 62, $input);
$fan_speed_supply = getValue($connection, 36, $input);
$fan_speed_exhaust = getValue($connection, 37, $input);
$fan_consumption_supply = getValue($connection, 44, $input);
$fan_consumption_exhaust = getValue($connection, 45, $input);
$airflow_supply = getValue($connection, 3, $input);
$airflow_exhaust = getValue($connection, 5, $input);
$supply_borvarde = getValue($connection, 4, $input)/1000;
$exhaust_borvarde = getValue($connection, 6, $input)/1000;
$stack = array(($airsuplly/100), ($exhaust/100),($SFP/10),($fan_speed_supply/100),($fan_speed_exhaust/100),($fan_consumption_supply/100),($airflow_supply/1000),($airflow_exhaust/1000),($outdoor_temp/100));
foreach ($stack as $value) {
echo($value."#");
}
function getValue($connection, $startAddress, $register){
$ip = '192.168.1.188';
$port = 502;
$unitId = 1;
$endianess = 5;
$quantity = 1;
Endian::$defaultEndian = $endianess;
$connection = BinaryStreamConnection::getBuilder()
->setPort($port)
->setHost($ip)
->setConnectTimeoutSec(1.5) // timeout when establishing connection to the server
->setWriteTimeoutSec(0.5) // timeout when writing/sending packet to the server
->setReadTimeoutSec(1.0) // timeout when waiting response from server
->build();
if ($register == 3) {
$packet = new ReadInputRegistersRequest($startAddress, $quantity, $unitId);
} else {
$packet = new ReadHoldingRegistersRequest($startAddress, $quantity, $unitId);
}
try {
$binaryData = $connection->connect()->sendAndReceive($packet);
$response = ResponseFactory::parseResponseOrThrow($binaryData)->withStartAddress($startAddress);
foreach ($response as $address => $word) {
return $word->getInt16();
}
} catch (Exception $exception) {
$result = null;
} finally {
$connection->close();
}
}
?>