Exemplo n.º 1
0
// 连接
int Connect(const char *host, const char *serv, int nSecond) {
	struct sockaddr_in server;
	int SocketFd = -1;

	server.sin_family = AF_INET;
	server.sin_port = htons(atoi(serv));

    server.sin_addr.s_addr = inet_addr(host);
	if (server.sin_addr.s_addr == INADDR_NONE)
    {
        struct hostent *inhost = gethostbyname(host);
        if (inhost)
        {
			for (int i = 0; inhost->h_addr_list[i]; i++)
			{
				SocketFd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
				memcpy(&server.sin_addr, inhost->h_addr_list[i], inhost->h_length);
			    if (SocketFd >= 0)
				{
					if (nSecond > 0)
					{
						if (ConnectTimeOut(SocketFd, (struct sockaddr *)&server, sizeof(server), nSecond) == 0)
							break;
					}
					else
					{
						if (ReConnect(SocketFd, (struct sockaddr *)&server, sizeof(server)) == 0)
							break;
					}
				}
			    Close(SocketFd);
			} 
        }
		      
    }
	else
	{
		SocketFd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
		if (SocketFd >= 0)
		{
			if (nSecond > 0)
			{
				if (ConnectTimeOut(SocketFd, (struct sockaddr *)&server, sizeof(server), nSecond) < 0)
					Close(SocketFd);
			}
			else
			{
				if (ReConnect(SocketFd, (struct sockaddr *)&server, sizeof(server)) < 0)
					Close(SocketFd);
			}
		}
	}
	
	return SocketFd;
}
Exemplo n.º 2
0
BOOL CFtpFile::GetFile(TCHAR *RemotePath,TCHAR *LocalPath)
{
	
	if(!(m_isConnect && m_hConnect))
	{
		g_Datalog.Trace(LOGL_TOP,LOGT_WARNING, __TFILE__,__LINE__, _T("下载文件:%s失败,ftp未连接"),RemotePath);
		return FALSE;
	}
	BOOL bRet = FtpGetFile(m_hConnect, RemotePath,LocalPath , FALSE, 0, 1, 0);
	TCHAR buff[300]={0};	
	if(bRet == FALSE)
	{
		DWORD dwErr = GetLastError();
		switch(dwErr)
		{
		case ERROR_INTERNET_CONNECTION_ABORTED:	//网络中断
		case ERROR_INTERNET_CONNECTION_RESET:	//连接已经重置
		case ERROR_FILE_NOT_FOUND:			//文件未找到也要重新连接
			{
				_stprintf(buff,_T("FTP下载,连接已经重置 err=%d %s ,%s"),dwErr,RemotePath, LocalPath);
				g_Datalog.Trace(LOGL_TOP,LOGT_ERROR, __TFILE__,__LINE__, buff);
				ReConnect();	//失败就重新连接一次网络
			}
			break;

		default:
			{
				DWORD dwLastError = 0;
				DWORD dwLen = 512;
				TCHAR szErrMsg[512] = {0};
				InternetGetLastResponseInfo(&dwLastError, szErrMsg, &dwLen);
				_stprintf(buff,_T("FTP下载错误 err=%d, lasterr=%d :%s %s, %s"),dwErr, dwLastError, szErrMsg, RemotePath,LocalPath);
				g_Datalog.Trace(LOGL_TOP,LOGT_ERROR, __TFILE__,__LINE__, buff);

				ReConnect();
			}
			break;
		}

	}
	else
	{
		_stprintf(buff,_T("下载文件成功 %ls, %s"),RemotePath,LocalPath);
		g_Datalog.Trace(LOGL_TOP,LOGT_PROMPT, __TFILE__,__LINE__, buff);
	}

	return bRet;
}
Exemplo n.º 3
0
VirtScreen::VirtScreen(World * const world_, Player * const player_) :
		w(world_),
		player(player_)
{
	connect(w, SIGNAL(Notify(const QString &)),
		this, SLOT(Notify(const QString &)));
	connect(player, SIGNAL(Notify(const QString &)),
		this, SLOT(Notify(const QString &)));

	connect(w, SIGNAL(GetString(QString &)),
		this, SLOT(PassString(QString &)),
		Qt::DirectConnection);
	connect(player, SIGNAL(GetString(QString &)),
		this, SLOT(PassString(QString &)),
		Qt::DirectConnection);

	connect(player, SIGNAL(Updated()),
		this, SLOT(UpdatePlayer()),
		Qt::DirectConnection);
	connect(w, SIGNAL(ReConnect()),
		this, SLOT(ConnectWorld()),
		Qt::DirectConnection);
	connect(w, SIGNAL(UpdatedAll()),
		this, SLOT(UpdateAll()),
		Qt::DirectConnection);
	connect(w, SIGNAL(Moved(const int)),
		this, SLOT(Move(const int)),
		Qt::DirectConnection);
	ConnectWorld();
	connect(w, SIGNAL(UpdatesEnded()),
		this, SLOT(UpdatesEnd()),
		Qt::DirectConnection);
}
Exemplo n.º 4
0
bool Redis::Get(string& key, string& value)
{
    
    redisReply* reply = NULL;

    log4cpp::Category& _logger = log4cpp::Category::getInstance("MAIN_LOG");
    
    reply = (redisReply*)redisCommand(connect_, "Get %s", key.c_str());

    if (!reply){
        ReConnect();

        reply = (redisReply*)redisCommand(connect_, "Get %s", key.c_str());
        if (!reply){
            _logger.error("Get key %s from redis error", key.c_str());
            return RESULT_ERROR;
        }
    }
    
    if (!reply->str){
        _logger.error("Get key %s from redis error: Not exsit!", key.c_str());
        freeReplyObject(reply);
        return RESULT_ERROR;
    }
    value = reply->str; 
    _logger.info("Get key %s from redis OK", key.c_str());

    freeReplyObject(reply);
    return RESULT_OK;
}
Exemplo n.º 5
0
int32 MysqlCon::ExcuteSql(const char* sql)
{
	if (false == CheckConnection())
	{
		std::cout << "ExcuteSql lost connection, sql = "<<sql << std::endl;
		return DB_ERR_CONN;
	}

	if (0 != mysql_query(m_mysql, sql))
	{
		uint32 err = mysql_errno(m_mysql);
		if (err == CR_SERVER_LOST || err == CR_SERVER_GONE_ERROR || err == CR_CONN_HOST_ERROR)
		{
			if (false == ReConnect())
			{
				std::cout << "ExcuteSql ReConnect failed, sql = "<<sql << std::endl;
				return DB_ERR_CONN;
			}

			if (0 != mysql_query(m_mysql, sql))
			{
				std::cout<< "err = "<<mysql_errno(m_mysql)<<", sql = "<<sql<<std::endl;
				return DB_ERR_UNKNOWN;
			}
		}
		else
		{
			std::cout<< "err = "<<mysql_errno(m_mysql)<<", sql = "<<sql<<std::endl;
			return DB_ERR_UNKNOWN;
		}
	}

	mysql_free_result(mysql_store_result(m_mysql));
	return (uint32)mysql_affected_rows(m_mysql);
}
Exemplo n.º 6
0
redisReply *ClusterRedis::redis_vCommand(const char *format, va_list ap)
{
    if (format == NULL || *format == '\0') return NULL;

    if (this->StatusCheck()) {
        return NULL;
    }
    redisReply *reply = NULL;
    va_list args;
    va_copy(args, ap);
    reply = (redisReply *)redisvCommand(_redisContext, format, args);
    if (!reply || reply->type == REDIS_REPLY_ERROR) {
        if (reply) {
            char buf[1024] = {0};
            va_copy(args, ap);
            vsnprintf(buf, 1024, format, args);
            logg("ERROR", "%s", buf);
        }
        FreeSources();
        if (ReConnect() < 0) return NULL;
        va_copy(args, ap);
        reply = (redisReply *)redisvCommand(_redisContext, format, args);
        return reply;
    }

    return reply;
}
Exemplo n.º 7
0
bool Redis::Set(string &key, string& value, int expiretime)
{
    redisReply* reply = NULL;

    log4cpp::Category& _logger = log4cpp::Category::getInstance("MAIN_LOG");
    
    reply = (redisReply*)redisCommand(connect_, "Set %s %s", key.c_str(), value.c_str());

    if (!reply){
        ReConnect();
        reply = (redisReply*)redisCommand(connect_, "Set %s %s", key.c_str(), value.c_str());
        if (!reply){
            _logger.error("Set key %s %s into redis error", key.c_str(),value.c_str());
            return RESULT_ERROR;
        }
    }

    _logger.info("Set key %s %s into redis OK", key.c_str(), value.c_str());

    freeReplyObject(reply);

    if(expiretime > 0){
        Expire(key, expiretime);
    }
    
    return RESULT_OK;
}
Exemplo n.º 8
0
bool Redis::Lrange(string &key, vector<string>& result)
{
    redisReply* reply = NULL;

    log4cpp::Category& _logger = log4cpp::Category::getInstance("MAIN_LOG");
    
    reply = (redisReply*)redisCommand(connect_, "Lrange %s %d %d", key.c_str(), 0, -1);


    if (!reply){
	    ReConnect();
	    reply = (redisReply*)redisCommand(connect_, "Lrange %s %d %d", key.c_str(), 0, -1);	
	    if(!reply){
		    _logger.error("get key %s from redis error", key.c_str());
		    return RESULT_ERROR;
	    }
    }

    if (reply->elements){
        for (unsigned int i = 0 ; i < reply->elements; i ++){
           result.push_back(reply->element[i]->str);    
        }
    }else{
        _logger.error("Lrange key %s from redis error, elements : %d", key.c_str(), reply->elements);
        return RESULT_ERROR;
    }
     
    _logger.info("Lrange key %s from redis OK, elements : %d", key.c_str(), reply->elements);
    freeReplyObject(reply);

    return RESULT_OK;
}
Exemplo n.º 9
0
DDEClient::DDEClient(HINSTANCE hInst, const char *server, const char *topic,
                     DDECALLBACK ClientCallBack, DWORD filters) :
                     DDE(hInst, server, topic, ClientCallBack, filters)
{
    if (!_bResult)              // if DDE construction failed
    {
        MessageBox(NULL, "Dde Construction failed",  "bugboard.exe", MB_OK | MB_ICONSTOP);
        return;
    }

    _timeout = _deftimeout = TIMEOUT_ASYNC;   // default to asynch trans

    ReConnect();                // ok, it's just "connect" this first time
}
Exemplo n.º 10
0
bool CNetConnector::Connect(INetClient *pNetClient, const char *pIP, unsigned short wPort)
{
	if (nullptr == pNetClient)
	{
		return false;
	}

	m_pNetClient = pNetClient;
	m_strRemoteIP = pIP;
	m_wRemotePort = wPort;

	ReConnect();
	
	return true;
}
Exemplo n.º 11
0
NetSpyThread::NetSpyThread(TCPNetClient *m_pNetClient)
{
    pClient=NULL;
    if(m_pNetClient!=NULL)
    pClient=m_pNetClient;
    m_bIsRunFlag=false;
    IsNetConnect = false;
    NetTimer = new QTimer;
    connect(pClient->Client,SIGNAL(error(QAbstractSocket::SocketError)),
            this,SLOT(displayerror(QAbstractSocket::SocketError))); //#显示错误
    connect(pClient->Client,SIGNAL(connected()),this,SLOT(NetConnected())); //#连接上时,发射connected()信号
    connect(pClient->Client,SIGNAL(disconnected()),this,SLOT(NetNotConnceted()));
    connect(this->NetTimer,SIGNAL(timeout()),this,SLOT(ReConnect()));
    connect(this,SIGNAL(NoDataReconnectSig()),this,SLOT(NoDataReconnectSlot()));


}
Exemplo n.º 12
0
// 에러 발생시 진단 정보를 출력해 준다.
void CQuery::PrintDiag(bool &bReconnect)
{
	int ii;
	SQLRETURN Ret;
	SQLINTEGER NativeError;
	SQLCHAR SqlState[6], Msg[255];
	SQLSMALLINT MsgLen;
	char str[256];

	ii=1;
	while (Ret=SQLGetDiagRec(SQL_HANDLE_STMT, hStmt, ii, SqlState, &NativeError, 
		Msg, sizeof(Msg), &MsgLen)!=SQL_NO_DATA) {
		wsprintf(str, "(2) SQLSTATE:%s, Diagnosis:%s",(LPCTSTR)SqlState,(LPCTSTR)Msg);
		//::MessageBox(NULL,str,"진단 정보",0);
		gWindow.PrintLog(str);
		//LogAdd(str);
		ii++;
		if(ii > 3) break;
	}

	// 오류가 통신 오류라면.. 다시 접속해 본다.
	if( strcmp((LPCTSTR)SqlState, "08S01") == 0 )
	{
		if(ReConnect() == 1) g_DelayHandler.IncreaseQuerySessionId();

		bReconnect = true;
	}
	// 복구 불가능한 에러가 발생한 경우 프로그램을 종료한다. 극단적 예외 처리가 불필요한
	// 경우는 이 코드를 주석 처리하거나 적당하게 다른 루틴으로 바꿔야 한다.
/*	if (ii > 1) {
		::MessageBox(NULL,"진단 정보가 출력되었습니다. 이 정보가 출력될 경우는 네트웍 끊김, DB 서버 중지 등의\r\n"
			"복구 불가능한 에러가 발생한 경우이며 프로그램 실행을 계속할 수 없습니다.\r\n"
			"에러를 수정하신 후 프로그램을 다시 실행해 주십시오.","Critical Error",MB_OK | MB_ICONERROR);

		// 다음 둘 중 하나를 선택할 것
		PostQuitMessage(0);
		// ExitProcess(0);
	}
*/
}
Exemplo n.º 13
0
/*=================================================================
* Function ID :  PostSend
* Input       :  char *pszBuffer, int nBufferSize, long nTimeOut
* Output      :  void
* Author      :  
* Date        :  2006  2
* Return	  :  TRUE 成功  FALSE 失败
* Description :  向服务端发送数据
* Notice	  :  pszBuffer 发送的数据   nBuffersize 发送的数据长度 
*			  :	 nTimeOut 等待时间
*					
*=================================================================*/
bool CComSmart::PostSend(char *pszBuffer, int nBufferSize, long nTimeOut)
{
	m_nWriteBytes = 0 ;
	
	ResetEvent(m_WriteOver.hEvent);
	
	m_WriteOver.Offset = 0 ;
	m_WriteOver.OffsetHigh = 0 ;
	
	DWORD nResult = WriteFile(m_handle, pszBuffer, (DWORD)nBufferSize, &m_nWriteBytes, &m_WriteOver);
	if( !m_nWriteBytes )
	{
		if( GetLastError() != ERROR_IO_PENDING )
		{
			sprintf(m_szErrorText,"向串口写数据错误[%ld]!", GetLastError());
			if( !ReConnect() ) return false;
			else return true;
		}
		else
		{
			if( WaitForSingleObject(m_WriteOver.hEvent, nTimeOut) != WAIT_OBJECT_0 )
			{
				sprintf(m_szErrorText,"向串口写数据错误,超时[%ld]!", GetLastError());
				return false;
			}
			
			m_nWriteBytes = 0 ;
			if( !GetOverlappedResult(m_handle, &m_WriteOver, &m_nWriteBytes, TRUE) )
			{
				DWORD dwLastError = GetLastError() ;
				if( dwLastError != ERROR_IO_INCOMPLETE )
				{
					sprintf(m_szErrorText,"向串口写数据错误,超时[%ld]!", GetLastError());
					return false;
				}
			}
		}
	}	
	return true;
}
Exemplo n.º 14
0
bool Redis::Delete(string &key)
{
    redisReply* reply = NULL;

    log4cpp::Category& _logger = log4cpp::Category::getInstance("MAIN_LOG");
    
    reply = (redisReply*)redisCommand(connect_, "del %s", key.c_str());

    if (!reply){
        ReConnect();

        reply = (redisReply*)redisCommand(connect_, "del %s", key.c_str());
        if (!reply){
            _logger.error("delete key %s from redis error", key.c_str());
            return RESULT_ERROR;
        }
    }

    _logger.info("delete key %s from redis OK", key.c_str());
    freeReplyObject(reply);
    return RESULT_OK;
}
Exemplo n.º 15
0
bool CRedisClient::TestOnline()
{
	m_locker->lock();
	std::string cmd = "PING";
	redisReply* pReply = (redisReply*)redisCommand( m_pRedisContext ,cmd.c_str() );
	if (pReply != NULL)
	{
		m_locker->unlock();
		freeReplyObject(pReply);
		pReply = NULL;
		return true;
	}
	else
	{//链接已经断开,开始重连计数,重连三次以后链接不上则认为此数据库已下线,将在client管理中进行剔除
		m_locker->unlock();
		if(ReConnect())
		{
			WLogInfo("CRedisClient::TestOnline::RedisClient Re Online! ip=%s, port=%d\n", m_address.c_str(), m_port);
			m_iReconnectCount = 0;
			return true;
		}
		else
		{
			m_iReconnectCount++;
			if (m_iReconnectCount > 3)
			{
				WLogError("CRedisClient::TestOnline::RedisClient Off! ip=%s, port=%d\n", m_address.c_str(), m_port);
				return false;
			}
			else
			{
				return true;
			}
		}
	}

	return false;
}
Exemplo n.º 16
0
bool Redis::Expire(string &key, int expiretime)
{
    redisReply* reply = NULL;

    log4cpp::Category& _logger = log4cpp::Category::getInstance("MAIN_LOG");
    
    reply = (redisReply*)redisCommand(connect_, "Expire %s %d", key.c_str(), expiretime);

    if (!reply){
        ReConnect();

        reply = (redisReply*)redisCommand(connect_, "Expire %s %d", key.c_str(), expiretime);
        if (!reply){
            _logger.error("Set key %s expire error", key.c_str());
            return RESULT_ERROR;
        }
    }

    _logger.info("Set key %s expire OK", key.c_str());

    freeReplyObject(reply);
    return RESULT_OK;
}
Exemplo n.º 17
0
void CQuery::PrintDiag()
{
	int ii;
	SQLRETURN Ret;
	SQLINTEGER NativeError;
	SQLCHAR SqlState[6], Msg[255];
	SQLSMALLINT MsgLen;
	char str[256];

	ii=1;
	while (Ret=SQLGetDiagRec(SQL_HANDLE_STMT, hStmt, ii, SqlState, &NativeError, 
		Msg, sizeof(Msg), &MsgLen)!=SQL_NO_DATA) {
		wsprintf(str, "SQLSTATE:%s, SQLSTRING:%s",(LPCTSTR)SqlState,(LPCTSTR)Msg);
		//::MessageBox(NULL,str,"진단 정보",0);
		g_Window.ServerLogAdd(S_TYPE,str);
		//LogAdd(str);
		ii++;
	}

	if( strcmp((LPCTSTR)SqlState, "08S01") == 0 )
	{
		ReConnect();
	}
}
Exemplo n.º 18
0
int32 MysqlCon::ExcuteSqlEx(const char* sql, MysqlRes& res)
{
	if (false == CheckConnection())
	{
		std::cout << "ExcuteSqlEx lost connection, sql = "<<sql << std::endl;
		return DB_ERR_CONN;
	}

	if (0 != mysql_query(m_mysql, sql))
	{
		uint32 err = mysql_errno(m_mysql);
		if (err == CR_SERVER_LOST || err == CR_SERVER_GONE_ERROR || err == CR_CONN_HOST_ERROR)
		{
			if (false == ReConnect())
			{
				std::cout << "ExcuteSqlEx ReConnect failed, sql = "<<sql << std::endl;
				return DB_ERR_CONN;
			}

			if (0 != mysql_query(m_mysql, sql))
			{
				std::cout<< "err = "<<mysql_errno(m_mysql)<<", sql = "<<sql<<std::endl;
				return DB_ERR_UNKNOWN;
			}
		}
		else
		{
			std::cout<< "err = "<<mysql_errno(m_mysql)<<", sql = "<<sql<<std::endl;
			return DB_ERR_UNKNOWN;
		}
	}

	if (res.m_res != NULL)
	{
		mysql_free_result(res.m_res);
	}

	res.m_res = mysql_store_result(m_mysql);
	if (NULL == res.m_res)
	{
		if (0 == mysql_field_count(m_mysql))
		{
			return DB_NO_RECORD;
		}
		else
		{
			return DB_ERR_UNKNOWN;
		}

		return DB_HAS_RECORD;
	}
	else
	{
		if (mysql_num_rows(res.m_res) != 0)
		{
			return DB_HAS_RECORD;
		}
		else
		{
			return DB_NO_RECORD;
		}
	}

	return DB_ERR_UNKNOWN;
}
Exemplo n.º 19
0
MainWindow::MainWindow( QString myname ) : QMainWindow()
{
  setupUi( this );

  MainTab->setCurrentIndex( 0 );
  RWDXMCenterF = false;
  DXMCenterFile = DXMCENTERFILE0;
  MCACanSaveAllOnMem = false;
  MCAPreAMPGainHasSet = false;
  MaxMCAEnergy = 20;
  MStabOk = false;
  MStabDelegate = "";

#if 0
  AutoShutter->setChecked( false );  // 自動シャッターのボタンはデフォルトでは
  AutoShutter->setEnabled( false );  // 使えなくしておく
#endif

  MCAFSel = scanFSel = monFSel = S2DFileSel
    = SelDFND = SelWBFND = SelRBFND = SelLFND = NULL;

  // Monitor の中で SSD の強度を別ファイルに書き出すときの時間を測るため
  T = new QTime;
  T->start();

  FSTATMsgs[0][0] = tr( "Both the name and the data is old." );
  FSTATMsgs[0][1] = tr( "The name is new, but the data is old." );
  FSTATMsgs[1][0] = tr( "The data is new, but the name is old." );
  FSTATMsgs[1][1] = tr( "The data and the name is new, but not saved." );
  MeasDataStat = MeasNameStat = OLD;
  ScanDataStat = ScanNameStat = OLD;
  MonDataStat = MonNameStat = OLD;
  MCADataStat = MCANameStat = OLD;
  S2DDataStat = S2DNameStat = OLD;

  isQXafsModeAvailable = false;

  XMAPk2p = new KeV2Pix;
  fdbase = new FluoDBase;
  u = new Units;

  MMainTh = NULL;
  MDTh1 = NULL;
  EncMainTh = NULL;
  Enc2 = NULL;
  SLS = NULL;
  SI0 = NULL;
  SI1 = NULL;
  SFluo = NULL;
  MMStab = NULL;

  oldDeg = -100;
  AllInited = MotorsInited = SensorsInited = false;
  EncOrPM = XENC;
  MCAGains.clear();
  MeasA = 0;
  OldDTh1 = 0;

  StatDisp = new Status();
  StatTab->layout()->addWidget( StatDisp );

  XAFSName = myname;
  XAFSKey = myname;
  XAFSTitle = myname;

  starsSV = new StarsSV2;
  conds = new Conditions;
  conds->setVersionInfo( VERSION, __DATE__, __TIME__ );
  alarms = new Alarms;
  connect( alarms, SIGNAL( alarmOn() ),
	   this, SLOT( alarmOn() ), Qt::UniqueConnection );
  connect( alarms, SIGNAL( alarmOff() ),
	   this, SLOT( alarmOff() ), Qt::UniqueConnection );
  
  setupLogArea();     // ログに対する書き出しがある可能性があるので最初にイニシャライズ
  ReadDef( DefFileName );
  remote = new AUnitRemote;
  connect( remote, SIGNAL( setMeasBlockF( bool ) ), MeasBlockB, SLOT( setChecked( bool ) ), Qt:: UniqueConnection );
  
  selmc = new SelMC2( mccd );
  setWindowTitle( XAFSTitle );
  s = new Stars;      // モータ類のイニシャライズの前に Stars の準備はしておく
  s->ReadStarsKeys( XAFSKey, XAFSName ); // Stars とのコネクション確立の準備
  s->SetNewSVAddress( starsSV->SSVAddress() );
  s->SetNewSVPort( starsSV->SSVPort() );
  connect( s, SIGNAL( EvAll( SMsg ) ), this, SLOT( RcvEvAll( SMsg ) ), Qt::UniqueConnection );

  TTable = new TuningTable;
  pmConds = new PMConditions;

  Initialize();
  setupView();
  setupCommonArea();
  setupSetupArea();     // AUnit 関係の Initialize 後でないとだめ
  if ( SFluo != NULL ) {
    setupSetupSSDArea();
  } else {
    MainTab->removeTab( MainTab->indexOf( SSDTab ) );
  }
  setupChangerArea();
  setupQXafsMode();
  setupMeasArea();
  setupReadDataArea();
  setupScan2DArea();
  setupWebView();
  setupAutoSequence();

  //  useFixedDelta = false;
  connect( conds, SIGNAL( SetDXMPMC() ), this, SLOT( SetDXMPMC() ),
	   Qt::UniqueConnection );

  StatDisp->setupStatArea( &AMotors, &ASensors, starsSV, selmc, conds, pmConds );

  connect( StatDisp, SIGNAL( NeedListNodes() ), this, SLOT( SendListNodes() ),
	   Qt::UniqueConnection );
  //  QString msg = "XafsMsg_" + QLocale::system().name();
  //  NewLogMsg( msg );
  NewLogMsg( QString( tr( "Mono: %1 (%2 A)" ) )
	     .arg( mccd[ selmc->MC() ]->getMCName() )
	     .arg( mccd[ selmc->MC() ]->getD() ) );

  connect( s, SIGNAL( AskShowStat( QString, int ) ),
	   this, SLOT( ShowMessageOnSBar( QString, int ) ),
	   Qt::UniqueConnection );
  connect( action_Quit, SIGNAL( triggered() ), qApp, SLOT( closeAllWindows() ),
	   Qt::UniqueConnection );
  //  connect( action_SelMC, SIGNAL( triggered() ), selmc, SLOT( show() ),
  //       Qt::UniqueConnection );
  connect( selmc, SIGNAL( NewLogMsg( QString ) ),
	   this, SLOT( NewLogMsg( QString ) ),
	   Qt::UniqueConnection );
  connect( selmc, SIGNAL( NewLatticeConstant( double ) ),
	   u, SLOT( setD( double ) ),
	   Qt::UniqueConnection );
  //  connect( action_SetSSV, SIGNAL( triggered() ), starsSV, SLOT( show() ),
  //           Qt::UniqueConnection );

  connect( starsSV, SIGNAL( SSVNewAddress( const QString & ) ),
	   s, SLOT( SetNewSVAddress( const QString & ) ),
	   Qt::UniqueConnection );
  connect( starsSV, SIGNAL( SSVNewPort( const QString & ) ),
	   s, SLOT( SetNewSVPort( const QString & ) ),
	   Qt::UniqueConnection );
  connect( s, SIGNAL( RecordSSVHistoryA( const QString & ) ),
	   starsSV, SLOT( RecordSSVHistoryA( const QString & ) ),
	   Qt::UniqueConnection );
  connect( s, SIGNAL( RecordSSVHistoryP( const QString & ) ),
	   starsSV, SLOT( RecordSSVHistoryP( const QString & ) ),
	   Qt::UniqueConnection );
  connect( starsSV, SIGNAL( AskReConnect() ), s, SLOT( ReConnect() ),
	   Qt::UniqueConnection );
  connect( s, SIGNAL( ReConnected() ), this, SLOT( InitializeUnitsAgain() ),
	   Qt::UniqueConnection );
  //  connect( starsSV, SIGNAL( accepted() ), s, SLOT( ReConnect() ),
  //           Qt::UniqueConnection );

  connect( s, SIGNAL( ConnectionIsReady( void ) ), this, SLOT( Initialize( void ) ),
	   Qt::UniqueConnection );
  connect( s, SIGNAL( AnsListNodes( SMsg ) ), this, SLOT( RcvListNodes( SMsg ) ),
	   Qt::UniqueConnection );
  connect( s, SIGNAL( EvConnected( SMsg ) ),
	   this, SLOT( SomeDrvIsConnected( SMsg ) ),
	   Qt::UniqueConnection );
  connect( s, SIGNAL( EvDisconnected( SMsg ) ),
	   this, SLOT( SomeDrvIsDisconnected( SMsg ) ),
	   Qt::UniqueConnection );

  if ( ! isQXafsModeAvailable ) {
    QXafsMode->setChecked( false );
    QXafsMode->setEnabled( false );
  }

  GoTimer = new QTimer;
  MCATimer = new QTimer;
  ScanTimer = new QTimer;
  MonTimer = new QTimer;
  MeasTimer = new QTimer;
  MeasDarkTimer = new QTimer;

  connect( GoTimer, SIGNAL( timeout() ), this, SLOT( MotorMove() ),
	   Qt::UniqueConnection );
  connect( MCATimer, SIGNAL( timeout() ), this, SLOT( MCASequence() ),
	   Qt::UniqueConnection );
  connect( ScanTimer, SIGNAL( timeout() ), this, SLOT( ScanSequence() ),
	   Qt::UniqueConnection );
  connect( MonTimer, SIGNAL( timeout() ), this, SLOT( MonSequence() ),
	   Qt::UniqueConnection );
  connect( MeasTimer, SIGNAL( timeout() ), this, SLOT( MeasSequence() ),
	   Qt::UniqueConnection );
  connect( MeasDarkTimer, SIGNAL( timeout() ), this, SLOT( MeasDarkSequence() ),
	   Qt::UniqueConnection );
  connect( s, SIGNAL( SSisActive( bool ) ), StatDisp, SLOT( SetSSVStat( bool ) ),
	   Qt::UniqueConnection );

  connect( AddNewDTh1TPoint, SIGNAL( clicked() ), this, SLOT( AddNewDTh1TunePoint() ),
	   Qt::UniqueConnection );
  connect( conds, SIGNAL( AskToSaveDTh1TTable() ), TTable, SLOT( SaveTuneTable() ),
	   Qt::UniqueConnection );
  connect( conds, SIGNAL( AskToShowDTh1TTable() ), TTable, SLOT( ShowTuneTable() ),
	   Qt::UniqueConnection );
  connect( conds, SIGNAL( NewDiff1( int ) ), this, SIGNAL( NewDiff1( int ) ),
	   Qt::UniqueConnection );
  connect( conds, SIGNAL( NewDiff2( int ) ), this, SIGNAL( NewDiff2( int ) ),
	   Qt::UniqueConnection );

  connect( Special, SIGNAL( clicked() ), this, SLOT( SpecialMove() ) );
  
  conds->setupDataRoot();      // 他のファイルダイアログが全部 new されていないとダメ !

  s->AskStatus();
  s->MakeConnection();
}