[Armadeus-commitlog] SF.net SVN: armadeus:[1240] trunk/software/demos/ApfDacClientServer/src
Brought to you by:
sszy
|
From: <ar...@us...> - 2009-04-28 17:20:28
|
Revision: 1240
http://armadeus.svn.sourceforge.net/armadeus/?rev=1240&view=rev
Author: artemys
Date: 2009-04-28 17:20:22 +0000 (Tue, 28 Apr 2009)
Log Message:
-----------
[DEMOS] Makes Qt demo sexier
Modified Paths:
--------------
trunk/software/demos/ApfDacClientServer/src/Client/ApfClient.cpp
trunk/software/demos/ApfDacClientServer/src/Client/ApfClient.h
trunk/software/demos/ApfDacClientServer/src/Client/ApfClientMain.cpp
trunk/software/demos/ApfDacClientServer/src/Client/ApfHostSelectDialog.ui
trunk/software/demos/ApfDacClientServer/src/Client/Vmeters.ui
trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkDefs.h
trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkOperation.cpp
trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkOperation.h
trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkProtocol.cpp
trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkProtocol.h
trunk/software/demos/ApfDacClientServer/src/Server/ApfCore.cpp
trunk/software/demos/ApfDacClientServer/src/Server/ApfCore.h
trunk/software/demos/ApfDacClientServer/src/Server/ApfDacController.cpp
trunk/software/demos/ApfDacClientServer/src/Server/ApfServer.cpp
trunk/software/demos/ApfDacClientServer/src/Server/ApfServer.h
trunk/software/demos/ApfDacClientServer/src/Server/ApfServerListener.cpp
trunk/software/demos/ApfDacClientServer/src/Server/ApfServerMain.cpp
trunk/software/demos/ApfDacClientServer/src/Server/Server.pro
trunk/software/demos/ApfDacClientServer/src/build.sh
Added Paths:
-----------
trunk/software/demos/ApfDacClientServer/src/Server/ApfServerTabDialog.ui
trunk/software/demos/ApfDacClientServer/src/widgets/
trunk/software/demos/ApfDacClientServer/src/widgets/README
trunk/software/demos/ApfDacClientServer/src/widgets/abstractmeter.cpp
trunk/software/demos/ApfDacClientServer/src/widgets/abstractmeter.h
trunk/software/demos/ApfDacClientServer/src/widgets/functions.h
trunk/software/demos/ApfDacClientServer/src/widgets/manometer.cpp
trunk/software/demos/ApfDacClientServer/src/widgets/manometer.h
trunk/software/demos/ApfDacClientServer/src/widgets/qled.cpp
trunk/software/demos/ApfDacClientServer/src/widgets/qled.h
trunk/software/demos/ApfDacClientServer/src/widgets/qslide.cpp
trunk/software/demos/ApfDacClientServer/src/widgets/qslide.h
trunk/software/demos/ApfDacClientServer/src/widgets/thermometer.cpp
trunk/software/demos/ApfDacClientServer/src/widgets/thermometer.h
trunk/software/demos/ApfDacClientServer/src/widgets/widgets.pro
trunk/software/demos/ApfDacClientServer/src/widgets/widgetwithbackground.cpp
trunk/software/demos/ApfDacClientServer/src/widgets/widgetwithbackground.h
Property Changed:
----------------
trunk/software/demos/ApfDacClientServer/src/build.sh
Modified: trunk/software/demos/ApfDacClientServer/src/Client/ApfClient.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Client/ApfClient.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Client/ApfClient.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -23,10 +23,10 @@
*/
-#include <iostream>
+#include <iostream>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <QMessageBox>
@@ -60,8 +60,8 @@
setupUi(this);
rightDacControl->setRange(MIN_DAC,MAX_DAC);
leftDacControl->setRange(MIN_DAC,MAX_DAC);
- mPreviousLeft=-1;
- mPreviousRight =-1;
+ mPreviousLeft = -1;
+ mPreviousRight = -1;
connect(&mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this,SLOT(displayError(QAbstractSocket::SocketError)));
connect(&mSocket, SIGNAL(readyRead()), this, SLOT(readData()));
@@ -71,28 +71,29 @@
// connect(rightDacControl, SIGNAL( valueChanged (int ) ), this, SLOT(setRightDac(int )));
// connect(leftDacControl, SIGNAL( valueChanged (int ) ), this, SLOT(setLeftDac(int )));
connect(cancelButton, SIGNAL( clicked ( ) ), this, SLOT(userClose( )));
+ connect(greenLEDBox, SIGNAL(stateChanged(int)), this, SLOT(greenLEDChanged(int)));
+ connect(redLEDBox, SIGNAL(stateChanged(int)), this, SLOT(redLEDChanged(int)));
+ connect(lcdButton, SIGNAL(released()), this, SLOT(updateLCDText()));
show();
mSocket.connectToHost(mHost,mPort);
//if ( mSocket.state() == QAbstractSocket::ConnectedState )
mApfNetworkProtocol = new ApfNetworkProtocol( & mSocket );
+}
-
-
-}
//******************************************************************************
void ApfClient::readData()
{
- qDebug("Read data");
+ qDebug("Read data");
}
//******************************************************************************
void ApfClient::initConnection()
{
- qDebug("Connected");
+ qDebug("Connected");
ApfNetworkOperation NetworkOperation(ApfNetworkProtocol::OpVersionRequest, QString(""));
mApfNetworkProtocol->request( &NetworkOperation );
@@ -103,7 +104,7 @@
void ApfClient::endPeerConnection()
{
- qDebug("Disconnected");
+ qDebug("Disconnected");
if (mSocket.state() == QAbstractSocket::UnconnectedState)
{
@@ -118,7 +119,7 @@
void ApfClient::userClose()
{
- qDebug("Disconnected");
+ qDebug("Disconnected");
disconnect(rightDacControl, SIGNAL( valueChanged (int ) ), this, SLOT(setRightDac(int )));
disconnect(leftDacControl, SIGNAL( valueChanged (int ) ), this, SLOT(setLeftDac(int )));
disconnect(&mSocket, SIGNAL(disconnected()), this, SLOT(endPeerConnection()));
@@ -130,7 +131,7 @@
void ApfClient::timeOut()
{
int value;
- if ( (cnt++%2) == 0)
+ if ((cnt++%2) == 0)
{
value = rightDacControl->value();
if (mPreviousRight != value) setRightDac(value);
@@ -164,9 +165,43 @@
//******************************************************************************
+void ApfClient::greenLEDChanged(int aState)
+{
+ bool state;
+
+ state = aState ? true : false;
+ setLED(0, state);
+}
+
+void ApfClient::redLEDChanged(int aState)
+{
+ bool state;
+
+ state = aState ? true : false;
+ setLED(1, state);
+}
+
+void ApfClient::setLED(int id, int state)
+{
+ ApfNetworkOperation NetworkOperation(ApfNetworkProtocol::OpLed, QString("").sprintf("%d,%d", id, state));
+ mApfNetworkProtocol->request(&NetworkOperation);
+ usleep(80000);
+}
+
+//******************************************************************************
+
+void ApfClient::updateLCDText(void)
+{
+ ApfNetworkOperation NetworkOperation(ApfNetworkProtocol::OpLcd, lcdLineEdit->text());
+ mApfNetworkProtocol->request(&NetworkOperation);
+ usleep(80000);
+}
+
+//******************************************************************************
+
void ApfClient::displayError(QAbstractSocket::SocketError err)
{
- switch (err)
+ switch (err)
{
case QAbstractSocket::RemoteHostClosedError:
break;
@@ -189,4 +224,3 @@
}
close();
}
-
Modified: trunk/software/demos/ApfDacClientServer/src/Client/ApfClient.h
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Client/ApfClient.h 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Client/ApfClient.h 2009-04-28 17:20:22 UTC (rev 1240)
@@ -43,30 +43,34 @@
public:
- ApfClient( QString host,int port=APF_SOCKET) ;
+ ApfClient( QString host,int port=APF_SOCKET) ;
- virtual ~ApfClient();
+ virtual ~ApfClient();
void run();
protected slots:
void readData();
- void displayError(QAbstractSocket::SocketError err);
+ void displayError(QAbstractSocket::SocketError err);
void setRightDac(int value);
void setLeftDac(int value);
void initConnection();
void endPeerConnection();
void userClose();
void timeOut();
+ void greenLEDChanged(int);
+ void redLEDChanged(int);
+ void setLED(int id, int state);
+ void updateLCDText();
protected:
QString mHost;
int mPort;
- QTcpSocket mSocket;
+ QTcpSocket mSocket;
QTimer mTimer;
int cnt;
int mPreviousLeft,mPreviousRight;
- ApfNetworkProtocol *mApfNetworkProtocol;
+ ApfNetworkProtocol *mApfNetworkProtocol;
};
#endif // __APFCLIENT_H_INCLUDED__
Modified: trunk/software/demos/ApfDacClientServer/src/Client/ApfClientMain.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Client/ApfClientMain.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Client/ApfClientMain.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -1,19 +1,15 @@
//
-// KmAtsMain.cpp
+// ApfClientMain.cpp
//
-// Copyright : (c) 2005 by Kontron Medical
+// Copyright : (c) 2007 Armadeus Project
//
-// Email : in...@ko...
//
-// main for ATS client
-
#include <iostream>
#include <qapplication.h>
#include "ApfHostChooser.h"
#include "ApfClient.h"
-//#include "KmAtsSettings.h"
int main(int argc, char **argv)
{
@@ -24,23 +20,21 @@
ApfHostChooser theApfHostChooser( &cancelled,hostUnderTest );
- theApfHostChooser.initialize();
- theApfHostChooser.show();
+ theApfHostChooser.initialize();
+ theApfHostChooser.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
a.exec();
if (cancelled == true)
{
qDebug("User has cancelled");
return 1;
- }
- else
- {
- ApfClient theApfClient(hostUnderTest);
+ } else {
+ ApfClient theApfClient(hostUnderTest);
- theApfClient.run();
+ theApfClient.run();
qDebug("Selected host: %s",hostUnderTest.toAscii().data());
- a.exec();
- return 0;
-
- }
+ a.exec();
+ return 0;
+ }
}
+
Modified: trunk/software/demos/ApfDacClientServer/src/Client/ApfHostSelectDialog.ui
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Client/ApfHostSelectDialog.ui 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Client/ApfHostSelectDialog.ui 2009-04-28 17:20:22 UTC (rev 1240)
@@ -130,6 +130,11 @@
</item>
<item>
<property name="text" >
+ <string>192.168.0.10</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
<string>192.168.2.30</string>
</property>
</item>
Modified: trunk/software/demos/ApfDacClientServer/src/Client/Vmeters.ui
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Client/Vmeters.ui 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Client/Vmeters.ui 2009-04-28 17:20:22 UTC (rev 1240)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>188</height>
+ <width>490</width>
+ <height>348</height>
</rect>
</property>
<property name="windowTitle" >
@@ -16,192 +16,302 @@
<property name="windowIcon" >
<iconset>../../../../apf/general/generalResources/iconsAndGraphics/armadeusIcon_50x50.png</iconset>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="0" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
+ <layout class="QVBoxLayout" >
+ <item>
+ <widget class="QFrame" name="frame_3" >
+ <property name="frameShape" >
+ <enum>QFrame::StyledPanel</enum>
</property>
- <property name="spacing" >
- <number>6</number>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
</property>
- <item>
- <widget class="QFrame" name="frame" >
- <property name="frameShape" >
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
+ <layout class="QVBoxLayout" >
+ <item>
+ <widget class="QLineEdit" name="lcdLineEdit" />
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="lcdButton" >
+ <property name="text" >
+ <string>Update</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QFrame" name="frame_2" >
+ <property name="frameShape" >
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="QCheckBox" name="redLEDBox" >
+ <property name="text" >
+ <string>Red LED</string>
</property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="greenLEDBox" >
+ <property name="text" >
+ <string>Green LED</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QFrame" name="frame" >
+ <property name="frameShape" >
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="leftMargin" >
+ <number>9</number>
+ </property>
+ <property name="topMargin" >
+ <number>9</number>
+ </property>
+ <property name="rightMargin" >
+ <number>9</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>9</number>
+ </property>
+ <property name="horizontalSpacing" >
+ <number>6</number>
+ </property>
+ <property name="verticalSpacing" >
+ <number>6</number>
+ </property>
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
- <item row="0" column="0" >
- <layout class="QHBoxLayout" >
- <property name="margin" >
+ <property name="leftMargin" >
+ <number>0</number>
+ </property>
+ <property name="topMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <property name="leftMargin" >
<number>0</number>
</property>
+ <property name="topMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::RichText</enum>
+ </property>
+ <property name="pixmap" >
+ <pixmap/>
+ </property>
+ <property name="scaledContents" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="leftDacControl" >
+ <property name="value" >
+ <number>0</number>
+ </property>
+ <property name="sliderPosition" >
+ <number>0</number>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="invertedAppearance" >
+ <bool>false</bool>
+ </property>
+ <property name="invertedControls" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Sans Serif; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Left Vmeter</p></body></html></string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
+ <property name="leftMargin" >
+ <number>0</number>
+ </property>
+ <property name="topMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>0</number>
+ </property>
<item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
+ <widget class="QLabel" name="label_4" >
+ <property name="autoFillBackground" >
+ <bool>true</bool>
</property>
- <property name="spacing" >
- <number>6</number>
+ <property name="text" >
+ <string/>
</property>
- <item>
- <widget class="QLabel" name="label_3" >
- <property name="text" >
- <string/>
- </property>
- <property name="textFormat" >
- <enum>Qt::RichText</enum>
- </property>
- <property name="pixmap" >
- <pixmap>vmeter.png</pixmap>
- </property>
- <property name="scaledContents" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSlider" name="leftDacControl" >
- <property name="value" >
- <number>0</number>
- </property>
- <property name="sliderPosition" >
- <number>0</number>
- </property>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="invertedAppearance" >
- <bool>false</bool>
- </property>
- <property name="invertedControls" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Sans Serif; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Left Vmeter</p></body></html></string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
+ <property name="pixmap" >
+ <pixmap/>
+ </property>
+ <property name="scaledContents" >
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
<item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
+ <widget class="QSlider" name="rightDacControl" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
</property>
- <property name="spacing" >
- <number>6</number>
+ <property name="tickPosition" >
+ <enum>QSlider::NoTicks</enum>
</property>
- <item>
- <widget class="QLabel" name="label_4" >
- <property name="autoFillBackground" >
- <bool>true</bool>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="pixmap" >
- <pixmap>vmeter.png</pixmap>
- </property>
- <property name="scaledContents" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSlider" name="rightDacControl" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="tickPosition" >
- <enum>QSlider::NoTicks</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Sans Serif; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Right Vmeter</p></body></html></string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
+ </widget>
</item>
+ <item>
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Sans Serif; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Right Vmeter</p></body></html></string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
</layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <property name="leftMargin" >
+ <number>0</number>
+ </property>
+ <property name="topMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>0</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>71</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="text" >
+ <string>Close</string>
+ </property>
</widget>
</item>
<item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
</property>
- <property name="spacing" >
- <number>6</number>
+ <property name="sizeHint" >
+ <size>
+ <width>71</width>
+ <height>31</height>
+ </size>
</property>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>71</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="cancelButton" >
- <property name="text" >
- <string>Close</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>71</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ </spacer>
</item>
</layout>
</item>
Modified: trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkDefs.h
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkDefs.h 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkDefs.h 2009-04-28 17:20:22 UTC (rev 1240)
@@ -27,15 +27,13 @@
#define __APFNETWORKDEFS_H_INCLUDED__
-
namespace ApfNetworkDefs
{
// The Dynamic and/or Private Ports are those from 49152 through 65535
static const unsigned int APF_SOCKET = 50154; //why not ?
- static const unsigned int DATASTREAM_RELEASE = 5;
- static const int MIN_DAC = 0;
- static const int MAX_DAC = 32;
-
+ static const unsigned int DATASTREAM_RELEASE = 5;
+ static const int MIN_DAC = 0;
+ static const int MAX_DAC = 32;
}
-#endif // __APFNETWORKDEFS_H_INCLUDED__
+#endif // __APFNETWORKDEFS_H_INCLUDED__
Modified: trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkOperation.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkOperation.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkOperation.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -30,27 +30,25 @@
ApfNetworkOperation::ApfNetworkOperation( ApfNetworkProtocol::Operation operation,
const QString &arg0, const QString &arg1, const QString &arg2 )
{
- mOperation = operation ;
+ mOperation = operation;
setArg(0, arg0);
setArg(1, arg1);
setArg(2, arg2);
- setState (ApfNetworkProtocol::StWaiting) ;
+ setState (ApfNetworkProtocol::StWaiting);
setErrorCode(ApfNetworkProtocol::NoError);
-
}
ApfNetworkOperation::ApfNetworkOperation( ApfNetworkProtocol::Operation operation,
const QByteArray &arg0, const QByteArray &arg1, const QByteArray &arg2 )
{
- mOperation = operation ;
+ mOperation = operation;
setRawArg(0, arg0);
setRawArg(1, arg1);
setRawArg(2, arg2);
- setState (ApfNetworkProtocol::StWaiting) ;
+ setState (ApfNetworkProtocol::StWaiting);
setErrorCode(ApfNetworkProtocol::NoError);
+}
-}
-
//*****************************************************************************
ApfNetworkOperation::~ApfNetworkOperation()
@@ -75,7 +73,7 @@
void ApfNetworkOperation::setArg( int num, const QString &arg )
{
- if ( num < 3)
+ if (num < 3)
{
mArg[num] = arg;
}
@@ -85,7 +83,7 @@
void ApfNetworkOperation::setRawArg( int num, const QByteArray &arg )
{
- if ( num < 3)
+ if (num < 3)
{
mRawArg[num] = arg;
mRawArg[num].detach();
@@ -96,23 +94,23 @@
void ApfNetworkOperation::appendRawArg( int num, const QByteArray &arg )
{
- if ( num < 3)
+ if (num < 3)
{
- if ( true == mRawArg[num].isNull ())
+ if (true == mRawArg[num].isNull ())
{
- setRawArg(num,arg);
- mRawArg[num].detach();
+ setRawArg(num,arg);
+ mRawArg[num].detach();
}
else
- {
- int previousSize;
- previousSize = mRawArg[num].size();
- mRawArg[num].resize(previousSize + arg.size());
+ {
+ int previousSize;
+ previousSize = mRawArg[num].size();
+ mRawArg[num].resize(previousSize + arg.size());
memcpy (mRawArg[num].data()+ previousSize, arg.data(), arg.size());
}
}
}
-
+
//******************************************************************************
ApfNetworkProtocol::Operation ApfNetworkOperation::operation() const
@@ -124,7 +122,7 @@
QString ApfNetworkOperation::arg( int num ) const
{
- if ( num >2)
+ if (num > 2)
{
num = 0;
}
@@ -135,7 +133,7 @@
QByteArray ApfNetworkOperation::rawArg( int num ) const
{
- if ( num >2)
+ if (num > 2)
{
num = 0;
}
@@ -147,4 +145,3 @@
{
return mState;
}
-
Modified: trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkOperation.h
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkOperation.h 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkOperation.h 2009-04-28 17:20:22 UTC (rev 1240)
@@ -38,11 +38,10 @@
public:
ApfNetworkOperation( ApfNetworkProtocol::Operation operation,
- const QString &arg0, const QString &arg1=0, const QString &arg2=0 );
+ const QString &arg0, const QString &arg1=0, const QString &arg2=0 );
ApfNetworkOperation( ApfNetworkProtocol::Operation operation,
- const QByteArray &arg0, const QByteArray &arg1=0, const QByteArray &arg2=0 );
-
-
+ const QByteArray &arg0, const QByteArray &arg1=0, const QByteArray &arg2=0 );
+
virtual ~ApfNetworkOperation();
void setState( ApfNetworkProtocol::State state );
@@ -50,24 +49,24 @@
void setArg( int num, const QString &arg );
void setRawArg( int num, const QByteArray &arg );
void appendRawArg( int num, const QByteArray &arg );
-
+
ApfNetworkProtocol::Operation operation() const;
ApfNetworkProtocol::State state() const;
QString arg( int num ) const;
QByteArray rawArg( int num ) const;
-
+
private:
protected:
friend class ApfNetworkProtocol;
-
+
ApfNetworkProtocol::Operation mOperation;
ApfNetworkProtocol::State mState;
ApfNetworkProtocol::Error mErrorCode;
QString mArg[3];
QByteArray mRawArg[3];
-
+
};
#endif // __APFNETWORKOPERATION_H_INCLUDED__
Modified: trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkProtocol.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkProtocol.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkProtocol.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -20,8 +20,9 @@
** ApfNetworkProtocol.cpp
**
** author: ca...@us...
-*/
+*/
+#include <iostream>
#include <unistd.h>
#include "ApfNetworkProtocol.h"
@@ -33,8 +34,7 @@
mDevice(d)
{
mDataStream = new QDataStream(d);
- mDataStream->setVersion(ApfNetworkDefs::DATASTREAM_RELEASE); // Qt 3.1 and more
-
+ mDataStream->setVersion(ApfNetworkDefs::DATASTREAM_RELEASE); // Qt 3.1 and more
}
//******************************************************************************
@@ -44,17 +44,17 @@
delete mDataStream;
}
-//******************************************************************************
-
+//******************************************************************************
+
int ApfNetworkProtocol::request(ApfNetworkOperation *ApfNetworkOperation)
{
Q_CHECK_PTR(ApfNetworkOperation);
-
+
qint32 OP;
- Operation operation(ApfNetworkOperation->operation());
+ Operation operation(ApfNetworkOperation->operation());
OP = (qint32) operation;
- ApfNetworkOperation->setState(StInProgress);
+ ApfNetworkOperation->setState(StInProgress);
ApfNetworkOperation->setErrorCode(NoError);
switch (operation)
@@ -63,42 +63,47 @@
ApfNetworkOperation->setErrorCode(ErrUnsupported);
ApfNetworkOperation->setState(StFailed);
return 0;
+
case OpVersionRequest:
{
*mDataStream << OP;
}
break;
+
case OpDacLeft:
case OpDacRight:
case OpVersion:
+ case OpLed:
+ case OpLcd:
{
- *mDataStream << OP;
- *mDataStream << ApfNetworkOperation->mArg[0].toAscii().data();
+ *mDataStream << OP;
+ *mDataStream << ApfNetworkOperation->mArg[0].toAscii().data();
}
break;
-
- case OpNone:
+
+ case OpNone:
case OpPing:
break;
case OpExitStatus:
return 0;
- };
- if ( mDevice->waitForBytesWritten (10) == true)
+ }
+
+ if (mDevice->waitForBytesWritten(10) == true)
{
ApfNetworkOperation->setErrorCode(ErrIO);
- ApfNetworkOperation->setState(StFailed);
+ ApfNetworkOperation->setState(StFailed);
}
else
{
ApfNetworkOperation->setState(StDone);
}
- return (0);
-
+
+ return (0);
}
-//******************************************************************************
-
+//******************************************************************************
+
int ApfNetworkProtocol::readData(ApfNetworkOperation *ApfNetworkOperation)
{
Q_CHECK_PTR(ApfNetworkOperation);
@@ -106,10 +111,9 @@
qint32 OP;
Operation expectedOperation(ApfNetworkOperation->operation());
-
if (ApfNetworkOperation->mState != StInProgress)
{
- *mDataStream >> OP;
+ *mDataStream >> OP;
if ( (expectedOperation != (Operation) OP) && (ApfNetworkOperation->mState != StWaiting) )
{
qWarning("Expected operation and current operation are different: %d vs. %d", expectedOperation , (Operation)OP);
@@ -121,7 +125,7 @@
}
ApfNetworkOperation->mOperation = (Operation) OP;
ApfNetworkOperation->setErrorCode(NoError);
-
+
switch (OP)
{
default:
@@ -131,45 +135,45 @@
qDebug("WARNING: Unexpected operation received");
emit unexpectedCode();
return -1;
-
- case OpDacLeft:
- case OpDacRight:
+
+ case OpDacLeft:
+ case OpDacRight:
case OpVersion:
- {
- char * ptr =new char [mDevice->size()] ;
+ case OpLed:
+ case OpLcd:
+ {
+ char * ptr =new char [mDevice->size()];
*mDataStream >> ptr;
- ApfNetworkOperation->setArg(0,QString (ptr));
- ApfNetworkOperation->setState (StDone);
+ ApfNetworkOperation->setArg(0, QString (ptr));
+ ApfNetworkOperation->setState(StDone);
delete [] ptr;
}
break;
+
case OpVersionRequest:
- {
- ApfNetworkOperation->setState (StDone);
- }
+ ApfNetworkOperation->setState (StDone);
break;
-
- case OpNone:
- case OpPing:
+ case OpNone:
+ case OpPing:
break;
}
-
- if ( mDataStream->status () != QDataStream::Ok)
+
+ if (mDataStream->status () != QDataStream::Ok)
{
ApfNetworkOperation->setErrorCode(ErrIO);
ApfNetworkOperation->setState(StFailed);
qDebug ("The status is not Ok: %d\n",mDataStream->status ());
- return -1;
+ return -1;
}
- else if ( StDone== ApfNetworkOperation->state())
+ else if (StDone == ApfNetworkOperation->state())
{
emit finished();
}
- return (0);
+ return (0);
}
-//******************************************************************************
+//******************************************************************************
int ApfNetworkProtocol::getIOError()
{
Modified: trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkProtocol.h
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkProtocol.h 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Networking/ApfNetworkProtocol.h 2009-04-28 17:20:22 UTC (rev 1240)
@@ -32,32 +32,30 @@
#include <QIODevice>
#include <QDataStream>
-
-
#include "ApfNetworkDefs.h"
-
-
using namespace ApfNetworkDefs;
-
-class ApfNetworkOperation;
+class ApfNetworkOperation;
+
class ApfNetworkProtocol : public QObject
{
Q_OBJECT
-
+
public:
-
- typedef enum Operation
+
+ typedef enum Operation
{
OpNone=0, // no operation (or must be set by protocol)
OpVersion, // get ATS version (compatibility)
- OpVersionRequest, // request ATS version (compatibility)
+ OpVersionRequest, // request ATS version (compatibility)
OpPing, // check if remote is responding
- OpDacLeft, // upload a file
- OpDacRight, // upload a ATS data base file
+ OpDacLeft, // change left DAC value
+ OpDacRight, // change right DAC value
+ OpLed, // switch LEDs state
+ OpLcd, // show text on LCD
OpExitStatus // send process exit status
};
-
+
typedef enum State
{
StWaiting = 0,
@@ -65,18 +63,17 @@
StDone,
StFailed,
StStopped
-
};
+
typedef enum Error
{
// no error
NoError = 0,
ErrUnsupported, // unsupported operation
ErrIO // device error
-
};
-
+
ApfNetworkProtocol(QIODevice * d );
virtual ~ApfNetworkProtocol();
@@ -84,24 +81,19 @@
int request(ApfNetworkOperation *ApfNetworkOperation);
int getIOError(); // get error from last operation
int readData(ApfNetworkOperation *ApfNetworkOperation);
-
-signals:
+
+signals:
void finished();
void unexpectedCode();
void inProgress(int percentDone);
-
+
private:
-
protected:
-
QIODevice *mDevice;
QDataStream *mDataStream;
-
- int mIOError;
+ int mIOError;
};
-
#endif // __APFNETWORKPROTOCOL_H_INCLUDED__
-
Modified: trunk/software/demos/ApfDacClientServer/src/Server/ApfCore.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Server/ApfCore.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Server/ApfCore.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -34,27 +34,26 @@
//******************************************************************************
ApfCore::ApfCore(QTcpSocket *clientConnection, QObject *parent ,const char *):
-QTcpSocket( parent ), mApfCurrentOperation(0), mVersionTransfered(false),
+QTcpSocket( parent ), mApfCurrentOperation(0), mVersionTransfered(false),
mApfDacController( MIN_DAC, MAX_DAC, MIN_DAC, MAX_DAC)
{
- mSocket =clientConnection;
+ mSocket =clientConnection;
mApfNetworkProtocol = new ApfNetworkProtocol(mSocket);
- connect( mSocket, SIGNAL(disconnected()), SLOT(deleteLater()) );
- connect( mSocket, SIGNAL( readyRead()),this, SLOT(data()) );
- connect( mApfNetworkProtocol, SIGNAL( finished()),this, SLOT(exec()) );
- connect( mApfNetworkProtocol, SIGNAL( unexpectedCode()),this, SLOT(protocolError()) );
- QTimer::singleShot ( 10000, this, SLOT(protocolError()) ) ;
- mApfDacController.setbothDAC(MIN_DAC);
-
+ connect( mSocket, SIGNAL(disconnected()), SLOT(deleteLater()) );
+ connect( mSocket, SIGNAL( readyRead()),this, SLOT(data()) );
+ connect( mApfNetworkProtocol, SIGNAL( finished()),this, SLOT(exec()) );
+ connect( mApfNetworkProtocol, SIGNAL( unexpectedCode()),this, SLOT(protocolError()) );
+ QTimer::singleShot ( 10000, this, SLOT(protocolError()) );
+ mApfDacController.setbothDAC(MIN_DAC);
}
//******************************************************************************
ApfCore::~ApfCore()
{
- mApfDacController.setbothDAC(MIN_DAC);
- if ( 0!= mApfNetworkProtocol )
+ mApfDacController.setbothDAC(MIN_DAC);
+ if ( 0 != mApfNetworkProtocol )
{
delete mApfNetworkProtocol;
}
@@ -73,8 +72,8 @@
{
if (mVersionTransfered==false) // huummmm Hacker???
{
- close();
- deleteLater();
+ close();
+ deleteLater();
}
}
@@ -84,10 +83,9 @@
{
if ( mApfCurrentOperation == 0 )
{
- mApfCurrentOperation = new ApfNetworkOperation(ApfNetworkProtocol::OpNone,QString(""));
+ mApfCurrentOperation = new ApfNetworkOperation(ApfNetworkProtocol::OpNone,QString(""));
}
mApfNetworkProtocol->readData(mApfCurrentOperation);
-
}
//******************************************************************************
@@ -95,23 +93,34 @@
void ApfCore::exec()
{
mMessage = QString(tr("command received: "));
+
switch (mApfCurrentOperation->operation())
{
- default:
+ default:
mMessage += QString( tr("unknown operation\n") );
if (mVersionTransfered==false) // huummmm Hacker???
{
close();
}
break;
+
case ApfNetworkProtocol::OpVersionRequest :
- execVersion( mApfCurrentOperation);
- break;
+ execVersion(mApfCurrentOperation);
+ break;
+
case ApfNetworkProtocol::OpDacLeft :
case ApfNetworkProtocol::OpDacRight :
- execSetDac( mApfCurrentOperation);
- break;
- }
+ execSetDac(mApfCurrentOperation);
+ break;
+
+ case ApfNetworkProtocol::OpLed :
+ execSetLed(mApfCurrentOperation);
+ break;
+
+ case ApfNetworkProtocol::OpLcd :
+ execSetLcd(mApfCurrentOperation);
+ break;
+ }
emit logText(mMessage);
delete mApfCurrentOperation;
mApfCurrentOperation = 0;
@@ -120,36 +129,61 @@
//******************************************************************************
void ApfCore::execVersion(ApfNetworkOperation *)
-{
+{
mMessage += QString(tr("Get version\n"));
mVersionTransfered = true;
- ApfNetworkOperation VersionNetworkOperation(ApfNetworkProtocol::OpVersion,QString("1.0"));
+ ApfNetworkOperation VersionNetworkOperation(ApfNetworkProtocol::OpVersion,QString("1.0"));
mApfNetworkProtocol->request(&VersionNetworkOperation);
- if ( mApfDacController.isOpen() == false)
+ if (mApfDacController.isOpen() == false)
{
- mMessage += QString(tr("Warning: The i2c bus is not accessible"));
+ mMessage += QString(tr("Warning: The i2c bus is not accessible"));
}
else
{
- mMessage += QString(tr("Info: The i2c bus is accessible"));
+ mMessage += QString(tr("Info: The i2c bus is accessible"));
}
}
+
//******************************************************************************
void ApfCore::execSetDac(ApfNetworkOperation *ApfNetworkOperation)
{
QString value = ApfNetworkOperation->arg(0);
- int val = value.toInt();
+ int val = value.toInt();
if ( ApfNetworkOperation->operation() == ApfNetworkProtocol::OpDacLeft )
{
mMessage += QString(tr("Set left DAC operation : value = ")) + value;
mApfDacController.setLeftDAC(val);
+ emit setManometerValue(val * 10);
}
else
{
mMessage += QString(tr("Set right DAC operation : value = ")) + value;
mApfDacController.setRightDAC(val);
+ emit setThermometerValue(val * 3);
}
}
+
+//******************************************************************************
+
+void ApfCore::execSetLed(ApfNetworkOperation *ApfNetworkOperation)
+{
+ QString arg = ApfNetworkOperation->arg(0);
+ QString led = arg.left(1);
+ QString state = arg.right(1);
+
+ mMessage += QString(tr("Set LED operation : value = ")) + led + " " + state;
+ emit setLedValue(led.toInt(), (state.toInt() ? true : false));
+}
+
+//******************************************************************************
+
+void ApfCore::execSetLcd(ApfNetworkOperation *ApfNetworkOperation)
+{
+ QString text = ApfNetworkOperation->arg(0);
+
+ mMessage += QString(tr("Set LCD text : ")) + text;
+ emit updateText(text);
+}
Modified: trunk/software/demos/ApfDacClientServer/src/Server/ApfCore.h
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Server/ApfCore.h 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Server/ApfCore.h 2009-04-28 17:20:22 UTC (rev 1240)
@@ -36,10 +36,10 @@
class ApfCore : public QTcpSocket
{
Q_OBJECT
-
+
public:
- ApfCore(QTcpSocket *clientConnection, QObject *parent=0, const char *name=0 );
+ ApfCore(QTcpSocket *clientConnection, QObject *parent=0, const char *name=0);
virtual ~ApfCore();
@@ -48,26 +48,34 @@
// output debug messages
void logText( const QString& );
void ApfCoreFinished();
-
+ void setLedValue(int id, bool state);
+ void setManometerValue(int id);
+ void setThermometerValue(int id);
+ void updateText(const QString &);
+
public slots:
void exec();
void data();
void deleteLater();
- void protocolError();
+ void protocolError();
private:
-
QString mMessage;
-
+
protected:
ApfNetworkProtocol *mApfNetworkProtocol;
ApfNetworkOperation *mApfCurrentOperation;
bool mVersionTransfered;
- void execVersion(ApfNetworkOperation *ApfNetworkOperation);
- void execSetDac(ApfNetworkOperation *ApfNetworkOperation);
- QTcpSocket *mSocket;
- ApfDacController mApfDacController;
+
+ void execVersion(ApfNetworkOperation*);
+ void execSetDac(ApfNetworkOperation*);
+ void execSetLed(ApfNetworkOperation*);
+ void execSetLcd(ApfNetworkOperation*);
+
+ QTcpSocket *mSocket;
+ ApfDacController mApfDacController;
};
+
#endif // __APFCORE_H_INCLUDED__
Modified: trunk/software/demos/ApfDacClientServer/src/Server/ApfDacController.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Server/ApfDacController.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Server/ApfDacController.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -79,6 +79,7 @@
void ApfDacController::setLeftDAC(int value)
{
unsigned char buf[2];
+
if ( (mOpen==true) && (value>= mMinLeft) && (value <= mMaxLeft) )
{
value = (value * MAX5821M_MAX_DATA_VALUE) / (mMaxLeft-mMinLeft);
@@ -89,10 +90,9 @@
mDACOutput.command = MAX5821_LOAD_DAC_A_IN_REG_B ;
mDACOutput.data = value;
Build_extended_command( mPowerUpCommand, buf);
- write (mI2cBus, buf,2);
+ write (mI2cBus, buf,2);
Build_data_command(mDACOutput,buf);
- write (mI2cBus, buf,2);
-
+ write (mI2cBus, buf,2);
}
}
@@ -108,12 +108,12 @@
// printf("Set the right DAC : %d\n", value);
mPowerUpCommand.ctrlA = POWER_CTRL_UNSELECTED;
mPowerUpCommand.ctrlB = POWER_CTRL_SELECTED;
- mDACOutput.command = MAX5821_LOAD_DAC_B_IN_REG_A ;
+ mDACOutput.command = MAX5821_LOAD_DAC_B_IN_REG_A;
mDACOutput.data = value;
Build_extended_command( mPowerUpCommand, buf);
- write (mI2cBus, buf,2);
+ write (mI2cBus, buf,2);
Build_data_command(mDACOutput,buf);
- write (mI2cBus, buf,2);
+ write (mI2cBus, buf,2);
}
}
@@ -133,11 +133,10 @@
mDACOutput.command = MAX5821_LOAD_DAC_ALL_IN_UPDATE_ALL ;
mDACOutput.data = value;
Build_extended_command( mPowerUpCommand, buf);
- write (mI2cBus, buf,2);
+ write (mI2cBus, buf,2);
Build_data_command(mDACOutput,buf);
- write (mI2cBus, buf,2);
+ write (mI2cBus, buf,2);
}
-
}
//******************************************************************************
Modified: trunk/software/demos/ApfDacClientServer/src/Server/ApfServer.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Server/ApfServer.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Server/ApfServer.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -20,7 +20,7 @@
** ApfServer.cpp
**
** author: ca...@us...
-*/
+*/
#include <iostream>
@@ -49,32 +49,44 @@
//******************************************************************************
#ifndef NOSERVERGUI
-
-ApfServer::ApfServer(): QDialog(),mApfServerListener()
+ApfServer::ApfServer(): QDialog(), mApfServerListener()
#else
ApfServer::ApfServer() : mApfServerListener()
#endif
-
{
-
#ifndef NOSERVERGUI
- setupUi(this);
+ setupUi(this);
+ mRedLed = new QLed(tab_2);
+ mRedLed->setColor(QColor(200,0,0));
+ mGreenLed = new QLed(tab_2);
+ mGreenLed->setColor(QColor(0,200,0));
+ mSlide = new QSlide(tab_2);
+ mSlide->startTmr(true);
+ mManometer = new ManoMeter(tab_2);
+ mThermometer = new ThermoMeter(tab_2);
+ mWidgetsLayout = new QGridLayout(tab_2);
+ mWidgetsLayout->addWidget(mRedLed, 0, 0);
+ mWidgetsLayout->addWidget(mGreenLed, 2, 0);
+ QSpacerItem* spacerItem = new QSpacerItem(20, 80, QSizePolicy::Minimum, QSizePolicy::Expanding);
+ mWidgetsLayout->addItem(spacerItem, 1, 0);
+ mWidgetsLayout->addWidget(mManometer, 1, 1, 2, 1);
+ mWidgetsLayout->addWidget(mSlide, 0, 1);
+ mWidgetsLayout->addWidget(mThermometer, 0, 2, 3, 1);
#endif
mApfServerListener = new ApfServerListener(0);
- PutServerDebugMessage(QString("Starting Apf server"));
+ PutServerDebugMessage(QString("Starting Apf server"));
connect( mApfServerListener, SIGNAL( logText(const QString &) ), SLOT(PutServerDebugMessage(const QString &)) );
#ifndef NOSERVERGUI
connect( QuitButton, SIGNAL(clicked()), this, SLOT(EndServer()) );
- #endif
- gApfServer = this;
-
+#endif
+ gApfServer = this;
}
//******************************************************************************
ApfServer *ApfServer::getApfServerInstance()
{
- return gApfServer;
+ return gApfServer;
}
//******************************************************************************
@@ -82,43 +94,91 @@
void ApfServer::EndServer()
{
#ifndef NOSERVERGUI
- hide();
+ hide();
qApp->exit(0);
#else
- exit(0);
+ exit(0);
#endif
}
-
//******************************************************************************
ApfServer::~ApfServer()
{
- if ( 0 != mApfServerListener)
- {
+ if (0 != mApfServerListener)
+ {
delete mApfServerListener;
- }
+ }
}
//******************************************************************************
void ApfServer::PutServerDebugMessage(const char * str)
{
- PutServerDebugMessage (QString(str)) ;
+ PutServerDebugMessage (QString(str));
}
//******************************************************************************
void ApfServer::PutServerDebugMessage(const QString & str)
{
+#ifndef NOSERVERGUI
+ if (mTextEdit)
+ {
+ mTextEdit->append(str);
+ }
+#else
+ std::cout << str.toAscii().data() << std::endl;
+#endif
+}
+//******************************************************************************
+
+void ApfServer::setLedValue(int id, bool state)
+{
#ifndef NOSERVERGUI
-
- if (mTextEdit)
- {
- mTextEdit->append(str);
- }
+ if (id == 0)
+ {
+ mGreenLed->setValue(state);
+ }
+ else
+ {
+ mRedLed->setValue(state);
+ }
#else
- std::cout << str.toAscii().data() << std::endl;
+ std::cout << "Setting " << (id ? "Red" : "Green") << " LED to " << state << std::endl;
#endif
}
+
+//******************************************************************************
+
+void ApfServer::setManometerValue(int value)
+{
+#ifndef NOSERVERGUI
+ mManometer->setValue(value);
+#else
+ std::cout << "Setting Manometer to " << value << std::endl;
+#endif
+}
+
+//******************************************************************************
+
+void ApfServer::setThermometerValue(int value)
+{
+#ifndef NOSERVERGUI
+ mThermometer->setValue(value);
+#else
+ std::cout << "Setting Thermometer to " << value << std::endl;
+#endif
+}
+
+//******************************************************************************
+
+void ApfServer::setSlideText(const QString & atext)
+{
+#ifndef NOSERVERGUI
+ mSlide->setText(atext);
+#else
+ std::cout << "Setting LCD text to " << atext.toAscii().data() << std::endl;
+#endif
+}
Modified: trunk/software/demos/ApfDacClientServer/src/Server/ApfServer.h
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Server/ApfServer.h 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Server/ApfServer.h 2009-04-28 17:20:22 UTC (rev 1240)
@@ -1,4 +1,3 @@
-
/*
** THE ARMADEUS PROJECT
**
@@ -21,7 +20,7 @@
** ApfServer.h
**
** author: ca...@us...
-*/
+*/
#ifndef __APFSERVER_H_INCLUDED__
@@ -40,24 +39,28 @@
#ifndef NOSERVERGUI
#include <QDialog>
#include <qpushbutton.h>
-#include "ui_ApfServerDialog.h"
+#include "ui_ApfServerTabDialog.h"
+#include "../widgets/qled.h"
+#include "../widgets/manometer.h"
+#include "../widgets/thermometer.h"
+#include "../widgets/qslide.h"
#endif
class ApfServerListener;
-using namespace ApfNetworkDefs;
+using namespace ApfNetworkDefs;
#ifndef NOSERVERGUI
-class ApfServer : public QDialog , public Ui::ApfServerDialog
+class ApfServer : public QDialog, public Ui::ApfServerTabDialog
#else
class ApfServer : public QObject
#endif
{
Q_OBJECT
-
+
public:
- ApfServer( );
+ ApfServer( );
virtual ~ApfServer();
void PutServerDebugMessage(const char * str);
static ApfServer *getApfServerInstance();
@@ -66,7 +69,11 @@
void PutServerDebugMessage(const QString & str);
void EndServer();
-
+ void setLedValue(int id, bool);
+ void setManometerValue(int);
+ void setThermometerValue(int);
+ void setSlideText(const QString &);
+
private:
ApfServerListener *mApfServerListener;
@@ -77,6 +84,14 @@
protected:
static ApfServer * gApfServer;
+#ifndef NOSERVERGUI
+ QLed* mRedLed;
+ QLed* mGreenLed;
+ ManoMeter* mManometer;
+ ThermoMeter* mThermometer;
+ QGridLayout* mWidgetsLayout;
+ QSlide* mSlide;
+#endif
};
+
#endif // __APFSERVER_H_INCLUDED__
-
Modified: trunk/software/demos/ApfDacClientServer/src/Server/ApfServerListener.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Server/ApfServerListener.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Server/ApfServerListener.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -38,10 +38,10 @@
QTcpServer( parent ),mApfCore(0),mParent(parent)
{
connect( this, SIGNAL( newConnection() ),this, SLOT( newIncommingConnection() ) );
-
- bool ok= listen ( QHostAddress::Any, APF_SOCKET );
+
+ bool ok = listen(QHostAddress::Any, APF_SOCKET);
// bool ok =setSocketDescriptor (APF_SOCKET);
- if ( !ok )
+ if ( !ok )
{
qWarning("Failed to bind to port %d", APF_SOCKET);
exit(1);
@@ -56,42 +56,40 @@
//******************************************************************************
-void ApfServerListener::newIncommingConnection()
-
+void ApfServerListener::newIncommingConnection()
{
-
- emit logText(QString("").sprintf("Incoming connexion on port %d",APF_SOCKET));
+ emit logText(QString("").sprintf("Incoming connexion on port %d",APF_SOCKET));
if ( 0 == mApfCore )
{
QTcpSocket *clientConnection = this->nextPendingConnection();
-
- emit logText(QString("").sprintf("Starting the APF core"));
+
+ emit logText(QString("").sprintf("Starting the APF core"));
mApfCore = new ApfCore (clientConnection, this);
- connect( mApfCore, SIGNAL( logText(const QString &) ), ApfServer::getApfServerInstance() ,SLOT(PutServerDebugMessage(const QString &)) );
+ connect( mApfCore, SIGNAL( logText(const QString &) ), ApfServer::getApfServerInstance(),
+ SLOT(PutServerDebugMessage(const QString &)) );
connect( mApfCore, SIGNAL( ApfCoreFinished() ), SLOT( coreDestroyed() ) );
-
+ connect( mApfCore, SIGNAL(setLedValue(int, bool)), ApfServer::getApfServerInstance(), SLOT(setLedValue(int, bool)) );
+ connect( mApfCore, SIGNAL(setManometerValue(int)), ApfServer::getApfServerInstance(), SLOT(setManometerValue(int)) );
+ connect( mApfCore, SIGNAL(setThermometerValue(int)), ApfServer::getApfServerInstance(), SLOT(setThermometerValue(int)) );
+ connect( mApfCore, SIGNAL(updateText(const QString &)), ApfServer::getApfServerInstance(), SLOT(setSlideText(const QString &)) );
}
else
{
- emit logText(QString("").sprintf("APF core allready started. closing socket"));
+ emit logText(QString("").sprintf("APF core already started. closing socket"));
close();
}
-
}
//******************************************************************************
void ApfServerListener::coreDestroyed()
-
{
-
if ( 0 != mApfCore )
{
emit logText(QString("").sprintf("APF core stopped\n"));
delete mApfCore;
- mApfCore =0;
+ mApfCore = 0;
}
usleep(2000000);
}
-
Modified: trunk/software/demos/ApfDacClientServer/src/Server/ApfServerMain.cpp
===================================================================
--- trunk/software/demos/ApfDacClientServer/src/Server/ApfServerMain.cpp 2009-04-28 14:09:54 UTC (rev 1239)
+++ trunk/software/demos/ApfDacClientServer/src/Server/ApfServerMain.cpp 2009-04-28 17:20:22 UTC (rev 1240)
@@ -32,6 +32,9 @@
#ifndef NOSERVERGUI
#include <QApplication>
+# ifdef Q_WS_QWS
+#include <QWSServer>
+# endif
#else
#include <QCoreApplication>
#endif
@@ -42,32 +45,31 @@
//using namespace std;
-void runAsDaemon()
+void runAsDaemon()
{
+ int pid( fork());
- int pid( fork());
-
- if (pid < 0)
+ if (pid < 0)
{
exit(EXIT_FAILURE);
}
/* If we got a good PID, then
we can exit the parent process. */
- if (pid > 0)
+ if (pid > 0)
{
exit(EXIT_SUCCESS);
}
sleep(2);
umask(0);
int sid (setsid());
- if (sid < 0)
+ if (sid < 0)
{
/* Log the failure */
exit(EXIT_FAILURE);
- }
-
+ }
+
/* Change the current working directory */
- if ((chdir("/")) < 0)
+ if ((chdir("/")) < 0)
{
/* Log the failure */
exit(EXIT_FAILURE);
@@ -76,27 +78,31 @@
/* Close out the standar...
[truncated message content] |