BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
microscope.win32.MicroscopeWindowsService Class Reference
Inheritance diagram for microscope.win32.MicroscopeWindowsService:

Public Member Functions

def set_config_file (cls, path)
 
def get_config_file (cls)
 
def log (self, message, error=False)
 
def __init__ (self, args)
 
def SvcDoRun (self)
 
def SvcStop (self)
 

Public Attributes

 stop_event
 

Detailed Description

Serves microscope devices via a Windows service.

Win32 service manipulation relies on fetching _svc_name_ without
instantiating any object, so _svc_name_ must be a class
attribute. This means that only one MicroscopeService may be
installed on any one system, and will be responsible for serving
all microscope devices on that system.

Definition at line 55 of file win32.py.

Constructor & Destructor Documentation

◆ __init__()

def microscope.win32.MicroscopeWindowsService.__init__ (   self,
  args 
)

Definition at line 88 of file win32.py.

88 def __init__(self, args):
89 # Initialise service framework.
90 win32serviceutil.ServiceFramework.__init__(self, args)
91 self.stop_event = multiprocessing.Event()
92

Member Function Documentation

◆ get_config_file()

def microscope.win32.MicroscopeWindowsService.get_config_file (   cls)

Definition at line 76 of file win32.py.

76 def get_config_file(cls):
77 return win32serviceutil.GetServiceCustomOption(
78 cls._svc_name_, "config"
79 )
80

◆ log()

def microscope.win32.MicroscopeWindowsService.log (   self,
  message,
  error = False 
)

Definition at line 81 of file win32.py.

81 def log(self, message, error=False):
82 if error:
83 logFunc = servicemanager.LogErrorMsg
84 else:
85 logFunc = servicemanager.LogInfoMsg
86 logFunc("%s: %s" % (self._svc_name_, message))
87

◆ set_config_file()

def microscope.win32.MicroscopeWindowsService.set_config_file (   cls,
  path 
)

Definition at line 70 of file win32.py.

70 def set_config_file(cls, path):
71 win32serviceutil.SetServiceCustomOption(
72 cls._svc_name_, "config", os.path.abspath(path)
73 )
74

◆ SvcDoRun()

def microscope.win32.MicroscopeWindowsService.SvcDoRun (   self)

Definition at line 93 of file win32.py.

93 def SvcDoRun(self):
94 configfile = win32serviceutil.GetServiceCustomOption(
95 self._svc_name_, "config"
96 )
97 os.chdir(os.path.dirname(configfile))
98 self.log("Using config file %s." % configfile)
99 self.log("Logging at %s." % os.getcwd())
100 self.ReportServiceStatus(win32service.SERVICE_RUNNING)
101
102 from microscope.device_server import (
103 serve_devices,
104 validate_devices,
105 DeviceServerOptions,
106 )
107
108 options = DeviceServerOptions(
109 config_fpath=configfile,
110 logging_level=logging.INFO,
111 )
112
113 try:
114 devices = validate_devices(configfile)
115 serve_devices(devices, options, self.stop_event)
116 except Exception as e:
117 servicemanager.LogErrorMsg(str(e))
118 # Exit with non-zero error code so Windows will attempt to restart.
119 sys.exit(-1)
120 self.log("Service shutdown complete.")
121 self.ReportServiceStatus(win32service.SERVICE_STOPPED)
122

◆ SvcStop()

def microscope.win32.MicroscopeWindowsService.SvcStop (   self)

Definition at line 123 of file win32.py.

123 def SvcStop(self):
124 self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
125 self.stop_event.set()
126
127

Member Data Documentation

◆ stop_event

microscope.win32.MicroscopeWindowsService.stop_event

Definition at line 91 of file win32.py.


The documentation for this class was generated from the following file: