blob: be5b59efa35955c91b799dbeb07610982ae4ed07 [file] [log] [blame]
Matt Spinlere73446e2017-04-10 13:55:52 -05001/**
2 * Copyright © 2017 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <sdbusplus/bus.hpp>
Matt Spinleree7f6422017-05-09 11:03:14 -050017#include "argument.hpp"
Matt Spinlere10416e2017-04-10 14:15:53 -050018#include "manager.hpp"
Matt Spinlere73446e2017-04-10 13:55:52 -050019
Matt Spinleree7f6422017-05-09 11:03:14 -050020using namespace phosphor::fan::control;
21
Matt Spinlere73446e2017-04-10 13:55:52 -050022int main(int argc, char* argv[])
23{
24 auto bus = sdbusplus::bus::new_default();
Matt Spinleree7f6422017-05-09 11:03:14 -050025 phosphor::fan::util::ArgumentParser args(argc, argv);
Matt Spinlere73446e2017-04-10 13:55:52 -050026
Matt Spinleree7f6422017-05-09 11:03:14 -050027 if (argc != 2)
28 {
29 args.usage(argv);
30 exit(-1);
31 }
32
33 Manager::Mode mode;
34
35 if (args["init"] == "true")
36 {
37 mode = Manager::Mode::init;
38 }
39 else if (args["control"] == "true")
40 {
41 mode = Manager::Mode::control;
42 }
43 else
44 {
45 args.usage(argv);
46 exit(-1);
47 }
48
49 Manager manager(bus, mode);
50
51 //Init mode will just set fans to max and delay
52 if (mode == Manager::Mode::init)
53 {
54 manager.doInit();
55 return 0;
56 }
Matt Spinlere10416e2017-04-10 14:15:53 -050057
Matt Spinlere73446e2017-04-10 13:55:52 -050058 while (true)
59 {
60 bus.process_discard();
61 bus.wait();
62 }
63
64 return 0;
65}