2022-01-12 14:30:11 +08:00
# include <QCoreApplication>
# include <QDebug>
# include<VSMD12XControl.h>
# include "qtextstream.h"
QTextStream cout1 ( stdout , QIODevice : : WriteOnly ) ;
void logout ( QString str ) {
std : : cout < < str . toStdString ( ) < < " <br> " ;
std : : fflush ( stdout ) ;
}
int main ( int argc , char * argv [ ] ) {
int aaa = 1000 ;
QString str ( argv [ 1 ] ) ;
QCoreApplication a ( argc , argv ) ;
CVSMD12XControl Motercontrol ;
QString m_qstrDeviceConfigFilePath ;
// cout1<<"adfasdfsadfsd"<<flush;
cout1 < < " Your position number is " < < str < < " <br> " < < flush ;
# ifdef WIN32
m_qstrDeviceConfigFilePath = ( " D: \\ 03MyGit \\ linux \\ movingliner \\ DeviceSettings.ini " ) ;
# else
m_qstrDeviceConfigFilePath = ( " /home/data/Setting/DeviceSettings.ini " ) ;
# endif
QSettings * m_qsDeviceConfig ;
m_qsDeviceConfig = new QSettings ( m_qstrDeviceConfigFilePath , QSettings : : IniFormat ) ;
long positon = m_qsDeviceConfig - > value ( " LINEAR SHUTTER/Position " + str ) . toLongLong ( ) ;
if ( positon = = 0 )
{
logout ( " <b style= \" color:red \" >Can not Find the position< \ /b> " ) ;
return 0 ;
}
cout1 < < " Find Configfile in " < < m_qstrDeviceConfigFilePath < < " <br> The Port of Motor is " < < m_qsDeviceConfig - > value ( " LINEAR SHUTTER/Port " ) . toString ( ) < < " <br> " < < flush ;
cout1 < < " Position Find Value is " < < m_qsDeviceConfig - > value ( " LINEAR SHUTTER/Position " + str ) . toLongLong ( ) < < " <br> " < < flush ;
cout1 < < " Configing The Motor <br> " < < flush ;
// m_qsDeviceConfig->value("LINEAR SHUTTER/Port").toString()
2022-05-06 10:15:59 +08:00
if ( m_qsDeviceConfig - > value ( " LINEAR SHUTTER/Port " ) . toString ( ) = = " GPIO " )
{
int positionnumber = m_qsDeviceConfig - > value ( " LINEAR SHUTTER/TotalPosition " ) . toInt ( ) ;
if ( str > = positionnumber )
{
cout1 < < " ERROR number position " < < flush ;
}
int targetpos = m_qsDeviceConfig - > value ( " LINEAR SHUTTER/Position " + str ) . toLongLong ( ) ;
for ( int ii = 0 ; ii < positionnumber ; + + ii ) {
int tempgpio = m_qsDeviceConfig - > value ( " LINEAR SHUTTER/Position " + QString : : number ( ii ) ) . toInt ( ) ;
QString com = " gpio mode " + QString : : number ( tempgpio ) + " out " ;
system ( com . toStdString ( ) . c_str ( ) ) ;
com = " gpio write " + QString : : number ( tempgpio ) + " 0 " ;
system ( com . toStdString ( ) . c_str ( ) ) ;
}
QThread : : sleep ( 500 ) ;
QString com = " gpio write " + QString : : number ( targetpos ) + " 1 " ;
system ( com . toStdString ( ) . c_str ( ) ) ;
QThread : : sleep ( 500 ) ;
cout1 < < " FINISH Change Shutter <br> " < < flush ;
return 0 ;
}
2022-01-12 14:30:11 +08:00
Motercontrol . ILMES_InitializeComm ( m_qsDeviceConfig - > value ( " LINEAR SHUTTER/Port " ) . toString ( ) ) ;
ControllerParams cpTest ;
Motercontrol . ILMES_InitializeParams ( cpTest ) ;
logout ( " Moving to Zero " ) ;
Motercontrol . StartBackZero ( ) ;
//std::cout<<"beging to move position";
logout ( " Moving to The Position " ) ;
Motercontrol . MoveTo ( positon ) ;
logout ( " <b style= \" color:green \" >Finish the Task!!!< \ /b> <br><b>Thanks For Using< \ /b> " ) ;
return 0 ;
// return QCoreApplication::exec();
}