Pure Python COM package for Windows COM automation and interoperability
88
A Windows COM server that monitors temperature changes and notifies connected clients through COM events.
Build a COM server that acts as a temperature monitoring system with the following capabilities:
Create a COM server class that:
The server should support an event interface that notifies clients when:
The implementation should:
@generates
"""Temperature monitoring COM server with event support."""
# COM server class that implements temperature monitoring
class TemperatureMonitor:
"""COM server that monitors temperature and fires events to connected clients."""
def set_temperature(self, celsius: float) -> None:
"""Update the current temperature and fire events to connected clients.
Args:
celsius: The new temperature value in Celsius
"""
pass
def get_temperature(self) -> float:
"""Get the current temperature value.
Returns:
The current temperature in Celsius
"""
pass
# Event sink interface that clients implement to receive events
class ITemperatureEvents:
"""Interface that clients implement to receive temperature events."""
def on_temperature_changed(self, old_temp: float, new_temp: float) -> None:
"""Called when temperature changes.
Args:
old_temp: Previous temperature value
new_temp: New temperature value
"""
pass
def on_temperature_warning(self, temp: float) -> None:
"""Called when temperature exceeds 75°C.
Args:
temp: Current temperature that triggered the warning
"""
pass
def on_temperature_normal(self, temp: float) -> None:
"""Called when temperature returns below 75°C after a warning.
Args:
temp: Current temperature
"""
passProvides COM interoperability support for implementing event sources.
Install with Tessl CLI
npx tessl i tessl/pypi-comtypesevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10