Announcement

Collapse
No announcement yet.

HS2 web server and ActiveX objects?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    HS2 web server and ActiveX objects?

    I've got a third-party ActiveX object that I want to use from within an ASP page running under the HS2 web server. Is this possible, and if so, how do I set it up? I have the object registered on the machine and it is being referenced ok from VBScript (no ASP page errors), but it doesn't seem to be working (supposed to write an image file). I've checked permissions and I see no errors anywhere...
    |
    | - Gordon

    "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
    HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

    #2
    Oh, I'm stupid tonight... I had a typo in the path to write the file. It works fine!
    |
    | - Gordon

    "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
    HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

    Comment


      #3
      Check that again...

      I'm trying to use an ActiveX object (DynImage.dll) that creates graphic images (PNG files) and writes them to disk. It works fine under the HS2 web server when using it in an ASP page.

      However, it does not work (as in it does not write the file to disk) in an ASPX page.

      Is there a way to make this work in an ASPX page? Or if this is the problem, is there a way to force this object to use VB code instead of .NET in an ASPX page?
      |
      | - Gordon

      "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
      HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

      Comment


        #4
        Gordon,

        Is it possible to post the bit of code in question as it is very difficult to see what you are doing.

        Also, is there any reason you are wanting to use ASPX over ASP. I have been in communication with Rich and he has confirmed now that ASPX will be slower than ASP.

        Here is a snippet from his email:

        The problem is, communications between applications is slower with .NET (due to remoting and application domains), than it is with COM. I don't know why Microsoft would create a new technology and make it slower, but they did.
        Also see this post: http://board.homeseer.com/showthread.php?t=112477
        Jon

        Comment


          #5
          Hi, Jon00, sure.

          What I'm doing is trying to retrofit UltraView2 with the ability to take the DeviceString of a device and create a .PNG image of it for use in UltraView2 on the fly. UltraView2 is using an ASPX file to do the work today - I just wanted to try to have some inline code to use the DynImage ActiveX object.

          This is UltraJones' code in a file called ultraveiw2_common.txt, which is included in the basic ultraview2.aspx page with this line (less the opening sign):

          Code:
          script language="VBScript" src="/ultraview2/ultraview2_common.txt"></script><SCRIPT language=VBScript src="/ultraview2/ultraview2_common.txt"></SCRIPT>

          Here's the entire function code - the Case "Temps" is my section. The DynImage ActiveX object works with an ASP page, not in an ASPX page (spaces after the & to show the code in places):


          Code:
           Function ProcessDevice(ByVal strDevType, ByVal strDevStr, ByVal iDevStatus, ByVal iDevDim)
           
          On Error Resume Next
           
          Dim arrStatus(1)
          Dim oDynImage
          Dim Dimage
           
          Const DEVSTR = 0
          Const ICON = 1
           
          '
          ' Stip out html for tooltip display and set default icon value
          '
          arrStatus(DEVSTR) = Strip(strDevStr, "<[^>]*>", "")
          arrStatus(ICON) = "unknown.gif"
           
          Select Case strDevType
          Case "RCS TX15B Thermostat", "RCS TX15B", "Temperature Probe"
          '
          ' Special handling for devices that contain the status in the device string
          '
          If arrStatus(DEVSTR) = "" Then
          	'
          	' Use unknown.gif
          	'
          	arrStatus(DEVSTR) = "Unknown"
          	arrStatus(ICON) = "unknown.gif"
          Else
          	'
          	' Attempt to convert device string to icon
          	'
          	arrStatus(ICON) = BuildIcon(arrStatus(DEVSTR))
          End If
           
           
          Case "Temps"
          if arrStatus(DEVSTR) = "" then
          	arrStatus(DEVSTR) = "Unknown"
          	arrStatus(ICON) = "unknown.gif"
          else
          	'Convert degree character to HTML degree
          	arrStatus(DEVSTR) = replace(arrStatus(DEVSTR), "°", "& #176;")
          	select case arrStatus(DEVSTR)
          	case "."
          	 arrStatus(ICON) = mid(arrStatus(DEVSTR),1,(Instr(arrStatus(DEVSTR),".")-1) )
          	case "& #176;"
          	 arrStatus(ICON) = mid(arrStatus(DEVSTR),1,(Instr(arrStatus(DEVSTR),"°")-1) )
          	case else
          				 Set oDynImage = CreateObject("DynImage.DynImage")
          				 oDynImage.Open 50, 20
          	 oDynImage.Color = &h000000
          	 oDynImage.Rectangle 0, 0, 50,20
          	 oDynImage.FontFace = "Tahoma Bold"
          	 oDynImage.FontWeight = 300
          	 oDynImage.FontSize = 12
          	 oDynImage.Color = &h000000
          	 oDynImage.TextOut 7,03, arrStatus(DEVSTR) & "°"
          	 oDynImage.FontFace = "Arial"
          	 oDynImage.FontWeight = 500
          	 oDynImage.FontSize = 14
          		Dimage = "C:\Program Files\HomeSeer 2\html\Images\HomeSeer\temp\test.png"
          	 oDynImage.SaveImage(Dimage)
          	 oDynImage.Close
          	 set oDynImage = nothing
          				 arrStatus(ICON) = "temp/" & arrStatus(DEVSTR) & ".png"
          	end select
          	'arrStatus(ICON) = BuildIcon(arrStatus(ICON))
          end if
           
           
          Case Else
          '
          ' Attempt to make images identical to how HomeSeer displays them
          '
          Select Case CInt(iDevStatus)
          	Case 2
          	 '
          	 ' Device status is ON
          	 '
          	 If arrStatus(DEVSTR) = "" Then
          	 arrStatus(DEVSTR) = "On"
          	 arrStatus(ICON) = "on.gif"
          	 Else
          	 arrStatus(ICON) = BuildIcon(arrStatus(DEVSTR))
          	 End If
          	Case 3
          	 '
          	 ' Device status is OFF
          	 '
          	 If arrStatus(DEVSTR) = "" Then
          	 arrStatus(DEVSTR) = "Off"
          	 arrStatus(ICON) = "off.gif"
          	 Else
          	 arrStatus(ICON) = BuildIcon(arrStatus(DEVSTR))
          	 End If
          	Case 4
          	 '
          	 ' Deviced status is Dimmed
          	 '
          	 If DarrStatus(DEVSTR) = "" Then
          	 arrStatus(DEVSTR) = "Dimmed to " & FormatPercent(iDevDim / 100, 0)
          	 arrStatus(ICON) = "dim.gif"
          	 Else
          	 arrStatus(ICON) = BuildIcon(arrStatus(DEVSTR))
          	 End If
          	Case Else
          	 '
          	 ' Device status is Unknown
          	 '
          	 If arrStatus(DEVSTR) = "" Then
          	 arrStatus(DEVSTR) = "Unknown"
          	 arrStatus(ICON) = "unknown.gif"
          	 Else
          	 arrStatus(ICON) = BuildIcon(arrStatus(DEVSTR))
          	 End If
          End Select
          End Select
           
          ProcessDevice = arrStatus
           
          '
          ' Test for and process error condition
          '
          If Err.Number <> 0 Then
          Call ProcessError(Err, "ProcessDevice()")
          Err.Clear()
          End If
           
          End Function

          If you need more, grab UltraStatus2 plugin and it loads the UltraView2 as well.
          |
          | - Gordon

          "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
          HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

          Comment


            #6
            No thoughts about what the issue might be? <bump>
            |
            | - Gordon

            "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
            HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

            Comment


              #7
              Gordon,

              The code posted cannot work in ASPX as you have scripting commands such as 'set' which is not supported.

              Have you set the ASPX page to debug and your web.config file suitably configured which will force all errors to show?
              Jon

              Comment


                #8
                Hi Jon,

                Thanks for the look-see. I don't know how to make the changes to the settings you spoke of, I'm just getting into HS2 and I've got to learn all the ins and outs of it.

                I'll look around the board to find the places to make those changes you mentioned, then try some tests to see what errors I get.

                If I can't use 'set', what do I use to pass the parameters to the object? That was the only way to do it in the ASP pages - a simple assignment would not work. I'm not that familiar with ASPX requirements.
                |
                | - Gordon

                "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
                HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

                Comment


                  #9
                  PS Jon or others, I can't find the places to make the changes Jon suggested above (no web.config file, etc.).

                  Also, where can I find more about ASPX scripting? I don't see anything about it on MS' site... or at least their search engine isn't bringing anything noteworthy up.
                  |
                  | - Gordon

                  "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
                  HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

                  Comment


                    #10
                    Gordon,

                    After reading your first post, I see that the script you are trying to alter is called from the ASPX page and as it has the extension .txt, it will run in standard VB-script.

                    Have you tried extracting the image code and running it as a standalone script in HS2 to narrow down the problem? This should work using VB-script with no issues.

                    As for your other question about ASPX, it is really about scripting in VB.NET rather than VB-Script. If you can write a script in VB.NET, then you should be able to write a ASPX page.

                    There is no simple solution to conversion from VB-script to VB.NET as it depends on the complexity of the script. In very simple scripts, it may be just a matter of placing brackets around every command i.e.

                    hs.speak "Hello" becomes hs.speak ("Hello")
                    hs.waitsecs 2 becomes hs.waitsecs (2) etc

                    That said, several things have changed such as regular expressions, file manipulation, time etc.

                    There is no need to go down this route with your problem as VB-script still works very well in HS2.
                    Jon

                    Comment


                      #11
                      It's got to be simpler than this!

                      I'm sorry, Jon, you've lost me. The ONLY thing I know about .NET is I don't like what it's doing to HS. I don't know anything about ASPX or VB.NET - I'm not a developer/programmer. I can write scripts all day long, VBscript, even WMI scripts.

                      First, the .txt file is INCLUDEd, not called, in the main ASPX script, so it is being acted upon as ASPX code, I believe.

                      "Image code"???? Oh, you mean the code supporting the ActiveX object I'm trying to use? The object runs properly under HS2 in an ASP page, but the UltraView code is ASPX.

                      Switching gears: How do I go about calling a VBScript script from the ASPX page? There are no examples in HS2 documentation or scripts/pages... and while I have the VBScript docs, there are none for VB.NET ("ASPX scripting") that I can find.

                      What do I download from the MS site to learn about this stuff? Where are the docs? Are there any MS white papers on how to convert from VBScript to VB.NET code? I've been all over the MS site and MSDN and can't find a darn thing...

                      Now, can you also answer how to set up the debugging in HS2.0 so I can see the results and debug codes and such?
                      |
                      | - Gordon

                      "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
                      HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

                      Comment


                        #12
                        Gordon,

                        I'm not a programmer either, I just trying to help you from the experiences I've learnt in the last few weeks as no one else responded to your post. The trouble here is that VB.NET is very new to Homeseer scriptwriters and very little published on what to do. If you are experienced in VBScript, it will not take you long to get an understanding of VB.NET with a little research on the internet.

                        My choice of words was wrong, however I assumed that when a file is 'included', Homeseer acts on the file extension. As I have no experience with this, I may be wrong and it may well act as an ASPX as you suggest.

                        To enable ASPX debugging, you need to do the following:

                        Copy the following text.
                        PHP Code:
                        <?xml version="1.0" encoding="utf-8" ?> 
                        <configuration>
                            <system.web>
                                <customErrors mode="Off"/>
                            </system.web>
                        </configuration>
                        Create a file called Web.config and save this in the Homeseer 2/html directory

                        Next open up the main ASPX in question.

                        Add the following to the very first line of the page:
                        PHP Code:
                        <%@ Page Language="VB" Debug="true" %> 
                        This will then force the compiler output errors to show on the web page.

                        Finally modify the image code to be .NET compliant:
                        PHP Code:
                        oDynImage CreateObject("DynImage.DynImage")
                        oDynImage.Open 5020
                        oDynImage
                        .Color = &h000000
                        oDynImage
                        .Rectangle 0050,20
                        oDynImage
                        .FontFace "Tahoma Bold"
                        oDynImage.FontWeight 300
                        oDynImage
                        .FontSize 12
                        oDynImage
                        .Color = &h000000
                        oDynImage
                        .TextOut 7,03arrStatus(DEVSTR) & "°"
                        oDynImage.FontFace "Arial"
                        oDynImage.FontWeight 500
                        oDynImage
                        .FontSize 14
                        Dimage 
                        "C:\Program Files\HomeSeer 2\html\Images\HomeSeer\temp\test.png"
                        oDynImage.SaveImage(Dimage)
                        oDynImage.Close
                        oDynImage 
                        nothing 
                        I would also modify the dim statements as follows:
                        PHP Code:
                        Dim oDynImage As Object
                        Dim Dimage 
                        As String 
                        Hope that helps!
                        Jon

                        Comment


                          #13
                          Thanks, Jon, it didn't help. I have done some testing, but I can't get any errors to display and even Ultrajones' code doesn't show any errors (he traps many of them), even after adding the file and codes you mentioned and restarting HS2. I suspect that because this particular layer is a DHTML overlay, the errors (if any) are in a hidden window.

                          I did find one thing, though: just having the line "Dim oDynImage as Object" in the Function definition caused it to fail. No other changes were necessary, even when the code wasn't never run because nothing matched the Case statement parameters, and I still didn't get any errors.

                          Go figure. Apparently there is a lot more going on here than either of us knows, and it is related to Objects. Again, this is another reason why I don't care for the latest MS software. A script is no longer a script... and .NAT puts on many more idiosynchrasies. Whatever happened to good old BASIC? hehehe

                          I'm giving up for now. I need to learn this stuff on a simpler basis first. Thanks for all your help!
                          |
                          | - Gordon

                          "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
                          HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

                          Comment

                          Working...
                          X