Subversion Repositories HomeAutomation

Rev

Rev 1961 | Rev 2107 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1961 Rev 1964
Line 92... Line 92...
92
    return EXIT_SUCCESS;
92
    return EXIT_SUCCESS;
93
  }
93
  }
94
 
94
 
95
  if (config::Manager::Instance()->Exist("LogFile"))
95
  if (config::Manager::Instance()->Exist("LogFile"))
96
  {
96
  {
97
    logging::Logger::OpenFile(config::Manager::Instance()->GetAsString("LogFile"));
97
    log::OpenFile(config::Manager::Instance()->GetAsString("LogFile"));
98
  }
98
  }
99
 
99
 
100
  if (config::Manager::Instance()->Exist("LogLevelMask"))
100
  if (config::Manager::Instance()->Exist("LogLevelMask"))
101
  {
101
  {
102
    log::SetLogLevelByString(config::Manager::Instance()->GetAsString("LogLevelMask"));
102
    log::SetLevelByString(config::Manager::Instance()->GetAsString("LogLevelMask"));
103
  }
-
 
104
 
-
 
105
  if (config::Manager::Instance()->Exist("LogLevel")) // Deprecated
-
 
106
  {
-
 
107
    logging::Logger::SetLevel((logging::Logger::Level) config::Manager::Instance()->GetAsInt("LogLevel"));
-
 
108
  }
103
  }
109
 
104
 
110
  if (config::Manager::Instance()->Exist("daemon"))
105
  if (config::Manager::Instance()->Exist("daemon"))
111
  {
106
  {
112
    LOG.Info("Entering daemon mode...");
107
    LOG.Info("Entering daemon mode...");
Line 128... Line 123...
128
  can::Protocol::Create();
123
  can::Protocol::Create();
129
  control::Manager::Create();
124
  control::Manager::Create();
130
  vm::Manager::Create();
125
  vm::Manager::Create();
131
 
126
 
132
  storage::Manager::Instance()->SetRootPath(config::Manager::Instance()->GetAsString("StoragePath"));
127
  storage::Manager::Instance()->SetRootPath(config::Manager::Instance()->GetAsString("StoragePath"));
133
 
128
 
134
  can::Protocol::Instance()->Load(config::Manager::Instance()->GetAsString("ProtocolFile"));
129
  can::Protocol::Instance()->Load(config::Manager::Instance()->GetAsString("ProtocolFile"));
135
 
130
 
136
  if (config::Manager::Instance()->Exist("MonitorPort"))
131
  if (config::Manager::Instance()->Exist("MonitorPort"))
137
  {
132
  {
138
    subscribers.push_back(can::Monitor::Pointer(new can::Monitor(config::Manager::Instance()->GetAsInt("MonitorPort"))));
133
    subscribers.push_back(can::Monitor::Pointer(new can::Monitor(config::Manager::Instance()->GetAsInt("MonitorPort"))));
139
  }
134
  }
140
 
135
 
141
  if (config::Manager::Instance()->Exist("DaemonPort"))
136
  if (config::Manager::Instance()->Exist("DaemonPort"))
142
  {
137
  {
143
    subscribers.push_back(can::CanDaemon::Pointer(new can::CanDaemon(config::Manager::Instance()->GetAsInt("DaemonPort"))));
138
    subscribers.push_back(can::CanDaemon::Pointer(new can::CanDaemon(config::Manager::Instance()->GetAsInt("DaemonPort"))));
144
  }
139
  }
145
 
140
 
146
  subscribers.push_back(control::Manager::Instance());
141
  subscribers.push_back(control::Manager::Instance());
147
 
142
 
148
  vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::System(vm::Manager::Instance()->GetIoService())));
143
  vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::System(vm::Manager::Instance()->GetIoService())));
149
  vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Console(vm::Manager::Instance()->GetIoService(), config::Manager::Instance()->GetAsInt("CommandPort"))));
144
  vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Console(vm::Manager::Instance()->GetIoService(), config::Manager::Instance()->GetAsInt("CommandPort"))));
150
  vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Storage(vm::Manager::Instance()->GetIoService())));
145
  vm::Manager::Instance()->AddPlugin(vm::Plugin::Pointer(new vm::plugin::Storage(vm::Manager::Instance()->GetIoService())));
Line 164... Line 159...
164
  vm::Manager::Instance()->Start(config::Manager::Instance()->GetAsString("ScriptPath"), config::Manager::Instance()->GetAsString("UserScriptPath"));
159
  vm::Manager::Instance()->Start(config::Manager::Instance()->GetAsString("ScriptPath"), config::Manager::Instance()->GetAsString("UserScriptPath"));
165
 
160
 
166
  if (config::Manager::Instance()->Exist("CanNet"))
161
  if (config::Manager::Instance()->Exist("CanNet"))
167
  {
162
  {
168
    common::StringList cannetworks = config::Manager::Instance()->GetAsStringVector("CanNet");
163
    common::StringList cannetworks = config::Manager::Instance()->GetAsStringVector("CanNet");
169
 
164
 
170
    for (uint n = 0; n < cannetworks.size(); n++)
165
    for (uint n = 0; n < cannetworks.size(); n++)
171
    {
166
    {
172
      subscribers.push_back(can::Network::Pointer(new can::Network(cannetworks[n])));
167
      subscribers.push_back(can::Network::Pointer(new can::Network(cannetworks[n])));
173
    }
168
    }
174
  }
169
  }
175
 
170
 
176
  boost::mutex::scoped_lock guard(guard_mutex);
171
  boost::mutex::scoped_lock guard(guard_mutex);
177
 
172
 
178
  on_message_condition.wait(guard);
173
  on_message_condition.wait(guard);
179
 
174
 
180
  log::Info(log_module_, "Cleaning up...");
175
  log::Info(log_module_, "Cleaning up...");
181
 
176
 
182
  CleanUp();
177
  CleanUp();
183
 
178
 
184
  log::Info(log_module_, "Thank you for using Atom. Goodbye!");
179
  log::Info(log_module_, "Thank you for using Atom. Goodbye!");
185
 
180
 
186
  return EXIT_SUCCESS;
181
  return EXIT_SUCCESS;
Line 200... Line 195...
200
  can::Protocol::Delete();
195
  can::Protocol::Delete();
201
  broker::Manager::Delete();
196
  broker::Manager::Delete();
202
  vm::Manager::Delete();
197
  vm::Manager::Delete();
203
  net::Manager::Delete();
198
  net::Manager::Delete();
204
  storage::Manager::Delete();
199
  storage::Manager::Delete();
-
 
200
 
-
 
201
  log::CloseFile();
205
}
202
}
206
 
203
 
207
void Handler(int status)
204
void Handler(int status)
208
{
205
{
209
  std::string signal_name = "Unknown";
206
  std::string signal_name = "Unknown";