1 /**
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>
17 #include "argument.hpp"
18 #include "manager.hpp"
19 
20 using namespace phosphor::fan::control;
21 
22 int main(int argc, char* argv[])
23 {
24     auto bus = sdbusplus::bus::new_default();
25     phosphor::fan::util::ArgumentParser args(argc, argv);
26 
27     if (argc != 2)
28     {
29         args.usage(argv);
30         exit(-1);
31     }
32 
33     Mode mode;
34 
35     if (args["init"] == "true")
36     {
37         mode = Mode::init;
38     }
39     else if (args["control"] == "true")
40     {
41         mode = 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 == Mode::init)
53     {
54         manager.doInit();
55         return 0;
56     }
57 
58     while (true)
59     {
60         bus.process_discard();
61         bus.wait();
62     }
63 
64     return 0;
65 }
66