-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_simple_demo.py
More file actions
68 lines (56 loc) · 1.79 KB
/
Copy pathrun_simple_demo.py
File metadata and controls
68 lines (56 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
"""
Simple demo script for the Smart Garden System.
Runs the system with simulated hardware for demonstration purposes.
"""
import os
import sys
import time
import logging
import yaml
import threading
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
def main():
"""Run the Smart Garden System in demo mode."""
logger.info("Starting Smart Garden System Demo")
# Create data directory if it doesn't exist
os.makedirs('data', exist_ok=True)
os.makedirs('logs', exist_ok=True)
# Check if config.yaml exists
if not os.path.exists('config.yaml'):
logger.error("config.yaml not found. Please create it first.")
sys.exit(1)
# Import the main system (after ensuring directories exist)
from src.main import SmartGardenSystem
# Create and run the system
system = SmartGardenSystem('config.yaml')
# Start the system in a separate thread
system_thread = threading.Thread(target=system.run)
system_thread.daemon = True
system_thread.start()
# Print information about the demo
print("\n" + "="*80)
print("Smart Garden System Demo")
print("="*80)
print("\nThe system is now running with simulated hardware.")
print("Web interface available at: http://localhost:12000")
print("\nPress Ctrl+C to exit.")
print("="*80 + "\n")
try:
# Keep the main thread alive
while True:
time.sleep(1)
except KeyboardInterrupt:
logger.info("Keyboard interrupt received, shutting down")
finally:
logger.info("Demo completed")
if __name__ == "__main__":
main()