BioImager  4.9.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
microscope.win32.MicroscopeWindowsService Class Reference
Inheritance diagram for microscope.win32.MicroscopeWindowsService:

Public Member Functions

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

Public Attributes

 stop_event = multiprocessing.Event()
 

Static Protected Attributes

str _svc_name_ = "MicroscopeService"
 
str _svc_display_name_ = "Microscope device servers"
 
str _svc_description_ = "Serves microscope devices."
 

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__()

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()

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()

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()

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()

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()

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

◆ _svc_description_

str microscope.win32.MicroscopeWindowsService._svc_description_ = "Serves microscope devices."
staticprotected

Definition at line 67 of file win32.py.

◆ _svc_display_name_

str microscope.win32.MicroscopeWindowsService._svc_display_name_ = "Microscope device servers"
staticprotected

Definition at line 66 of file win32.py.

◆ _svc_name_

microscope.win32.MicroscopeWindowsService._svc_name_ = "MicroscopeService"
staticprotected

Definition at line 65 of file win32.py.

◆ stop_event

microscope.win32.MicroscopeWindowsService.stop_event = multiprocessing.Event()

Definition at line 91 of file win32.py.


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