1
////////////////////////////////////////////////////////////////////////////////
2
/*! @file Ludmil.cpp Людмил - прибор Русланы.
3
- Part of Rigaku_APRI - Research Assistant Plugin package.
4
- Uses RAGUI - Research Assistant Graphical User Interface.
5
- Uses QtGui v.4.6 - http://qt.nokia.com/
6
- Uses RANet - Research Assistant Net Library (based on ANSI C++).
7
- Copyright(C) 2010, Viktor E. Bursian, St.Petersburg, Russia.
8
Viktor.Bursian@mail.ioffe.ru
9
- Copyright(C) 2010, Dmitry K. Nelson, St.Petersburg, Russia.
10
D.Nelson@mail.ioffe.ru
11
*///////////////////////////////////////////////////////////////////////////////
14
#include "GeneralGUI.h"
15
#include <QMessageBox>
18
//------------------------------------------------------------------------------
20
DEFINE_CLASS_TAG(sLudmil)
22
//------------------------------------------------------------------ sLudmil ---
26
if( ! DeviceConfig.IsNULL() ){
27
DeviceConfig << attr("Speed",FldSpeed->currentIndex());
30
delete PhotonCounter; PhotonCounter=NULL;
35
sLudmil::sLudmil (sString DevicetId
38
:sUniScanner(DevicetId,DeviceCfg,WidgetCfg)
43
LblStepUnit = new QLabel(tr("degree"),ParamArea);
44
LblStepUnit->setObjectName("LblStepUnit");
45
ParamLayout->addWidget(LblStepUnit,Row-1,2,1,1);
47
LblSpeed = new QLabel(tr("Speed"),ParamArea);
48
LblSpeed->setObjectName("LblSpeed");
49
ParamLayout->addWidget(LblSpeed,Row,0,1,1);
50
FldSpeed = new QComboBox(ParamArea);
51
FldSpeed->setObjectName("FldSpeed");
52
FldSpeed->insertItem(0,"ASpeed");
53
FldSpeed->setCurrentIndex(0);
54
ParamLayout->addWidget(FldSpeed,Row,1,1,1);
55
LblSpeedUnit = new QLabel(tr("deg/min"),ParamArea);
56
LblSpeedUnit->setObjectName("LblSpeedUnit");
57
ParamLayout->addWidget(LblSpeedUnit,Row++,2,1,1);
58
for( int i = 0 ; i < 12 ; ++i )
61
if( ! DeviceConfig.IsNULL() ){
63
sPhysValueNode::sPtr R;
65
DeviceConfig |= attr("NumOFSpeeds",3);
66
I=DeviceConfig->GetAttr("NumOFSpeeds");
68
NumOfSpeeds = (int)(*I);
69
for (int Index = 1; Index < NumOfSpeeds; Index++ ) {
70
FldSpeed->insertItem(Index,"ASpeed");
72
DeviceConfig |= attr("Speed",FldSpeed->currentIndex());
73
I=DeviceConfig->GetAttr("Speed");
75
FldSpeed->setCurrentIndex((int)(*I));
77
sCluster::sPtr SpeedsConf;
79
DeviceConfig |= "Speeds";
80
SpeedsConf=DeviceConfig->GetAttr("Speeds");
81
if( SpeedsConf.IsCorrect() ){
82
for( int i = 0 ; i < NumOfSpeeds ; ++i ){
83
SpeedsConf |= attr(i+1,Speeds[i]);
84
R=SpeedsConf->GetAttr(i+1);
86
Speeds[i] = ((sPhysValue)(*R)).Value();
90
DeviceConfig |= attr("StartQuantum",StartQuantum);
91
R=DeviceConfig->GetAttr("StartQuantum");
93
StartQuantum = ((sPhysValue)(*R)).Value();
96
for (int Index = 0; Index < NumOfSpeeds; Index++ ) {
97
SS.setNum((double)Speeds[Index],'f',2);
98
FldSpeed->setItemText(Index,SS);
102
sTextNode::sPtr CounterId(DeviceConfig
103
->GetAttr("Counter"));
104
if( CounterId.IsCorrect() ){
105
PhotonCounter = dynamic_cast<psCounter_APRI_ML327>
106
(sDevice::CreateDevice(sString(*CounterId)));
108
connect(this,SIGNAL(ScanIsStarting()) ,this,SLOT(OnStartScan()));
109
connect(this,SIGNAL(ScanIsFinished()) ,this,SLOT(OnFinishScan()));
113
void sLudmil::Connect ()
115
if( DeviceState() == Offline ){
117
SetDeviceState(Warming);
118
PhotonCounter->Connect();
119
connect(PhotonCounter,SIGNAL(NowStandby()),this,SLOT(EnterStandby()));
120
connect(PhotonCounter,SIGNAL(NowOffline()),this,SLOT(ReportError()));
122
QMessageBox::critical(this
123
,sString2QString(DeviceIdentifier()+" failure.")
124
,tr("The counter driver has not been found. Check config.") );
129
void sLudmil::EnterStandby ()
131
disconnect(PhotonCounter,SIGNAL(NowStandby()),this,SLOT(EnterStandby()));
132
SetDeviceState(Standby);
135
void sLudmil::ReportError ()
137
QMessageBox::critical(this
138
,sString2QString(DeviceIdentifier()+" failure.")
140
+sString2QString(PhotonCounter->DeviceIdentifier())
141
+tr("' does not respond. Check connections.")
143
SetDeviceState(Offline);
146
void sLudmil::OnStartScan ()
148
if (PhotonCounter->CountIsStarted()) PhotonCounter->StopCount();
149
QMessageBox::information(this, tr("Start scanning")
150
,tr("Set the starting angle ")
151
+QString::number(From-StartQuantum/2,'g',5)
152
+tr(" and switch the motor on.")
154
int CountMultiple = round((Step / Speeds[FldSpeed->currentIndex()])*60*10);
155
if (CountMultiple < 1) CountMultiple = 1;
156
int TimePar = round((Step / Speeds[FldSpeed->currentIndex()])*60*100/CountMultiple);
157
//?? real RealStep = FldSpeed->value()*TimePar*CountMultiple/60/100;
158
connect(PhotonCounter,SIGNAL(NewData(real)),this,SLOT(AddNewPoint(real)));
159
PhotonCounter->StartScan(TimePar, CountMultiple);
160
qDebug() << "Scan started";
163
void sLudmil::OnFinishScan ()
165
PhotonCounter->StopCount();
166
disconnect(PhotonCounter,SIGNAL(NewData(real)),this,SLOT(AddNewPoint(real)));
167
QMessageBox::information(this, tr("Scanning is finished")
168
,tr("Switch off the motor.")
172
//------------------------------------------------------------------------------