Beispiel #1
0
//////////////////////////////////////////////////////////////////////////
//CallBack function for the modem settings
//////////////////////////////////////////////////////////////////////////
BOOL ALMCALLBACK ModemSettingsProc (HWND hDlg, WORD message,
																 WORD wParam, LONG lParam)
{
	CONN* conn ;
	switch (message)
		{
		case WM_INITDIALOG:
			AUtlCenterDialog(hDlg, 0);
			conn = (CONN*)lParam ;
			SetWindowLong(hDlg, DWL_USER, lParam) ;
			conn->InitModemSettings(hDlg) ;
			return FALSE ;

		case WM_COMMAND: //!!PORT!!
			conn = (CONN*)GetWindowLong(hDlg, DWL_USER) ;
      switch(wParam)
				{
				case idRing:
				case idDial:
				case idRedial:
					conn->ChangeModemSettings(hDlg) ;
					return FALSE ;

				case IDOK:
        	conn->SaveModemParams (hDlg) ;  
			 	 	EndDialog (hDlg, TRUE) ;
		 		 	return TRUE ;

        case IDCANCEL:
					EndDialog (hDlg, FALSE) ;
					return TRUE ;
				}
	}
	return FALSE ;
}
int On_CS_Lost(Aris::Core::MSG &msg)
{
    cout << "Control system connection lost" << endl;
    sleep(3);
    ControlSystem.StartServer("5690");
    return 0;
}
Beispiel #3
0
/* connection event handler */
void conn_event_handler(int event_fd, short event, void *arg)
{
    int error = 0;
    socklen_t len = sizeof(int);
    CONN *conn = (CONN *)arg;

    if(conn)
    {
        if(event_fd == conn->fd)
        {
            if(conn->status == CONN_STATUS_READY)
            {
                if(getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0 || error != 0)
                {
                    ERROR_LOGGER(conn->logger, "socket %d connecting failed, %s", strerror(errno));
                    conn->status = CONN_STATUS_CLOSED;
                    CONN_TERMINATE(conn);          
                    return ;
                }
                conn->status = CONN_STATUS_CONNECTED;
            }
            if(event & E_CLOSE)
            {
                //DEBUG_LOGGER(conn->logger, "E_CLOSE:%d on %d START ", E_CLOSE, event_fd);
                CONN_TERMINATE(conn);          
                //conn->push_message(conn, MESSAGE_QUIT);
                //DEBUG_LOGGER(conn->logger, "E_CLOSE:%d on %d OVER ", E_CLOSE, event_fd);
            }
            if(event & E_READ)
            {
                //DEBUG_LOGGER(conn->logger, "E_READ:%d on %d START", E_READ, event_fd);
                conn->read_handler(conn);
                //conn->push_message(conn, MESSAGE_INPUT);
                //DEBUG_LOGGER(conn->logger, "E_READ:%d on %d OVER ", E_READ, event_fd);
            }
            if(event & E_WRITE)
            {
                //conn->push_message(conn, MESSAGE_OUTPUT);
                //DEBUG_LOGGER(conn->logger, "E_WRITE:%d on %d START", E_WRITE, event_fd);
                 conn->write_handler(conn);
                //DEBUG_LOGGER(conn->logger, "E_WRITE:%d on %d OVER", E_WRITE, event_fd);
            } 
        }
    }
}
Beispiel #4
0
int On_CS_CMD_Received(Aris::Core::MSG &msg)
{
    MSG Command(msg);
    Command.SetMsgID(GetControlCommand);
    PostMsg(Command);
    MSG data(0,0);
    ControlSystem.SendData(data);
    return 0;
}
//MSG call back functions
int On_CS_Connected(Aris::Core::MSG &msg)
{
    cout<<"Received Connection from Control System:"<<endl;
    cout<<"   Remote IP is: "<<msg.GetDataAddress()+sizeof(int)<<endl;
    cout<<"   Port is     : "<<*((int*)msg.GetDataAddress()) << endl << endl;

    Aris::Core::MSG data(0,0);
    ControlSystem.SendData(data);
    return 0;
}
Beispiel #6
0
int main()
{
    time_t t = time(NULL);
    tm* local = new tm;
    char buf[26] = {0};
    localtime_r(&t,local);
    strftime(buf, 64, "%Y-%m-%d %H-%M-%S", local);
    mkdir(buf,S_IRWXU | S_IRWXG);
    chdir(buf);

    visionsensor.viewcloud();
    visionsensor.start();

#if ARIS_PLATFORM_==_PLATFORM_LINUX_
    //char RemoteIp[] = "192.168.1.100";
    char RemoteIp[] = "127.0.0.1";
#endif


    CONN VisualSystem;
    pVisualSystem = &VisualSystem;

    /*注册所有的消息函数*/
    Aris::Core::RegisterMsgCallback(VisualSystemDataNeeded, OnVisualSystemDataNeeded);
    Aris::Core::RegisterMsgCallback(VisualSystemLost, OnVisualSystemLost);

    Aris::Core::RegisterMsgCallback(NeedUpperControl, OnUpperControl);
    Aris::Core::RegisterMsgCallback(NeedStepUp, OnStepUp);
    Aris::Core::RegisterMsgCallback(NeedStepDown, OnStepDown);
    Aris::Core::RegisterMsgCallback(NeedStepOver, OnStepOver);

    /*设置所有CONN类型的回调函数*/
    VisualSystem.SetCallBackOnReceivedData(OnConnDataReceived);
    VisualSystem.SetCallBackOnLoseConnection(OnConnectionLost);

    /*连接服务器*/
    VisualSystem.Connect(RemoteIp, "5691");
    //VisualSystem.Connect(RemoteIp, "5688");

    /*开始消息循环*/
    Aris::Core::RunMsgLoop();
}
Beispiel #7
0
CONN *http_newconn(int id, char *ip, int port, int is_ssl)
{
    CONN *conn = NULL;

    if(running_status && ip && port > 0)
    {
        if(is_ssl) service->session.is_use_SSL = 1;
        if((conn = service->newconn(service, -1, -1, ip, port, NULL)))
        {
            conn->c_id = id;
            conn->start_cstate(conn);
            //service->newtransaction(service, conn, id);
            //usleep(10);
        }
        else
        {
            FATAL_LOGGER(logger, "new_conn(%s:%d) falied, %s", ip, port, strerror(errno));
        }
    }
    return conn;
}
Beispiel #8
0
//////////////////////////////////////////////////////////////////////////
//Callback function for the connection parameters setting
//////////////////////////////////////////////////////////////////////////
BOOL ALMCALLBACK CntObjProc(HWND hDlg, WORD message,
													WORD wParam, LONG lParam)

{
	CONN* conn ;
	switch (message)
		{
		case WM_INITDIALOG:
			AUtlCenterDialog(hDlg, 0);
			conn = (CONN*)lParam ;
			SetWindowLong(hDlg, DWL_USER, lParam) ;
			conn->InitCntDialog(hDlg) ;
			return FALSE ;

		case WM_COMMAND: //!!PORT!!
			conn = (CONN*)GetWindowLong(hDlg, DWL_USER) ;
			switch(wParam)
				{
				case idModem:
        	conn->SelectModem (hDlg) ;
        	return TRUE ;
			 	case idModemS:
					conn->ModemSettings (hDlg) ;
					return FALSE ; 			
       	case IDOK:
        	conn->SaveCntConfigure (hDlg) ;  //Save ring times ,redial times and phonenumber
			 	 	EndDialog (hDlg, TRUE) ;
		 		 	return TRUE ;

				case IDCANCEL:
					EndDialog (hDlg, FALSE) ;
					return TRUE ;

				}
    }
    return FALSE ;
}
Beispiel #9
0
//MSG callback functions
int OnControlCommandNeeded(Aris::Core::MSG &msg)
{
    int cmd;
    cout<<"Commands:"<<endl;
    cout<<"1.Eanble"<<endl<<"2.Disable"<<endl<<"3.Home"<<endl<<"4.Home to standstill"<<endl<<"5.Forward"<<endl<<"6.Back"<<endl<<"7.AUTO Calibration"<<endl<<"8.Turn left"<<endl<<"9.Turn right"<<endl;
    cout<<"Please enter your command: ";
    cin>>cmd;
    while(cmd!=1&&cmd!=2&&cmd!=3&&cmd!=4&&cmd!=5&&cmd!=6&&cmd!=7&&cmd!=8&&cmd!=9)
    {
      cout<<"Not valid command ID,enter again : ";
      cin>>cmd;
    }
    cmd=cmd-1;
    MSG data;
    data.SetMsgID(cmd);
    ControlSysClient.SendData(data);
    return 0;
}
Beispiel #10
0
int On_VS_Lost(Aris::Core::MSG &msg)
{
    cout << "Visual system connection lost" << endl;
    VisionSystem.StartServer("5691");
    return 0;
}
Beispiel #11
0
int On_VS_Capture(Aris::Core::MSG &msg)
{
    Aris::Core::MSG visionmsg(msg);
    VisionSystem.SendData(visionmsg);
    return 0;
}
Beispiel #12
0
int On_VS_Capture(Aris::Core::MSG &msg)
{
    MSG data(0,0);
    VisionSystem.SendData(data);
    return 0;
}