Пример #1
0
except(ImportError):
    print("COULD NOT GET DRIVERS/SDK, STARTING IN DUMMY MODE")
    import evora.server.dummy as andor

# For filter controls
# from FilterMotor import filtermotor

# port for evora is 5502
# port for filter wheel is 5503
# port for ftp server is 5504

# Global Variables
acquired = None
t = None
isAborted = None  # tracks globally when the abort has been called. Every call to the parser is an new instance
logger = my_logger.myLogger("evora_server.py", "server")
ftp_server = None
parser = None
# Get gregorian date, local
# d = date.today()
# logFile = open("/home/mro/ScienceCamera/gui/logs/log_server_" + d.strftime("%Y%m%d") + ".log", "a")


class EvoraServer(basic.LineReceiver):
    """
    This is the Evora camera server code using Twisted's convienience object of basic.LineReceiver.
    When a line is recieved from the client it is sent to the parser to execute the camera commands
    and the resulting data is sent back to the client.  This a threaded server so that long
    running functions in the parser don't hang the whole server.
    """
    def connectionMade(self):
Пример #2
0
from datetime import datetime

import evora.common.logging.my_logger as my_logger

logger = my_logger.myLogger("log_utils.py", "client")


def get_log_str(command, prePost):
    """
    Pre: Takes in command that is either sent to or from the server.  Parses that command and constructs
        a string for reporting in any particular status box.  Must pass in as prePost whether the command
         is pre-server exectution or post server exection.
    Post: Returns a string that is used to report in a status box through the GUI, e.g. the log box in the
          log tab.  If string is not made then it returns None.
    """
    command = command.split(" ")
    if prePost == 'pre':  # command is split with by white space
        key = command[0]

        if key == 'expose':
            itime = float(command[3])
            return "Exposing for time %.2f sec" % itime  # noqa: F821
        if key == 'real':
            itime = float(command[3])
            return "Starting real time expsoures with %.2f sec" % itime
        if key == 'series':
            itime = float(command[3])
            number = int(command[2])
            return "Exposing for %d images with time %.2f sec" % (number, itime)
        if key == 'setTEC':
            temp = float(command[1])
Пример #3
0
import datetime
import os

import numpy as np
from astropy.io import fits

import evora.common.logging.my_logger as my_logger

logger = my_logger.myLogger("fits_utils.py", "client")


def getdata(path):
    """
    This function will open a FITS file, return the data as a 2x2 numpy array
    """
    return fits.getdata(path)


def calcstats(data):
    """
    This function calculates the standard statistics of a FITS image of min,
    max, mean, and median. A list of these stats is returned so that these
    stats can then be displayed at the bottom of the image GUI window.
    """
    stats_list = []
    stats_list.append(min(data.flat))
    stats_list.append(max(data.flat))
    stats_list.append(np.mean(data.flat))
    stats_list.append(np.median(data.flat))
    return stats_list
Пример #4
0
import evora.common.utils.fits as fits_utils
import evora.common.utils.logs as log_utils
from evora.common import netconsts
"""
# Comment on documentation:
# When reading the doc strings if "Pre:" is present then this stands for "precondition", or the conditions in order to invoke something.
# Oppositely, "Post:" stands for "postcondition" and states what is returned by the method.
"""

__author__ = "Tristan J. Hillis"

# Global Variables
app = None  # reference to Evora app
port_dict = {}  # dictionary storing different connections that may be open.
ftpClientProc = None
logger = my_logger.myLogger("photoAcquisitionGUI.py", "client")

# Getting to parents (i.e. different classes)
# Three parents will get to the Evora class and out of the notebook


# Frame class.
class Evora(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Evora Acquisition GUI",
                          size=(630, 500))

        # width and height in pixels
Пример #5
0
import wx
from twisted.internet import protocol

import evora.common.logging.my_logger as my_logger

__author__ = "Tristan J. Hillis"
"""
Comment on documentation:
When reading the doc strings if "Pre:" is present then this stands for "precondition", or the conditions in order
to invoke something.  Oppositely, "Post:" stands for "postcondition" and states what is returned by the method.

File Description: This file contains a set of functions that the GUI or server code calls throughout.
"""

# Deprecated
logger = my_logger.myLogger("gui_elements.py", "client")
# Get gregorian date, local
# d = date.today()
# logFile = open("/home/mro/ScienceCamera/gui/logs/log_gui_" + d.strftime("%Y%m%d") + ".log", "a")


def AddLinearSpacer(boxsizer, pixelSpacing):
    """
    A one-dimensional spacer along only the major axis for any BoxSizer

    Found this on a wxPython tutorial and it has proved to be very handy.

    It takes in a box sizer as boxsizer and the spacing as pixelSpacing and expands the
    passed in sizer along its major axis.  This is used over boxsizer.AddSpacer(...) as this
    expands along both axises causing untold issues.  It also is more intuitive than
    boxsizer.AddSpacer((..,..)) where you pass a 0 to the width or height to obtain the same