Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

MaximDL TCP Communication Module‏


Euan

Recommended Posts

This idea spilled out of a project to have a remote monitoring webserver (http://stargazerslounge.com/diy-astronomer/146907-automation-monitoring-webserver.html)

What I wanted to do a first was to pull together information from different places to show as an "Observatory Interface" rather than having to leave a laptop open with remote desktop or VNC into the Obs PC with loads of different windows open, it's not a good way to check on things at a glance, you really just want to boil it down to the key information.

This has expanded quite a bit, and what I'm doing now as well as pulling information from security cameras and websites, is to pull information live from the automation programs that are running the show. The main obviously is MaximDL, but for me the status of CCD Commander is also important.

I've put together a VB command line application that will connect into MaximDL's COM interface and ask for feedback on Application and Camera events. It will then send these events out over network to any IP address and port number you ask it to connect to, as long as the port is open and listening.

This can handy for doing the following things:

1. Sending live info to a webserver to be presented on a webpage

2. Sending to a control system to display on a touchpanel / interface

3. Sending to another remote application (iPad, iPhone?)

I'm really doing option two, and processing this to be presented elsewhere as an interface. The beauty of this module is you can also use it to interpret events going into MaximDL, which opens up a bigger library of commands.

6009232655_a6f6933fab_b.jpg

Here is a list of the states that the MaximDL COM object supports, as you can see there are quite a few that are extremely handy to have on a remote device or controller, such as "Guider Exposure Star Faded" and "Autofocus Aborted".

Application Events

Sequence Started

Sequence Completed

Telescope Connected

Telescope Disconnected

Telescope Slew Started

Telescope Slew Completed

Telescope Declination Limit

Telescope Horizon Limit

Autofocus Started

Autofocus Fine Focus Started

Autofocus Completed

Autofocus Aborted

CCD Events

CCD Exposure Started

CCD Exposure Completed

CCD Exposure Aborted

CCD Sequence Started

CCD Sequence Completed

CCD Sequence Aborted

Guider Tracking Started

Guider Tracking Stopped

Guider Exposure Completed

Guider Exposure Star Faded

Guide Correction Started

Guide Correction Completed

Filter Wheel Moving

Filter Wheel Stopped

CCD Connected

CCD Disconnected

CCD Exposure Paused

CCD Exposure Resumed

CCD Exposure Readout Completed

Guider Calibration Completed

This may seem a bit pointless at first, but just to put this in context here is how I've started to put it together on a touchpanel (security cams blurred out). This can all be manipulated into a nice funky graphical interface, as you see in things like ACP. Next is to add in a live log feed from CCD Commander and build it in some nice graphics.

The weather applet is being made using the data from the Aurora Cloud Sensor, more on that soon ;)

If anyone wants this to try out, drop me a PM. It should work fine as a standalone app as long as you have a socket to connect to.

6009424897_6bb4f4a291_b.jpg

Link to comment
Share on other sites

WOW Euan - sign me up, just what I have been looking for! An IPhone app has to be next on the list though!

Will do, I've signed up as an iOS developer for that very reason :rolleyes:

I'm hoping the iPad 3 has a retina display as it would be great for showing loads of data.

The possibilities are quite interesting, my head is buzzing with ideas, I just need to try and concentrate on getting the new Borg setup ready and working before the darkness returns to 55° north on Tuesday ;)

Link to comment
Share on other sites

Nice. I've been thinking of doing something similar lately, but haven't quite got round to it yet. My application is more to regularly (5-10s) 'ping' Maxim etc at get information such a telescope pointing, CCD temp, status, etc and dump it in to a database. I guess that would be a relatively simple expansion of your script?

Fraser

Link to comment
Share on other sites

Nice. I've been thinking of doing something similar lately, but haven't quite got round to it yet. My application is more to regularly (5-10s) 'ping' Maxim etc at get information such a telescope pointing, CCD temp, status, etc and dump it in to a database. I guess that would be a relatively simple expansion of your script?

Fraser

Should be easy enough, here is the script. To register for all the events you need to set the EventMask for both App and Cam to -1

Also, this is built with Visual Basic Express 2010 with Maxim as a COM reference device, if you can't do this you might have to create new objects and connect them to Maxim.Application and Maxim.CCDCamera

It uses a simple loop to keep it open, so it's still pretty basic. The two functions Cam_Notify and App_Notify handle the feedback from Maxim. AppWindow is the start of a form I'm building for it to make it a bit nicer.

Imports System.Net.Sockets

Imports System.Text

Module MasterCode

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer)

Dim sServer As String

Dim nPort As Long

Dim clientSocket As New System.Net.Sockets.TcpClient()

Dim outStream As Byte()

Dim WithEvents App As New MaxIm.Application

Dim WithEvents Cam As New MaxIm.CCDCamera

Dim dwMilliseconds = 10000

Dim AppWindow As New AppGUI

Sub Main()

sServer = InputBox("Enter IP Address to connect to", "MaximDL TCP Outgoing Communications Interface", "192.168.1.21")

nPort = InputBox("Enter Port Number to connect to", "MaximDL TCP Outgoing Communications Interface", "4001")

Console.WriteLine("MaximDL TCP Outgoing Communications Interface")

Console.WriteLine("Written for the Nano Observatory, July 2011")

Console.WriteLine("--------------------------------------------------")

clientSocket.Connect(sServer, nPort)

If clientSocket.Connected Then

Console.WriteLine("Connection to Controller Established")

Console.WriteLine("--------------------------------------------------")

Dim serverStream As NetworkStream = clientSocket.GetStream()

Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes("Connection Established" & vbCrLf)

serverStream.Write(outStream, 0, outStream.Length)

serverStream.Flush()

End If

Cam.EventMask = (-1)

App.EventMask = (-1)

Call ConnectCamera()

Do Until Cam.LinkEnabled = False

Loop

End Sub

Public Sub ConnectCamera()

Cam.LinkEnabled = True

End Sub

Public Sub Cam_Notify(ByVal EventCode As Short) Handles Cam.Notify

Dim AppWindow As New AppGUI

Dim serverStream As NetworkStream = clientSocket.GetStream()

Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes("Camera Event = " & EventCode & vbCrLf)

serverStream.Write(outStream, 0, outStream.Length)

serverStream.Flush()

Console.WriteLine("Camera Event = " & EventCode)

End Sub

Public Sub App_Notify(ByVal EventCode As Short) Handles App.Notify

Dim AppWindow As New AppGUI

Dim serverStream As NetworkStream = clientSocket.GetStream()

Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes("Application Event = " & EventCode & vbCrLf)

serverStream.Write(outStream, 0, outStream.Length)

serverStream.Flush()

Console.WriteLine("Application Event = " & EventCode)

End Sub

End Module

Link to comment
Share on other sites

Another sub here to pull the autoguider error, it should work just struggling to get the ASCOM simulator to work to try and test it. Also making shorthand variable descriptors hence GEX and GEY. This could be used to stick into a graph, I think I will use it to just show the data, with maybe alarms built around certain limits.

Do Until Cam.LinkEnabled = False

If Cam.GuiderRunning Then

If (GuiderErrorX <> Cam.GuiderXError) Then

GuiderErrorX = Cam.GuiderXError

Dim serverStream As NetworkStream = clientSocket.GetStream()

Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes("GEX=" & GuiderErrorX & vbCrLf)

serverStream.Write(outStream, 0, outStream.Length)

serverStream.Flush()

Console.WriteLine("Guider Error X = " & GuiderErrorX)

End If

If (GuiderErrorY <> Cam.GuiderYError) Then

GuiderErrorY = Cam.GuiderYError

Dim serverStream As NetworkStream = clientSocket.GetStream()

Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes("GEY=" & GuiderErrorY & vbCrLf)

serverStream.Write(outStream, 0, outStream.Length)

serverStream.Flush()

Console.WriteLine("Guider Error Y = " & GuiderErrorY)

End If

End If

Loop

EDIT: Tested and working now with the simulator, just keep this in the main sub on a loop

6011477472_b9d9047014_b.jpg

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.