Esempio n. 1
0
    def init_camera(self):
        ns = locate_ns(host="camacholab.ee.byu.edu")
        objs = str(ns.list())
        while (True):
            temp_str = objs[objs.find('\'') + 1:-1]
            temp_obj = temp_str[0:temp_str.find('\'')]
            if (temp_obj[0:5] == "UC480"):
                temp_ser_no = int(temp_obj[6:len(temp_obj)])
                if (temp_ser_no == self.ser_num):
                    cam_str = temp_obj
            if (objs.find(',') == -1):
                break
            objs = objs[objs.find(',') + 1:-1]
        try:
            cam_str
        except NameError:
            raise Exception("Camera with serial number " + str(self.ser_num) +
                            " could not be found")
        self.cam = Proxy(ns.lookup(cam_str))

        self.cam.start(exposure=65)
        ip_address = self.cam.start_capture(self.color)
        self.clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.clientsocket.connect((str(ip_address), PORT))

        self.time_s = 0
        self.frame_rate = 0
        self.count = -1
Esempio n. 2
0
 def __init__(self,
              pyroname: str = "",
              ns_host: str = "localhost",
              ns_port: int = 9090) -> None:
     super().__init__(pyroname)
     with locate_ns(host=ns_host, port=ns_port) as ns:
         self.driver = Proxy(ns.lookup(pyroname))
         self.driver.autoconnect()
Esempio n. 3
0
    def init_camera(self):
        ns = locate_ns(host="camacholab.ee.byu.edu")
        objs = str(ns.list())
        while (True):
            temp_str = objs[objs.find('\'') + 1:-1]
            temp_obj = temp_str[0:temp_str.find('\'')]
            if (temp_obj[0:5] == "UC480"):
                temp_ser_no = int(temp_obj[6:len(temp_obj)])
                if (temp_ser_no == SER_NUMBER):
                    cam_str = temp_obj
            if (objs.find(',') == -1):
                break
            objs = objs[objs.find(',') + 1:-1]
        try:
            cam_str
        except NameError:
            raise Exception("Camera with serial number " + str(SER_NUMBER) +
                            " could not be found")

        self.cam = Proxy(ns.lookup(cam_str))

        self.cam.start(exposure=65)
        ip_address = self.cam.start_capture(COLOR)
        print("IP: " + str(ip_address))
        self.clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.clientsocket.connect((str(ip_address), PORT))

        now = datetime.now()
        dt_string = now.strftime("rec_" + str(SER_NUMBER) +
                                 "/%Y-%m-%d_%H-%M-%S.avi")
        fourcc = cv2.VideoWriter_fourcc(*'XVID')
        self.out = cv2.VideoWriter(dt_string, fourcc, 4.0, (640, 512))

        self.time_s = 0
        self.frame_rate = 0
        self.count = -1
        self.vid = cv2.VideoCapture("test.mp4")
Esempio n. 4
0
# -*- coding: utf-8 -*-
#
# Copyright © PyroLab Project Contributors
# Licensed under the terms of the GNU GPLv3+ License
# (see pyrolab/__init__.py for details)

"""
2-Way SSL Server
----------------

...
"""

from pyrolab.api import Daemon, locate_ns
from pyrolab.drivers.sample import SampleService

daemon = Daemon()
ns = locate_ns(host="localhost")
uri = daemon.register(SampleService)
ns.register("test.SampleService", uri)

print("READY")
try:
    daemon.requestLoop()
finally:
    ns.remove("test.SampleService")
Esempio n. 5
0
folderName = prefix + data_directory
folderPath = Path(Path.cwd(), folderName)
print("Saving data to {} in current directory.".format(folderName))
if not os.path.exists(folderPath):
    print("Creating {} directory.".format(folderName))
    os.makedirs(folderPath)

# ---------------------------------------------------------------------------- #
# Initialize Devices
# ---------------------------------------------------------------------------- #
# Initialize Laser
print("Initializing laser.")
try:
    # Remote Computer via PyroLab
    from pyrolab.api import locate_ns, Proxy
    ns = locate_ns(host="camacholab.ee.byu.edu")
    laser = Proxy(ns.lookup("lasers.TSL550"))
except:
    # Local Computer
    laser = TSL550("COM4")

laser.on()
laser.power_dBm(power_dBm)
laser.open_shutter()
laser.sweep_set_mode(continuous=True,
                     twoway=True,
                     trigger=False,
                     const_freq_step=False)
print("Enabling laser's trigger output.")
laser.trigger_enable_output()
triggerMode = laser.trigger_set_mode("Step")
Esempio n. 6
0
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyroLab is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyroLab. If not, see <https://www.gnu.org/licenses/>.


from tabulate import tabulate
from pyrolab.api import locate_ns


HOST = "localhost"
PORT = 9090

ns = locate_ns(host=HOST, port=PORT)
services = ns.list(return_metadata=True)

listing = []
for k, v in services.items():
    name = k
    uri, description = v
    listing.append([name, uri, ': '.join(description)])

print(tabulate(listing, headers=['NAME', 'URI', 'DESCRIPTION']))
Esempio n. 7
0
# -*- coding: utf-8 -*-
#
# Copyright © PyroLab Project Contributors
# Licensed under the terms of the GNU GPLv3+ License
# (see pyrolab/__init__.py for details)
"""
Kinesis KCube Driver Example
============================

This example demonstrates the use of the Thorlabs KCube DC Servo controlling a 
Z825B translational stage using PyroLab. 
"""

from pyrolab.api import NameServerConfiguration, Proxy, locate_ns

nscfg = NameServerConfiguration(host="yourdomain.com")
nscfg.update_pyro_config()

# Be considerate; don't stay connected to the nameserver too long.
with locate_ns() as ns:
    motor = Proxy(ns.lookup("Z825B_PyroName"))

motor.autoconnect()
print(motor.get_position())
motor.close()