src.dualinventive.com/dinet/libdi-php/tests/constants.php

214 lines
4.7 KiB
PHP

<?php
/* Display all registered constants mapped from libdi */
$constants = get_defined_constants(true);
print("-- enum di_errno" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DNE_") !== false || strrpos($k, "DNOK") !== false)
echo("\t$k = $v" . PHP_EOL);
}
/*
* DI device
*/
print("-- enum di_device_battery_state" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_DEVICE_BATTERY_STATE_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_device_cloudlight_state" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_DEVICE_CLOUDLIGHT_STATE_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_device_charger_state" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_DEVICE_CHARGER_STATE_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
/*
* DI RPC
*/
print("-- enum di_rpc_types" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_TYPE_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_rpc_uid_sensor" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_UID_SENSOR_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_rpc_uid_config" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_UID_CONFIG_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_rpc_uid_notify" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_UID_NOTIFY_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- device type labels" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "_DEVICE_TYPE_LABEL") !== false) {
echo("\t$k = \"$v\"" . PHP_EOL);
}
}
/*
* DI RPC DUU
*/
print("-- enum di_rpc_uid_duu_sensor" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_UID_DUU_SENSOR_") !== false) {
$v = dechex($v);
echo("\t$k = $v" . PHP_EOL);
}
}
print("-- enum di_rpc_uid_duu_notify" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_UID_DUU_NOTIFY_") !== false) {
$v = dechex($v);
echo("\t$k = $v" . PHP_EOL);
}
}
print("-- enum di_rpc_uid_duu_action" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_UID_DUU_ACTION_") !== false) {
echo("\t$k = $v" . PHP_EOL);
}
}
/*
* DI RPC ZKL (and RC)
*/
print("-- enum di_rpc_uid_zkl_sensor" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_UID_ZKL_SENSOR_") !== false) {
echo("\t$k = $v" . PHP_EOL);
}
}
print("-- enum di_rpc_uid_zklrc_sensor" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_UID_ZKLRC_SENSOR_") !== false) {
echo("\t$k = $v" . PHP_EOL);
}
}
print("-- enum di_rpc_zklrc_keyswitch_state" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_RPC_ZKLRC_KEYSWITCH_STATE_") !== false) {
echo("\t$k = $v" . PHP_EOL);
}
}
/*
* DI CAN
*/
print("-- enum di_can_nodeids" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_CAN_NODEID_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_can_msgtype" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_CAN_MSGTYPE_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_can_transfertype" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_CAN_TRANSFERTYPE_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_can_ptypes" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_CAN_PTYPE_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
/*
* DI CAN raw
*/
print("-- enum di_can_raw_dtypes" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_CAN_RAW_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print("-- enum di_can_raw_connection_state" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_CAN_RAW_CONNECTION_STATE_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
/*
* DI CAN net
*/
print("-- enum di_can_net_dtypes" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_CAN_NET_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
/*
* DI Log
*/
print("-- DI_LOG_*" . PHP_EOL);
foreach($constants['di'] as $k => $v) {
if (strrpos($k, "DI_LOG_") !== false) {
$v = dechex($v);
echo("\t$k = 0x$v" . PHP_EOL);
}
}
print ("-- All constants defined by di module" . PHP_EOL);
print_r ($constants["di"]);