blob: 413a4193f56ecb28128c1fc8ec6ea27b060b62d7 [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
Matthew Barth14184132017-05-19 14:37:30 -050033 Mode mode;
Matt Spinleree7f6422017-05-09 11:03:14 -050034
35 if (args["init"] == "true")
36 {
Matthew Barth14184132017-05-19 14:37:30 -050037 mode = Mode::init;
Matt Spinleree7f6422017-05-09 11:03:14 -050038 }
39 else if (args["control"] == "true")
40 {
Matthew Barth14184132017-05-19 14:37:30 -050041 mode = Mode::control;
Matt Spinleree7f6422017-05-09 11:03:14 -050042 }
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
Matthew Barth14184132017-05-19 14:37:30 -050052 if (mode == Mode::init)
Matt Spinleree7f6422017-05-09 11:03:14 -050053 {
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}