RDK Documentation (Open Sourced RDK Components)
main.cpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 /**
22 * @defgroup trm
23 * @{
24 * @defgroup qtapp
25 * @{
26 **/
27 
28 
29 #include <QApplication>
30 #include <QDialog>
31 #include <QPainter>
32 #include <QDebug>
33 #include "TRMMonitorGUI.h"
34 
35 using namespace TRM;
36 
37 int main(int argc, char *argv[])
38 {
39  QApplication app(argc, argv);
40  QStringList args = app.arguments();
41 
42  int portNumber= -1;
43  QString hostAddressStr;
44  QString clientId;
45  QString barWidth;
46 
47  QRegExp optionPort("-port");
48  QRegExp optionIP("-ip");
49  QRegExp optionClientId("-clientId");
50  QRegExp optionBarWidth("-barWidth");
51 
52 
53  for (int i = 1; i < args.size(); ++i) {
54 
55  if (optionPort.indexIn(args.at(i)) != -1 ) {
56  portNumber= args.at(i+1).toInt();
57  ++i;
58  qDebug() << "port is " << portNumber;
59  }
60  else if (optionIP.indexIn(args.at(i)) != -1 ) {
61  hostAddressStr = args.at(i+1);
62  ++i;
63  qDebug() << "ip is " << hostAddressStr;
64  }
65  else if (optionClientId.indexIn(args.at(i)) != -1 ) {
66  clientId = args.at(i+1);
67  ++i;
68  qDebug() << "clientId is " << clientId;
69  }
70  else if (optionBarWidth.indexIn(args.at(i)) != -1 ) {
71  barWidth = args.at(i+1);
72  ++i;
73  qDebug() << "barWidth is " << barWidth;
74  }
75  else {
76  }
77  }
78 
79  if (portNumber < 0 || portNumber > 65535 || hostAddressStr.isEmpty()) {
80  printf("\r\n%s: <ip address> <port number> <clientName> <barWidth> \r\n", args.at(0).toUtf8().data());
81  exit(0);
82  }
83 
84  if (clientId.isEmpty()) clientId = "FFFFF001";
85  if (barWidth.isEmpty()) barWidth = "3600";
86 
87  TRMMonitorGUI monitorGUI(QHostAddress(hostAddressStr), portNumber, clientId, barWidth);
88  monitorGUI.show();
89  return app.exec();
90 }
91 
92 
93 /** @} */
94 /** @} */
TRM::TRMMonitorGUI
Definition: TRMMonitorGUI.h:46