Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devicelist.cgi extended by device_id #79

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 108 additions & 100 deletions xmlapi/devicelist.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if {[info exists sid] && [check_session $sid]} {

set show_internal 0
set show_remote 0
set device_id 0
catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
Expand All @@ -21,13 +22,18 @@ if {[info exists sid] && [check_session $sid]} {
set show_remote $val
continue
}
if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
set device_id $val
continue
}
}
}

array set res [rega_script {

integer show_internal = "} $show_internal {";
integer show_remote = "} $show_remote {";
integer device_id = "} $device_id {";

integer DIR_SENDER = 1;
integer DIR_RECEIVER = 2;
Expand All @@ -39,116 +45,118 @@ if {[info exists sid] && [check_session $sid]} {
string sDPId;
foreach (sDevId, root.Devices().EnumUsedIDs())
{
object oDevice = dom.GetObject(sDevId);
integer iDevInterfaceId = oDevice.Interface();
object oDeviceInterface = dom.GetObject(iDevInterfaceId);

boolean bDevReady = oDevice.ReadyConfig();
boolean isRemote = ( ("HMW-RCV-50" == oDevice.HssType()) || ("HM-RCV-50" == oDevice.HssType()) || ("HmIP-RCV-50" == oDevice.HssType()) );

if( (oDeviceInterface) && (true == bDevReady) && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
{
string sDevInterface = oDeviceInterface.Name();
string sDevType = oDevice.HssType();

Write("<device");
Write(" name='");WriteXML( oDevice.Name() );Write("'");
Write(" address='");WriteXML( oDevice.Address() );Write("'");
Write(" ise_id='" # sDevId # "'");
Write(" interface='" # sDevInterface # "'");
Write(" device_type='");WriteXML(sDevType);Write("'");
Write(" ready_config='" # bDevReady # "'");
Write(">");

foreach(sChnId, oDevice.Channels())
{
object oChannel = dom.GetObject(sChnId);

boolean show = false;
if( (device_id == 0) || (device_id == sDevId) ){
object oDevice = dom.GetObject(sDevId);
integer iDevInterfaceId = oDevice.Interface();
object oDeviceInterface = dom.GetObject(iDevInterfaceId);

if (false == oChannel.Internal() ) {
show = true;
}
boolean bDevReady = oDevice.ReadyConfig();
boolean isRemote = ( ("HMW-RCV-50" == oDevice.HssType()) || ("HM-RCV-50" == oDevice.HssType()) || ("HmIP-RCV-50" == oDevice.HssType()) );

if ( show_internal == 1){
show = true;
}
if( (oDeviceInterface) && (true == bDevReady) && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
{
string sDevInterface = oDeviceInterface.Name();
string sDevType = oDevice.HssType();

Write("<device");
Write(" name='");WriteXML( oDevice.Name() );Write("'");
Write(" address='");WriteXML( oDevice.Address() );Write("'");
Write(" ise_id='" # sDevId # "'");
Write(" interface='" # sDevInterface # "'");
Write(" device_type='");WriteXML(sDevType);Write("'");
Write(" ready_config='" # bDevReady # "'");
Write(">");

foreach(sChnId, oDevice.Channels())
{
object oChannel = dom.GetObject(sChnId);

boolean show = false;

if (false == oChannel.Internal() ) {
show = true;
}

if (show == true){
integer iChnDir = oChannel.ChnDirection();
string sChnDir = "UNKNOWN";
if (DIR_SENDER == iChnDir) { sChnDir = "SENDER"; }
if (DIR_RECEIVER == iChnDir) { sChnDir = "RECEIVER"; }
string sChnPartnerId = oChannel.ChnGroupPartnerId();
if (PARTNER_INVALID == sChnPartnerId) { sChnPartnerId = ""; }
boolean bChnAESAvailable = false;
if (0 != oChannel.ChnAESOperation()) { bChnAESAvailable = true; }
string sChnMode = "DEFAULT";
if (true == oChannel.ChnAESActive()) { sChnMode = "AES"; }

! boolean bChnReady = oChannel.ReadyConfig();
! integer iChnLinkCount = oChannel.ChnLinkCount();
! integer iChnProgramCount = oChannel.DPUsageCount();
! if (ID_ERROR == iChnProgramCount) { iChnProgramCount = 0; }
! boolean bChnVirtual = false;
! if (TYPE_VIRTUAL == sChnType) { bChnVirtual = true; }
! boolean bChnReadable = false;
! boolean bChnWritable = false;
! boolean bChnEventable = false;
! foreach (sDPId, oChannel.DPs())
! {
! object oDP = dom.GetObject(sDPId);
! if (false == oDP.Internal())
! {
! integer iDPOperations = oDP.Operations();
! if (OPERATION_READ & iDPOperations) { bChnReadable = true; }
! if (OPERATION_WRITE & iDPOperations) { bChnWritable = true; }
! if (OPERATION_EVENT & iDPOperations) { bChnEventable = true; }
! }
! }
!
Write("<channel name='");WriteXML( oChannel.Name() );Write("'");
Write(" type='");WriteXML( oChannel.ChannelType() );Write("'");
Write(" address='");WriteXML( oChannel.Address() );Write("'");
Write(" ise_id='" # sChnId # "'");
Write(" direction='" # sChnDir # "'");
Write(" parent_device='" # oChannel.Device() # "'");
Write(" index='" # oChannel.ChnNumber() # "'");
Write(" group_partner='" # sChnPartnerId # "'");
Write(" aes_available='" # bChnAESAvailable # "'");
Write(" transmission_mode='" # sChnMode # "'");
! Write(" archive='" # oChannel.ChnArchive() # "'");

if (false == oChannel.Internal()) {
Write(" visible='" # oChannel.Visible() # "'");
} else {
Write(" visible=''");
if ( show_internal == 1){
show = true;
}

Write(" ready_config='" # oChannel.ReadyConfig() # "'");
! Write(" link_count='" # iChnLinkCount # "'");
! Write(" program_count='" # iChnProgramCount # "'");
! Write(" virtual='" # bChnVirtual # "'");
! Write(" readable='" # bChnReadable # "'");
! Write(" writable='" # bChnWritable # "'");
! Write(" eventable='" # bChnEventable # "'");

if (false == oChannel.Internal()) {
Write(" operate='");
if( oChannel.UserAccessRights(iulOtherThanAdmin) == iarFullAccess ) {
Write("true");
if (show == true){
integer iChnDir = oChannel.ChnDirection();
string sChnDir = "UNKNOWN";
if (DIR_SENDER == iChnDir) { sChnDir = "SENDER"; }
if (DIR_RECEIVER == iChnDir) { sChnDir = "RECEIVER"; }
string sChnPartnerId = oChannel.ChnGroupPartnerId();
if (PARTNER_INVALID == sChnPartnerId) { sChnPartnerId = ""; }
boolean bChnAESAvailable = false;
if (0 != oChannel.ChnAESOperation()) { bChnAESAvailable = true; }
string sChnMode = "DEFAULT";
if (true == oChannel.ChnAESActive()) { sChnMode = "AES"; }

! boolean bChnReady = oChannel.ReadyConfig();
! integer iChnLinkCount = oChannel.ChnLinkCount();
! integer iChnProgramCount = oChannel.DPUsageCount();
! if (ID_ERROR == iChnProgramCount) { iChnProgramCount = 0; }
! boolean bChnVirtual = false;
! if (TYPE_VIRTUAL == sChnType) { bChnVirtual = true; }
! boolean bChnReadable = false;
! boolean bChnWritable = false;
! boolean bChnEventable = false;
! foreach (sDPId, oChannel.DPs())
! {
! object oDP = dom.GetObject(sDPId);
! if (false == oDP.Internal())
! {
! integer iDPOperations = oDP.Operations();
! if (OPERATION_READ & iDPOperations) { bChnReadable = true; }
! if (OPERATION_WRITE & iDPOperations) { bChnWritable = true; }
! if (OPERATION_EVENT & iDPOperations) { bChnEventable = true; }
! }
! }
!
Write("<channel name='");WriteXML( oChannel.Name() );Write("'");
Write(" type='");WriteXML( oChannel.ChannelType() );Write("'");
Write(" address='");WriteXML( oChannel.Address() );Write("'");
Write(" ise_id='" # sChnId # "'");
Write(" direction='" # sChnDir # "'");
Write(" parent_device='" # oChannel.Device() # "'");
Write(" index='" # oChannel.ChnNumber() # "'");
Write(" group_partner='" # sChnPartnerId # "'");
Write(" aes_available='" # bChnAESAvailable # "'");
Write(" transmission_mode='" # sChnMode # "'");
! Write(" archive='" # oChannel.ChnArchive() # "'");

if (false == oChannel.Internal()) {
Write(" visible='" # oChannel.Visible() # "'");
} else {
Write("false");
Write(" visible=''");
}

Write(" ready_config='" # oChannel.ReadyConfig() # "'");
! Write(" link_count='" # iChnLinkCount # "'");
! Write(" program_count='" # iChnProgramCount # "'");
! Write(" virtual='" # bChnVirtual # "'");
! Write(" readable='" # bChnReadable # "'");
! Write(" writable='" # bChnWritable # "'");
! Write(" eventable='" # bChnEventable # "'");

if (false == oChannel.Internal()) {
Write(" operate='");
if( oChannel.UserAccessRights(iulOtherThanAdmin) == iarFullAccess ) {
Write("true");
} else {
Write("false");
}
} else {
Write(" operate='");
}
} else {
Write(" operate='");
}

Write("' />");
Write("' />");
}
}
}

Write("</device>");
Write("</device>");
}
}
}
}]
Expand Down
1 change: 1 addition & 0 deletions xmlapi/index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if {[info exists sid] && [check_session $sid]} {
<tr><td><a href=./checkuptodate.cgi?sid=$sid>checkuptodate.cgi</a></td><td>????</td></tr>
<tr><td><a href=./devicelist.cgi?sid=$sid>devicelist.cgi</a></td><td><b>Lists all devices with channels. Contain names, serial number, device type and ids.</b><br/>
<i>sid=string</i> - security access token id<br/>
<i>device_id=int</i> - returns values of specified device (e.g. "1234") (optional)<br/>
<i>show_internal=0/1</i> - adds internal channels also (default=0)<br/>
<i>show_remote=0/1</i> - adds output of virtual remote channels (default=0)
</td></tr>
Expand Down