<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <HTML>
    <HEAD>
      <TITLE>Presentation page for Controlling a UPnP Television</TITLE>
    </HEAD>

    <BODY>

      <H3><P ID=FName>Device Name</P></H3>


      <H3>TvDevice Control State Table</H3>
      <TABLE BGCOLOR='#D6D7DE' BORDER=0 VALIGN=top ALIGN=left CELLPADDING=1 CELLSPACING=3>
        <TR>
          <TD BGCOLOR='#000000' VALIGN=center ALIGN=center WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Variable</FONT></B></TD>
          <TD VALIGN=middle ALIGN=left BGCOLOR='#000000' WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Value</FONT></B></TD>
          <TD VALIGN=middle ALIGN=left BGCOLOR='#000000' WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Actions</FONT></B></TD>
        </TR>
        <TR>
          <TD  BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Power</TD>
          <TD  BGCOLOR="#FFFFFF" valign="top"><P ID=Power></P></TD>
          <TD  BGCOLOR="#FFFFFF" valign="top">
		&nbsp;&nbsp;
		<INPUT type="button" onclick="SetPowerOn()"      value=" On   ">
	        &nbsp;&nbsp;
		<INPUT type="button" onclick="SetPowerOff()"     value=" Off  ">
		&nbsp;&nbsp;
          </TD>
        </TR>
        <TR>
          <TD  BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Channel</TD>
          <TD  BGCOLOR="#FFFFFF" valign="top"><P ID=Channel></P></TD>
          <TD  BGCOLOR="#FFFFFF" valign="top">
		&nbsp;&nbsp;
		<INPUT type="button" onclick="IncreaseChannel()"     value=" Up   ">
		&nbsp;&nbsp;
	        <INPUT type="button" onclick="DecreaseChannel()"     value=" Down ">
		&nbsp;&nbsp;
          </TD>
        </TR>
        <TR>
          <TD  BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Volume</TD>
          <TD  BGCOLOR="#FFFFFF" valign="top"><P ID=Volume></P></TD>
          <TD  BGCOLOR="#FFFFFF" valign="top">
		&nbsp;&nbsp;
		<INPUT type="button" onclick="IncreaseVolume()"     value=" Up   ">
		&nbsp;&nbsp;
	        <INPUT type="button" onclick="DecreaseVolume()"     value=" Down ">
		&nbsp;&nbsp;
          </TD>
        </TR>
      </TABLE>


      <BR>
      <BR>
      <BR>
      <BR>
      <BR>
      <BR>
      <BR>
      <BR>
      <BR>

      <H3>TvDevice Picture State Table</H3>
      <TABLE BGCOLOR='#D6D7DE' BORDER=0 VALIGN=top ALIGN=left CELLPADDING=1 CELLSPACING=3>
        <TR>
          <TD BGCOLOR='#000000' VALIGN=center ALIGN=center WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Variable</FONT></B></TD>
          <TD VALIGN=middle ALIGN=left BGCOLOR='#000000' WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Value</FONT></B></TD>
          <TD VALIGN=middle ALIGN=left BGCOLOR='#000000' WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Actions</FONT></B></TD>
        </TR>
        <TR>
          <TD  BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Color</TD>
          <TD  BGCOLOR="#FFFFFF" valign="top"><P ID=Color></P></TD>
          <TD  BGCOLOR="#FFFFFF" valign="top">
		&nbsp;&nbsp;
		<INPUT type="button" onclick="IncreaseColor()"     value=" Up   ">
		&nbsp;&nbsp;
	        <INPUT type="button" onclick="DecreaseColor()"     value=" Down ">
		&nbsp;&nbsp;
          </TD>
        </TR>
        <TR>
          <TD  BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Tint</TD>
          <TD  BGCOLOR="#FFFFFF" valign="top"><P ID=Tint></P></TD>
          <TD  BGCOLOR="#FFFFFF" valign="top">
		&nbsp;&nbsp;
		<INPUT type="button" onclick="IncreaseTint()"     value=" Up   ">
		&nbsp;&nbsp;
	        <INPUT type="button" onclick="DecreaseTint()"     value=" Down ">
		&nbsp;&nbsp;
          </TD>
        </TR>
        <TR>
          <TD  BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Contrast</TD>
          <TD  BGCOLOR="#FFFFFF" valign="top"><P ID=Contrast></P></TD>
          <TD  BGCOLOR="#FFFFFF" valign="top">
		&nbsp;&nbsp;
		<INPUT type="button" onclick="IncreaseContrast()"     value=" Up   ">
		&nbsp;&nbsp;
	        <INPUT type="button" onclick="DecreaseContrast()"     value=" Down ">
		&nbsp;&nbsp;
          </TD>
        </TR>
        <TR>
          <TD  BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Brightness</TD>
          <TD  BGCOLOR="#FFFFFF" valign="top"><P ID=Brightness></P></TD>
          <TD  BGCOLOR="#FFFFFF" valign="top">
		&nbsp;&nbsp;
		<INPUT type="button" onclick="IncreaseBrightness()"     value=" Up   ">
		&nbsp;&nbsp;
	        <INPUT type="button" onclick="DecreaseBrightness()"     value=" Down ">
		&nbsp;&nbsp;
          </TD>
        </TR>
      </TABLE>
<H3>&nbsp;</H3>

<SCRIPT language=VBScript>


' *********************************************************
' Event handler called when the UPnP device submits events
' *********************************************************



Sub eventHandler(callbackType, svcObj, varName, value)

'Dim output
'output = output & "varName " & varName & vbCrLf 
'output = output & "value " & value & vbCrLf
'output = output & "svcObj " & svcObj.Id & vbCrLf
'MsgBox output 

  If (callbackType = "VARIABLE_UPDATE") Then
    select case svcObj.Id
      case "urn:upnp-org:serviceId:tvcontrol1"
        select case varName
          Case "Power"      Power.innerText = value
          Case "Channel"    Channel.innerText = value
          Case "Volume"     Volume.innerText = value
        end select
      case "urn:upnp-org:serviceId:tvpicture1"
        select case varName
          Case "Color"      Color.innerText = value
          Case "Tint"       Tint.innerText = value
          Case "Contrast"   Contrast.innerText = value
          Case "Brightness" Brightness.innerText = value
        end select
      end select
    End If
End Sub



' **********************************************************
' Button action callbacks invoke actions
' **********************************************************

function SetPowerOn()
    Dim inArgs(0)
    Dim outArgs(0)
    TvControlService.InvokeAction "PowerOn", inArgs, outArgs
end function


function SetPowerOff()
    Dim inArgs(0)
    Dim outArgs(0)
    TvControlService.InvokeAction "PowerOff", inArgs, outArgs
end function

function IncreaseChannel()
    Dim inArgs(0)
    Dim outArgs(0)
    TvControlService.InvokeAction "IncreaseChannel", inArgs, outArgs
end function

function DecreaseChannel()
    Dim inArgs(0)
    Dim outArgs(0)
    TvControlService.InvokeAction "DecreaseChannel", inArgs, outArgs
end function

function IncreaseVolume()
    Dim inArgs(0)
    Dim outArgs(0)
    TvControlService.InvokeAction "IncreaseVolume", inArgs, outArgs
end function

function DecreaseVolume()
    Dim inArgs(0)
    Dim outArgs(0)
    TvControlService.InvokeAction "DecreaseVolume", inArgs, outArgs
end function

function IncreaseColor()
    Dim inArgs(0)
    Dim outArgs(0)
    TvPictureService.InvokeAction "IncreaseColor", inArgs, outArgs
end function

function DecreaseColor()
    Dim inArgs(0)
    Dim outArgs(0)
    TvPictureService.InvokeAction "DecreaseColor", inArgs, outArgs
end function

function IncreaseTint()
    Dim inArgs(0)
    Dim outArgs(0)
    TvPictureService.InvokeAction "IncreaseTint", inArgs, outArgs
end function

function DecreaseTint()
    Dim inArgs(0)
    Dim outArgs(0)
    TvPictureService.InvokeAction "DecreaseTint", inArgs, outArgs
end function

function IncreaseContrast()
    Dim inArgs(0)
    Dim outArgs(0)
    TvPictureService.InvokeAction "IncreaseContrast", inArgs, outArgs
end function

function DecreaseContrast()
    Dim inArgs(0)
    Dim outArgs(0)
    TvPictureService.InvokeAction "DecreaseContrast", inArgs, outArgs
end function

function IncreaseBrightness()
    Dim inArgs(0)
    Dim outArgs(0)
    TvPictureService.InvokeAction "IncreaseBrightness", inArgs, outArgs
end function

function DecreaseBrightness()
    Dim inArgs(0)
    Dim outArgs(0)
    TvPictureService.InvokeAction "DecreaseBrightness", inArgs, outArgs
end function




' ********************************************************
' Download the description document from the UPnP device
' ********************************************************
Dim TvDesc
Set TvDesc = CreateObject("UPnP.DescriptionDocument.1")
TvDesc.Load("tvdevicedesc.xml")


' ********************************************************
' Get the Root Device from the description document
' ********************************************************
Dim TvDevice
Set TvDevice = TvDesc.RootDevice


' ********************************************************
' Output some of the device properties to the user
' ********************************************************
Dim output
output = "Found: " & vbCrLf
output = output & "DisplayName: " & TvDevice.FriendlyName & vbCrLf 
output = output & "Type: " & TvDevice.Type & vbCrLf
output = output & "UDN: " & TvDevice.UniqueDeviceName & vbCrLf
MsgBox output 

FName.innerText =  TvDevice.FriendlyName


' ********************************************************
' Attach the event handler to the tv control service 
' ********************************************************
Dim TvControlService
set TvControlService=TvDevice.Services("urn:upnp-org:serviceId:tvcontrol1")
TvControlService.AddCallback GetRef("eventHandler")

' ********************************************************
' Attach the event handler to the tv picture service 
' ********************************************************
Dim TvPictureService
set TvPictureService=TvDevice.Services("urn:upnp-org:serviceId:tvpicture1")
TvPictureService.AddCallback GetRef("eventHandler")



</SCRIPT>
</BODY>
</HTML>





