You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
316 lines
9.1 KiB
316 lines
9.1 KiB
<?php
|
|
|
|
function parseLibconfig_section( &$Array, &$LineID ){
|
|
$RetVal = array();
|
|
$TCount = count( $Array );
|
|
while( $TCount > $LineID ){
|
|
if( ( stripos( $Array[$LineID] , ':' ) !== false ) && ( stripos( $Array[$LineID] , '=' ) === false ) ){
|
|
$TArr = explode( ' ', trim( $Array[$LineID] ) );
|
|
$CS = $TArr[0];
|
|
} elseif( stripos( $Array[$LineID] , '{' ) !== false ){
|
|
$LineID++;
|
|
$RetVal[$CS] = parseLibconfig_section( $Array, $LineID );
|
|
} elseif( stripos( $Array[$LineID] , '}' ) !== false ){
|
|
break;
|
|
} else {
|
|
$TVrr = parse_ini_string( trim( $Array[$LineID] ) );
|
|
if( count( $TVrr ) ){
|
|
foreach( $TVrr as $Key => $Val ) $RetVal[$Key] = $Val;
|
|
};
|
|
};
|
|
$LineID++;
|
|
};
|
|
return $RetVal;
|
|
};
|
|
|
|
function parseLibconfig( $FName ){
|
|
$RetVal = array();
|
|
$Data = file( $FName );
|
|
$TCount = count( $Data );
|
|
$Index = 0;
|
|
if( $TCount > 0 )$RetVal = parseLibconfig_section( $Data, $Index );
|
|
return $RetVal;
|
|
};
|
|
|
|
function listVideoDevices(){
|
|
$Data=`ls /dev/video* -1`;
|
|
$RR = explode("\n", $Data );
|
|
foreach( $RR as $R ){
|
|
$CD = trim( $R );
|
|
if( $CD != '' ){
|
|
$CMD = "v4l2-ctl -d {$CD} -L";
|
|
$Data = `$CMD`;
|
|
echo"------------------------------------------------------------------------------------\n";
|
|
echo $Data;
|
|
};
|
|
};
|
|
};
|
|
|
|
//$LibConfig = parseLibconfig( '/srv/mastbaum/SingleIPI.conf' );
|
|
$LibConfig = parseLibconfig( '/home/samba/dev/MastBaum/Debug/SingleIPI.conf' );
|
|
|
|
function getDeviceIdByBusID( $bid ){
|
|
$CMD = "v4l2-ctl --list-devices";
|
|
$Data = `$CMD`;
|
|
$RR = explode("\n", $Data);
|
|
for( $index = 0; $index < count($RR); $index++ ){
|
|
if( stripos( $RR[$index], $bid )!== false ) {
|
|
$TArr = substr( $RR[$index+1], stripos( $RR[$index+1], 'video')+5);
|
|
return intval( trim( $TArr ));
|
|
};
|
|
};
|
|
return -1;
|
|
};
|
|
|
|
function getVideoSourcesCount(){
|
|
global $LibConfig;
|
|
$RetVal = 0;
|
|
if( count($LibConfig) ){
|
|
foreach( $LibConfig['KERNEL']['VIDEO_INPUTS'] as $VI ) $RetVal ++;
|
|
};
|
|
return $RetVal;
|
|
};
|
|
|
|
function getVideoSourceID( $id ){
|
|
global $LibConfig;
|
|
$RetVal = -1;
|
|
if( count( $LibConfig )){
|
|
$index = 0;
|
|
foreach( $LibConfig['KERNEL']['VIDEO_INPUTS'] as $VI ){
|
|
if( $index == $id ){
|
|
$RetVal = getDeviceIdByBusID($VI['VIDEO_INPUT_ID']);
|
|
break;
|
|
};
|
|
$index ++;
|
|
};
|
|
};
|
|
return $RetVal;
|
|
};
|
|
|
|
function getPictureWidth(){
|
|
global $LibConfig;
|
|
if( count($LibConfig) ){
|
|
$RetVal = 0;
|
|
foreach( $LibConfig['KERNEL']['VIDEO_INPUTS'] as $VI ){
|
|
$RetVal += $VI['VIDEO_INPUT_WIDTH'];
|
|
};
|
|
return $RetVal;
|
|
} else {
|
|
return 320;
|
|
};
|
|
};
|
|
|
|
function getPictureHeight(){
|
|
global $LibConfig;
|
|
if( count($LibConfig) ){
|
|
$RetVal = 0;
|
|
foreach( $LibConfig['KERNEL']['VIDEO_INPUTS'] as $VI ){
|
|
if( $RetVal < $VI['VIDEO_INPUT_HEIGHT'] ) $RetVal = $VI['VIDEO_INPUT_HEIGHT'];
|
|
};
|
|
return $RetVal+18;
|
|
} else {
|
|
return 320;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
function getDeviceCtrl( $id ){
|
|
$CMD = "v4l2-ctl -d /dev/video{$id} -L";
|
|
$Data = `$CMD`;
|
|
$RR = explode("\n", $Data);
|
|
$C_SECT = '';
|
|
$menu_flag = false;
|
|
$SUB_CAT = array();
|
|
$RetVal = array();
|
|
$C_MIN = 0;
|
|
$C_MAX = 0;
|
|
$C_DEF = 0;
|
|
$C_STEP = 0;
|
|
$C_VALUE = 0;
|
|
foreach( $RR as $R ){
|
|
if( stripos( $R, ':' ) === false ){
|
|
if( trim( $R ) != '' ){
|
|
$C_SECT = trim( $R );
|
|
$RetVal[] = array( 'type'=>'section', 'name'=>$C_SECT );
|
|
};
|
|
} elseif( stripos( $R, '(' ) !== false ){
|
|
$C1 = stripos( $R, '(' );
|
|
$C2 = stripos( $R, ')' );
|
|
$C3 = stripos( $R, ':' );
|
|
$SUB = $C3 < $C1;
|
|
if( !$SUB ){
|
|
if( $menu_flag ){
|
|
$RetVal[] = array( 'type'=>$C_TYPE, 'name'=>$C_READ, 'tag'=>$C_NAME, 'value'=>$C_VALUE, 'min'=>$C_MIN, 'max'=>$C_MAX, 'def'=>$C_DEF, 'step'=>$C_STEP, 'items'=>$SUB_CAT );
|
|
//Handle Prev Menu Items
|
|
$C_MIN = 0;
|
|
$C_MAX = 0;
|
|
$C_DEF = 0;
|
|
$C_STEP = 0;
|
|
$C_VALUE = 0;
|
|
$SUB_CAT = array();
|
|
$menu_flag = false;
|
|
};
|
|
$C_NAME = trim( substr( $R, 0, $C1 ) );
|
|
$C_READ = str_replace( '_', ' ', $C_NAME );
|
|
$C_TYPE = strtolower( substr( $R, $C1+1, ($C2 - $C1)-1 ) );
|
|
if( $C_TYPE == 'int' || $C_TYPE == 'menu' || $C_TYPE == 'intmenu' ){
|
|
if( $C_TYPE == 'menu' || $C_TYPE == 'intmenu' ){
|
|
$menu_flag = true;
|
|
};
|
|
$V = substr( $R, $C3 + 2 );
|
|
$PRM = explode( ' ', $V );
|
|
foreach( $PRM as $P ){
|
|
$TT = explode( '=', $P );
|
|
switch( $TT[0] ){
|
|
case 'min': $C_MIN = intval($TT[1]); break;
|
|
case 'max': $C_MAX = intval($TT[1]); break;
|
|
case 'step': $C_STEP = intval($TT[1]); break;
|
|
case 'default': $C_DEF = intval($TT[1]); break;
|
|
case 'value': $C_VALUE = intval($TT[1]); break;
|
|
};
|
|
};
|
|
};
|
|
if( !$menu_flag ){
|
|
// No new menu started - Adding plane value
|
|
$RetVal[] = array( 'type'=>$C_TYPE, 'name'=>$C_READ, 'tag'=>$C_NAME, 'value'=>$C_VALUE, 'min'=>$C_MIN, 'max'=>$C_MAX, 'def'=>$C_DEF, 'step'=>$C_STEP );
|
|
$C_MIN = 0;
|
|
$C_MAX = 0;
|
|
$C_DEF = 0;
|
|
$C_STEP = 0;
|
|
$C_VALUE = 0;
|
|
};
|
|
} else {
|
|
$T_NAME = trim( substr( $R, $C3+1 ) );
|
|
$T_VALUE = trim( substr( $R, 0, $C3 ) );
|
|
$SUB_CAT[$T_VALUE]=$T_NAME;
|
|
};
|
|
} else {
|
|
$C3 = stripos( $R, ':' );
|
|
$T_NAME = trim( substr( $R, $C3+1 ) );
|
|
$T_VALUE = trim( substr( $R, 0, $C3 ) );
|
|
$SUB_CAT[$T_VALUE]=$T_NAME;
|
|
};
|
|
};
|
|
return $RetVal;
|
|
};
|
|
|
|
function createExtJS_int_field( $AA, $id, $listeners = '' ){
|
|
$RetVal = array();
|
|
$RetVal['xtype'] = 'slider';
|
|
$RetVal['value'] = $AA['value'];
|
|
$RetVal['fieldLabel'] = $AA['name'];
|
|
$RetVal['name'] = $AA['tag'] . '#' . $id;
|
|
$RetVal['width'] = 160;
|
|
$RetVal['minValue'] = $AA['min'];
|
|
$RetVal['maxValue'] = $AA['max'];
|
|
if( $listeners == '' ){
|
|
return json_encode( $RetVal );
|
|
};
|
|
$TVal = json_encode( $RetVal );
|
|
$TTVal = substr( $TVal, 0, strlen( $TVal )-1 ) . ', listeners:{';
|
|
foreach( $listeners as $Key=>$Value ){
|
|
$TTVal .= $Key . ':' . $Value .',';
|
|
};
|
|
$TTVal .= 'scope: this}}';
|
|
return $TTVal;
|
|
};
|
|
|
|
function createExtJS_bool_field( $AA, $id, $listeners = '' ){
|
|
$RetVal = array();
|
|
$RetVal['xtype'] = 'checkbox';
|
|
$RetVal['value'] = $AA['value'];
|
|
$RetVal['fieldLabel'] = $AA['name'];
|
|
$RetVal['name'] = $AA['tag'] . '#' . $id;
|
|
if( intval($AA['value'])>0 ){
|
|
$RetVal['checked'] = true;
|
|
}else{
|
|
$RetVal['checked'] = false;
|
|
};
|
|
if( $listeners == '' ){
|
|
return json_encode( $RetVal );
|
|
};
|
|
$TVal = json_encode( $RetVal );
|
|
$TTVal = substr( $TVal, 0, strlen( $TVal )-1 ) . ', listeners:{';
|
|
foreach( $listeners as $Key=>$Value ){
|
|
$TTVal .= $Key . ':' . $Value .',';
|
|
};
|
|
$TTVal .= 'scope: this}}';
|
|
return $TTVal;
|
|
};
|
|
|
|
$GLOB_DSID = 0;
|
|
function isAssoc( array $arr ){
|
|
if (array() === $arr) return false;
|
|
return array_keys($arr) !== range(0, count($arr) - 1);
|
|
}
|
|
|
|
function createExtJS_menu_field( $AA, $id , $listeners = '' ){
|
|
global $GLOB_DSID;
|
|
$DS = array();
|
|
$DS['xtype']='arraystore';
|
|
$DS['id'] = 0;//$GLOB_DSID;
|
|
//$GLOB_DSID++;
|
|
$DS['fields'] = array('myID','displayText');
|
|
$DS['data'] = array();
|
|
if( isAssoc( $AA['items'] ) ){
|
|
foreach( $AA['items'] as $Key=>$Val ) $DS['data'][] = array( $Key, $Val );
|
|
} else {
|
|
$index = 0;
|
|
foreach( $AA['items'] as $A ){
|
|
$DS['data'][] = array($index, $A);
|
|
$index++;
|
|
};
|
|
};
|
|
$RetVal = array();
|
|
$RetVal['xtype'] = 'combo';
|
|
$RetVal['fieldLabel'] = $AA['name'];
|
|
$RetVal['name'] = $AA['tag'] . '#' . $id;
|
|
$RetVal['value'] = $AA['value'];
|
|
$RetVal['mode'] = 'local';
|
|
$RetVal['store'] = $DS;
|
|
$RetVal['valueField'] = 'myID';
|
|
$RetVal['displayField'] = 'displayText';
|
|
if( $listeners == '' ){
|
|
return json_encode( $RetVal );
|
|
};
|
|
$TVal = json_encode( $RetVal );
|
|
$TTVal = substr( $TVal, 0, strlen( $TVal )-1 ) . ', listeners:{';
|
|
foreach( $listeners as $Key=>$Value ){
|
|
$TTVal .= $Key . ':' . $Value .',';
|
|
};
|
|
$TTVal .= 'scope: this}}';
|
|
return $TTVal;
|
|
};
|
|
|
|
//https://il.iherb.com/pr/Cellucor-CLK-Stimulant-Free-Fat-Loss-Raspberry-Flavored-90-Softgels/85513?fbclid=IwAR0AuMjRf23-tac7QAzdWX1OgIhpSUbRlUMH24ih3v-Fzzc-AYMiqSKzPHs
|
|
|
|
function createExtJS_spacer_field( $AA ){
|
|
$RetVal = array();
|
|
$RetVal['xtype'] = 'spacer';
|
|
$RetVal['labelStyle'] = "font-weight: bold; font-color: yellow; background: #00ff00;";
|
|
$RetVal['fieldLabel'] = $AA['name'];
|
|
return json_encode( $RetVal );
|
|
};
|
|
|
|
|
|
function buildExtJSForm( $AA, $id ){
|
|
$RetVal = "{'xtype':'form', 'title': 'Video Source $id','plain': true,'frame':false,'items':[";
|
|
foreach( $AA as $A ){
|
|
switch( $A['type'] ){
|
|
case 'int': $RetVal .= createExtJS_int_field( $A, $id, array('change'=>'ChangeHandler') ). ','; break;
|
|
case 'bool': $RetVal .= createExtJS_bool_field( $A, $id, array('change'=>'ChangeHandler') ). ','; break;
|
|
case 'intmenu':
|
|
case 'menu': $RetVal .= createExtJS_menu_field( $A, $id, array('change'=>'ChangeHandler') ). ','; break;
|
|
case 'section': $RetVal .= createExtJS_spacer_field( $A ) . ','; break;
|
|
};
|
|
};
|
|
$RetVal .="{html:''}],'border':false,'autoScroll':true,'layout':'form','hideLabels':false,'labelWidth':250,'labelPad':8 }";
|
|
return $RetVal;
|
|
};
|
|
|
|
//var_dump( buildExtJSForm( getDeviceCtrl( 0 ), 0 ) );
|
|
|
|
//echo getDeviceIdByBusID('usb-3f980000.usb-1.2') . "\n\n";
|
|
|
|
?>
|