Commit 3535f94c67b78561744e7cbbcde1773bc25d50da

Authored by Patrick Maeght
1 parent 931abe1d
Exists in dev

start_agent.py agentM

Showing 2 changed files with 27 additions and 3 deletions   Show diff stats
src/monitoring/AgentM.py
... ... @@ -9,9 +9,11 @@ import sys
9 9 #from common.models import Command
10 10  
11 11 sys.path.append("..")
12   -from agent.Agent import Agent, extract_parameters
13   -
  12 +from src.agent.Agent import Agent, extract_parameters
14 13  
  14 +# PM 20190416 recycle code
  15 +from src.devices.PLC import PLCController
  16 +from src.monitoring.plc_checker import PlcChecker
15 17  
16 18 ##log = L.setupLogger("AgentXTaskLogger", "AgentX")
17 19  
... ... @@ -27,6 +29,15 @@ class AgentM(Agent):
27 29 SIMULATOR_WITH_TEST = True
28 30 SIMULATOR_MAX_DURATION_SEC = None
29 31 #SIMULATOR_MAX_DURATION_SEC = 120
  32 +
  33 + # PM 20190416 fucking config path starting: /home/patrick/Dev/PYROS/start_agent.py agentM
  34 + _path_data = 'config'
  35 + # PM 20190416 recycle code
  36 + plcController = PLCController()
  37 + print ("AGENT ENV: config PLC is (ip={}, port={})".format(plcController.ip, plcController.port))
  38 + plc_checker = PlcChecker()
  39 +
  40 +
30 41 '''
31 42 # Who should I send commands to ?
32 43 #SIMULATOR_COMMANDS_DEST = "myself"
... ... @@ -130,6 +141,11 @@ class AgentM(Agent):
130 141 super().exec_specific_cmd_start(cmd, from_thread)
131 142 '''
132 143  
  144 + # @override
  145 + def routine_process(self):
  146 + print("TODO: we recycle code")
  147 +
  148 +
133 149  
134 150 # @override
135 151 def thread_exec_specific_cmd_main(self):
... ...
start_agent.py
... ... @@ -7,7 +7,8 @@ from django.conf import settings as djangosettings
7 7  
8 8 AGENTS = {
9 9 "agentX" : "AgentX",
10   - "agentA" : "AgentA",
  10 + "agentA" : "AgentA",
  11 + "agentM" : "AgentM",
11 12 "webserver" : "webserver",
12 13 "monitoring" : "monitoring",
13 14 "majordome" : "majordome",
... ... @@ -100,6 +101,13 @@ if agent_name == "agentA":
100 101 agentA.run(FOR_REAL=True)
101 102 sys.exit(0)
102 103  
  104 +if agent_name == "agentM":
  105 + from src.monitoring.AgentM import AgentM
  106 + agentM = AgentM(name="agentM", config_filename=configfile)
  107 + # Run agent without actual commands sent to devices (FOR_REAL=False)
  108 + agentM.run(FOR_REAL=True)
  109 + sys.exit(0)
  110 +
103 111 """
104 112 from src.agent.Agent import Agent
105 113 agent = Agent(name="agent", config_filename=configfile)
... ...