Esempio n. 1
0
// PAM entry point for authentication. This function gets called by pam when
//a login occurs. argc and argv work just like argc and argv for the 'main' 
//function of programs, except they pass in the options defined for this
//module in the pam configuration files in /etc/pam.conf or /etc/pam.d/
PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) 
{
	char *Tempstr=NULL, *KeyList=NULL;
	char *ActiveUSBKeys=NULL;
	const char *ptr;
	int result=PAM_IGNORE, i;

	//These are defined as 'const char' because they passwd to us from the parent
	//library. When we called pam_get_<whatever> the pam library passes pointers
	//to strings in it's own code. Thus we must not change or free them
	const char *pam_user = NULL, *pam_tty=NULL, *pam_rhost=NULL;

	//get the user. If something goes wrong we return PAM_IGNORE. This tells
	//pam that our module failed in some way, so ignore it. Perhaps we should
	//return PAM_PERM_DENIED to deny login, but this runs the risk of a broken
	//module preventing anyone from logging into the system!
	if (pam_get_user(pamh, &pam_user, NULL) != PAM_SUCCESS) return(PAM_IGNORE);
	if (pam_user == NULL) return(PAM_IGNORE);

	//perhaps there will not be a tty if we are logging in remotely
	pam_get_item(pamh, PAM_TTY, (const void **) &pam_tty);
	if (! pam_tty) pam_tty="";

	//perhaps there will not be a remote host if we are logging in locally
	pam_get_item(pamh, PAM_RHOST, (const void **) &pam_rhost);
	if (! pam_rhost) pam_rhost="";


	for (i=0; i < argc; i++)
	{
		ptr=argv[i];

		if (strncmp(ptr,"key=",4)==0)   Tempstr=MCatStr(Tempstr, ptr, " ", NULL);
		if (strncmp(ptr,"keys=",5)==0)  Tempstr=MCatStr(Tempstr, ptr, " ", NULL);
		if (strncmp(ptr,"tty=",4)==0)   Tempstr=MCatStr(Tempstr, ptr, " ", NULL);
		if (strncmp(ptr,"ttys=",5)==0)  Tempstr=MCatStr(Tempstr, ptr, " ", NULL);
		if (strncmp(ptr,"user="******" ", NULL);
		if (strncmp(ptr,"users=",6)==0) Tempstr=MCatStr(Tempstr, ptr, " ", NULL);
	}

	if (StrLen(Tempstr)) KeyList=MCopyStr(KeyList, Tempstr, "|", NULL);


	ActiveUSBKeys=LoadActiveUSBSerialNums(ActiveUSBKeys);
	result=CheckAuth(KeyList, ActiveUSBKeys, pam_user, pam_tty, pam_rhost);

	Destroy(ActiveUSBKeys);
	Destroy(Tempstr);
	Destroy(KeyList);

  return(result);
}
Esempio n. 2
0
// check if authentication is required
bool CWebserverRequest::Authenticate(void)
{
	if (!cfg.MustAuthenticate)
		return true;

	if (CheckAuth())
		return true;

	SocketWriteLn("HTTP/1.0 401 Unauthorized");
	SocketWriteLn("WWW-Authenticate: Basic realm=\"dbox\"\r\n");

	if (Method != M_HEAD)
		SocketWriteLn("Access denied.");

	return false;
}
Esempio n. 3
0
void Player::Auth( PacketPtr packet ) {
	PacketPtr reply = std::make_shared<sf::Packet>();

	if( CheckAuth( packet ) ) {
		(*reply) << sf::String("Authentication successful");
		SendPacket( reply, true );
		LogConsole("Authentication successful");

		m_half_open = false;
	} else {
		(*reply) << sf::String("Authentication failed");
		SendPacket( reply, true );
		LogConsole( "Authentication failed: " + GetName() + " disconnected (auth failure).." );

		Delete();
	}
}
Esempio n. 4
0
void EQWHTTPHandler::Exec() {
	m_sentHeaders = false;
	m_responseCode = "200";
//	printf("Request: %s, %s, %s, %s.\n", GetMethod().c_str(), GetUrl().c_str(), GetUri().c_str(), GetQueryString().c_str());

	SetHttpVersion("HTTP/1.0");
	AddResponseHeader("Connection", "close");

	if(GetUri().find("..") != std::string::npos) {
		SendResponse("403", "Forbidden");
		printf("%s is forbidden.\n", GetUri().c_str());
		return;
	}

	if(!CheckAuth()) {
		AddResponseHeader("Content-type", "text/plain");
		AddResponseHeader("WWW-Authenticate", "Basic realm=\"EQEmulator\"");
		SendResponse("401", "Authorization Required");
		SendString("Gotta Authenticate.");
	} else {
		std::string::size_type start = GetUri().find_first_not_of('/');
		std::string page;
		if(start != std::string::npos)
			page = GetUri().substr(start);
		else
			page = "index.html";
		SendPage(page);
	}
/*	if (!Detach()) {
		printf("Unable to detach...\n");
	}
	if(GetOutputLength() > 0) {
		//we cannot close yet
		m_closeOnFinish = true;
	} else {
		Close();
	}*/
	Free();	//the "app" side (us) is done with this connection too...
	Disconnect();
}
Esempio n. 5
0
//-------------------------------------------------------------------------
bool CWebserverRequest::Authenticate()			// check if authentication is required
{
	if(Parent->MustAuthenticate)
	{
		if(!CheckAuth())
		{
//			dprintf("Authenticate\n");
			SocketWriteLn("HTTP/1.0 401 Unauthorized");
			SocketWriteLn("WWW-Authenticate: Basic realm=\"dbox\"\r\n");
			if (Method != M_HEAD) {
				SocketWriteLn("Access denied.");
			}
			return false;
		}
		else
		{
//			dprintf("Zugriff ok\n");
			return true;
		}
	}
	else
		return true;
}
/*
 * Test a user entered password against all users and all SPs.
 */
void TestPassword(HWND hWndParent, LPTCGDRIVE hDrive)
{
	LPTABLECELL	SpCell;
	LPTABLECELL	UserCell;
	TCGAUTH		TcgAuth;
	LPTABLE		SpTable;
	LPTABLE		UserTable;
	LPBYTE		UserName;
	LPBYTE		SpName;
	TCHAR		Text[1000];
	DWORD		Count;
	BOOL		Result;
	int			SpRows;
	int			UserRows;
	int			i, j;

	/* Query the user for the password. */
	Result = GetPassword(hWndParent, hDrive, &TcgAuth);

	/* If the user cancels, just return. */
	if(Result == FALSE)	{
		return;
	}

	/* Get the list of SPs on the drive. */
	SpTable = GetSpTable(hDrive);

	/* Verify the table. */
	if(SpTable == NULL) {
		MessageBox(hWndParent, _T("There was an error reading the SP table."), _T("Password Test"), MB_ICONERROR | MB_OK);
		return;
	}

	/* For each SP, get a list of users within the SP. */
	Count = 0;
	SpRows = GetRows(SpTable);
	for(i=0; i<SpRows; i++) {
		/* Get the table cell. */
		SpCell = GetTableCell(SpTable, i, 0);

		/* Get a list of users. */
		UserTable = GetUserTable(hDrive, SpCell->Bytes);

		/* Verify the table. */
		if(UserTable == NULL) {
			MessageBox(hWndParent, _T("There was an error reading a user table."), _T("Password Test"), MB_ICONERROR | MB_OK);
			continue;
		}

		/* Loop through users. */
		UserRows = GetRows(UserTable);
		for(j=0; j<UserRows; j++) {
			/* Get the table cell. */
			UserCell = GetTableCell(UserTable, j, 0);

			/* Copy the authority. */
			memcpy(TcgAuth.Authority, UserCell->Bytes, sizeof(TcgAuth.Authority));

			/* Check the authorization value. */
			Result = CheckAuth(hDrive, SpCell->Bytes, &TcgAuth);

			/* If it works, notify the user. */
			if(Result) {
				SpName = GetName(SpTable, i);
				UserName = GetName(UserTable, j);
				wsprintf(Text, _T("Password verified for user '%s' in SP '%s'"), UserName, SpName);
				MessageBox(hWndParent, Text, _T("Password Test"), MB_OK);
				Count++;
			}
		}

		/* Free up memory. */
		FreeTable(UserTable);
	}

	/* If the password did not verify at all, notify the user. */
	if(Count == 0) {
		MessageBox(hWndParent, _T("The password was not verified."), _T("Password Test"), MB_OK);
	} else {
		MessageBox(hWndParent, _T("Password verification complete."), _T("Password Test"), MB_OK);
	}

	/* Free up memory. */
	FreeTable(SpTable);
}
Esempio n. 7
0
/*
 * lnd_name:lljz_net_disk_name
*/
void CreateFolderReq(RequestPacket* req,
void* args, ResponsePacket* resp) {
    Document req_doc;
/*
    Document resp_doc;
    Document::AllocatorType& resp_allocator=resp_doc.GetAllocator();
    StringBuffer resp_buffer;
    Writer<StringBuffer> resp_writer(resp_buffer);
    Value resp_json(kObjectType);
    Value resp_error_msg(kStringType);
*/

    TBSYS_LOG(DEBUG,"-------data:%s",req->data_);
    req_doc.Parse(req->data_);
    
    if (!CheckAuth(req,resp))
        return;

    if (!req_doc.HasMember("folder_name") 
        || !req_doc["folder_name"].IsString() 
        || !req_doc["folder_name"].GetStringLength()) {
        SetErrorMsg(35001,"folder_name is invalid",resp);
        return;        
    }

    const char* folder_name=req_doc["folder_name"].GetString();
    char value[200];
    char file_name[200];
    int file_n=0;
    int num=GetCharCount(folder_name, '/')+1;
    int i=0;
    //  /a/b//c//d
    for (i=0;i<num;i++) {
        GetStrValue(folder_name, '/', i+1, value);
        if (value[0]=='\0')
            continue;
        sprintf(file_name,"%s",value);
        file_n++;
    }
    if (0==file_n) {
        SetErrorMsg(35003,"path of new folder is invalid",resp);
        return;
    }

    RedisClient* file_rc=g_file_redis->GetRedisClient();
    char cmd[512];
    redisReply* reply;
    int cmd_ret;
    //是否存在根目录,父目录,新目录
    char father_name[200];
    sprintf(father_name,"folder_%s",req_doc["account"].GetString());
    sprintf(cmd,"HGET %s %c_%s", father_name,0x02,"create_time");
    cmd_ret=Rhget(file_rc,cmd,reply);
    if (FAILED_NOT_ACTIVE==cmd_ret) {//网络错误
        g_file_redis->ReleaseRedisClient(file_rc,cmd_ret);
        SetErrorMsg(35002,"redis database server is busy",resp);
        return;
    } else if (FAILED_ACTIVE==cmd_ret) {//没有父目录
        //记录异常日志
        g_file_redis->ReleaseRedisClient(file_rc,cmd_ret);
        SetErrorMsg(35003,"path of root folder does not exist",resp);
        return;
    }

    int counter=0;
    for (i=0;i<num;i++) {
        GetStrValue(folder_name, '/', i+1, value);
        if (value[0]=='\0')
            continue;
        counter++;
        if (counter>=file_n)
            break;
        sprintf(cmd,"HGET %s %s", father_name,value);
        cmd_ret=Rhget(file_rc,cmd,reply,false);
        if (FAILED_NOT_ACTIVE==cmd_ret) {//网络错误
            g_file_redis->ReleaseRedisClient(file_rc,cmd_ret);
            SetErrorMsg(35002,"redis database server is busy",resp);
            return;
        } else if (FAILED_ACTIVE==cmd_ret) {//没有父目录
            //记录异常日志
            g_file_redis->ReleaseRedisClient(file_rc,cmd_ret);
            freeReplyObject(reply);
            SetErrorMsg(35003,"path of parent folder does not exist",resp);
            return;
        }
        //
        if (0==reply->len) {
            //记录异常日志
            g_file_redis->ReleaseRedisClient(file_rc,cmd_ret);
            freeReplyObject(reply);
            SetErrorMsg(35003,"path of parent folder does not exist",resp);
            return;
        }
        sprintf(father_name,"%s",reply->str);
        freeReplyObject(reply);
    }

    //增加新文件夹,lnd_name不能冲突
    //取得file_id
    sprintf(cmd,"SPOP file_id_sets_%s",
        req_doc["account"].GetString());
    cmd_ret=Rspop(file_rc,cmd,reply,false);
    if (FAILED_NOT_ACTIVE==cmd_ret) {//网络错误
        g_file_redis->ReleaseRedisClient(file_rc,cmd_ret);
        SetErrorMsg(35002,"get file_id fail,redis database server is busy",resp);
        return;
    } else if (FAILED_ACTIVE==cmd_ret) {
        //记录异常日志
        g_file_redis->ReleaseRedisClient(file_rc,cmd_ret);
        freeReplyObject(reply);
        SetErrorMsg(35006,"get file_id fail,file_id is used out",resp);
        return;
    }

    //在父目录增加记录
    char lnd_name[512];
    sprintf(lnd_name,"%d%c%s%c%s", 0,0x01,
        req_doc["account"].GetString(),0x01,reply->str);
    freeReplyObject(reply);
    sprintf(cmd,"HSETNX %s %s %s",father_name,file_name, lnd_name);
    cmd_ret=Rhsetnx(file_rc,cmd,reply);
    if (FAILED_NOT_ACTIVE==cmd_ret) {//网络错误
        g_file_redis->ReleaseRedisClient(file_rc,false);
        SetErrorMsg(35002,"redis database server is busy",resp);
        return;
    } else if (FAILED_ACTIVE==cmd_ret) {
        //记录异常日志
        g_file_redis->ReleaseRedisClient(file_rc,true);
        SetErrorMsg(35006,"create folder fail,folder has existed",resp);
        return;
    }

    //为新文件夹增加hash表
    sprintf(cmd,"HSETNX %s %c_create_time %lld",
        lnd_name,0x02, tbsys::CTimeUtil::getTime());
    cmd_ret=Rhsetnx(file_rc,cmd,reply);
    if (FAILED_NOT_ACTIVE==cmd_ret) {//网络错误
        g_file_redis->ReleaseRedisClient(file_rc,false);
        SetErrorMsg(35002,"create folder fail,redis database server is busy",resp);
        return;
    } else if (FAILED_ACTIVE==cmd_ret) {
        //记录异常日志
        g_file_redis->ReleaseRedisClient(file_rc,true);
        SetErrorMsg(35006,"file_id has used,redis database server status error",resp);
        return;
    }
    g_file_redis->ReleaseRedisClient(file_rc,true);

    SetErrorMsg(0,"",resp);
}
Esempio n. 8
0
int CVICALLBACK RobotCommand (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_LEFT_CLICK:
			if(CheckAuth(OP_ROBOT) == 0)
				return 0;
			if (!ButtonConfirm (panel,control))		
				return 0;
			switch(control)
			{
				int stat; 
				case PANEL_RB_CMD_PUT:
					if(testBit(sys->rtk[curRid].hsFill,WB) > 0)
					{
						MessagePopup("操作條件不滿足","桶槽內已經有料,不可置料!");
						break;
					}
					if(testBit(sys->rb[curRobotId].hsFill,WB) == 0)
					{
						MessagePopup("操作條件不滿足","夾爪上無料,不可置料!");
						break;
					}
					setRobotCommand(&sys->rb[curRobotId],curRid,PUT_COMMAND);
					ActionLog(RB_PUT_ACT_EVENT,curRobotId,curRid,0,0,0); 
					break;
				case PANEL_RB_CMD_GET:
					if(testBit(sys->rtk[curRid].hsFill,WB) == 0)
					{
						MessagePopup("操作條件不滿足","桶槽內無料,不可取料!");
						break;
					}
					if(testBit(sys->rb[curRobotId].hsFill,WB) > 0)
					{
						MessagePopup("操作條件不滿足","夾爪上已經有料,不可取料!");
						break;
					}
					setRobotCommand(&sys->rb[curRobotId],curRid,GET_COMMAND);
					ActionLog(RB_GET_ACT_EVENT,curRobotId,curRid,0,0,0);
					break;	
				case PANEL_RB_CMD_HOME:
					setRobotCommand(&sys->rb[curRobotId],curRid,HOME_COMMAND);
					ActionLog(RB_HOME_ACT_EVENT,curRobotId,0,0,0,0);
					break;
				case PANEL_RB_CMD_MOVE:
					setRobotCommand(&sys->rb[curRobotId],curRid,MOVE_COMMAND);
					ActionLog(RB_MOVE_ACT_EVENT,curRobotId,curRid,0,0,0);
					break;
				case PANEL_RB_CMD_CLEAN:
					setRobotCommand(&sys->rb[curRobotId],curRid,BLOW_COMMAND);
					ActionLog(RB_CLEAN_ACT_EVENT,curRobotId,0,0,0,0);
					break;


				case PANEL_RB_CHUCK_OFF:
					setBit(sys->rb[curRobotId].hsChuck);
					ActionLog(RB_CHUCK_ACT_EVENT,curRobotId,1,0,0,0);
					break;
				case PANEL_RB_CHUCK_ON:
					resetBit(sys->rb[curRobotId].hsChuck);
					ActionLog(RB_CHUCK_ACT_EVENT,curRobotId,0,0,0,0);
					break;
					
				case PANEL_RB_TEACH_OFF:
					setBit(sys->rb[curRobotId].hsTeach);
					ActionLog(RB_TEACH_ACT_EVENT,curRobotId,1,0,0,0);
					break;
				case PANEL_RB_TEACH_ON:
					resetBit(sys->rb[curRobotId].hsTeach);
					ActionLog(RB_TEACH_ACT_EVENT,curRobotId,0,0,0,0);
					break;
					
				case PANEL_RB_FILL_OFF:
					setBit(sys->rb[curRobotId].hsFill);
					ActionLog(RB_CAR_ACT_EVENT,curRobotId,1,0,0,0);
					break;
				case PANEL_RB_FILL_ON:
					resetBit(sys->rb[curRobotId].hsFill); 
					ActionLog(RB_CAR_ACT_EVENT,curRobotId,0,0,0,0);
					break;
			}
			break;
	}
	return 0;
}
Esempio n. 9
0
int CVICALLBACK SavePosition (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			
			double tmpx,tmpy;
			int state;
			GetCtrlVal (panel, PANEL_RB_CHECKBOX, &state);  
			
			if(CheckAuth(OP_ROBOT) == 0) {
				SetCtrlAttribute(panel,PANEL_RB_SET_POS, ATTR_DIMMED, 1); 
				SetCtrlAttribute(panel,PANEL_RB_SET_LCK, ATTR_DIMMED, 1);
				SetCtrlAttribute(panel,PANEL_RB_SET_SAV_HI, ATTR_DIMMED, 1);
				
				SetCtrlVal (panel, PANEL_RB_CHECKBOX_2, 0); 
				return 0;
			}
			if (!ButtonConfirm (panel,control))	{
				SetCtrlAttribute(panel,PANEL_RB_SET_POS, ATTR_DIMMED, 1); 
				SetCtrlAttribute(panel,PANEL_RB_SET_LCK, ATTR_DIMMED, 1);
				SetCtrlAttribute(panel,PANEL_RB_SET_SAV_HI, ATTR_DIMMED, 1);
				SetCtrlVal (panel, PANEL_RB_CHECKBOX_2, 0);
				return 0;
			}
			
			if(control == PANEL_RB_SET_POS)
			{
				if(state)//maun input
				{
					GetCtrlVal(panel, PANEL_RB_UNLOCKX, &tmpx);
					GetCtrlVal(panel, PANEL_RB_UNLOCKY, &tmpy);
					if(curRid <= sys->rb[curRobotId].lastRid)//tank pos
					{
						if(curRid == sys->rb[curRobotId].firstRid && curRobotId > 0 )//overlap tank  pos
						{
							sys->rtk[curRid].MvPosH2 = tmpx * 10000;
							sys->rtk[curRid].MvPosV2 = tmpy * 10000;
						}
						else //normal tank pos
						{
							sys->rtk[curRid].MvPosH = tmpx * 10000;
							sys->rtk[curRid].MvPosV = tmpy * 10000;
						}	
					}
					else //clean pos
					{
						sys->rb[curRobotId].cleanPosH = tmpx * 10000;
						sys->rb[curRobotId].cleanPosV = tmpy * 10000;
					}	
				}
				else//get plc data
				{
					GetCtrlVal(panel, PANEL_RB_CURR_POS_X, &tmpx);
					GetCtrlVal(panel, PANEL_RB_CURR_POS_Y, &tmpy);
					SetCtrlVal(panel, PANEL_RB_UNLOCKX, tmpx); 
					SetCtrlVal(panel, PANEL_RB_UNLOCKY, tmpy);
					if(curRid <= sys->rb[curRobotId].lastRid)//tank pos
					{
						if(curRid == sys->rb[curRobotId].firstRid && curRobotId > 0 )//overlap tank  pos
						{
							sys->rtk[curRid].MvPosH2 = tmpx * 10000; 
							sys->rtk[curRid].MvPosV2 = tmpy * 10000;
						}
						else //normal tank pos
						{
							sys->rtk[curRid].MvPosH = tmpx * 10000; 
							sys->rtk[curRid].MvPosV = tmpy * 10000;
						}
					}
					else//clean pos
					{
						sys->rb[curRobotId].cleanPosH = tmpx * 10000; 
						sys->rb[curRobotId].cleanPosV = tmpy * 10000;	
					}
				}
				
				if(curRid <= sys->rb[curRobotId].lastRid)
					SavePositionData(curRobotId,curRid,TANK_POS);
				else
					SavePositionData(curRobotId,curRid,CLEAN_POS);
				
				ActionLog(RB_POS_SAVE_ACT_EVENT,curRobotId,0,curRid,0,0); 
			}
			else if(control == PANEL_RB_SET_LCK)
			{
				if(state)//maun input
				{
					GetCtrlVal(panel, PANEL_RB_LOCKX, &tmpx);
					GetCtrlVal(panel, PANEL_RB_LOCKY, &tmpy);
					if(curRid <= sys->rb[curRobotId].lastRid)//tank pos
					{
						if(curRid == sys->rb[curRobotId].firstRid && curRobotId > 0 )//overlap tank  pos
						{
							sys->rtk[curRid].MvLock2 = tmpx * 10000;
							sys->rtk[curRid].MvPosV2 = tmpy * 10000;
							
						}
						else //normal tank pos
						{
							sys->rtk[curRid].MvLock = tmpx * 10000;
							sys->rtk[curRid].MvPosV = tmpy * 10000;
						}	
					}
					else //clean pos
					{
						sys->rb[curRobotId].cleanLock = tmpx * 10000;
						sys->rb[curRobotId].cleanPosV = tmpy * 10000;
					}	
				}
				else//get plc data
				{
					GetCtrlVal(panel, PANEL_RB_CURR_POS_X, &tmpx);
					GetCtrlVal(panel, PANEL_RB_CURR_POS_Y, &tmpy);
					SetCtrlVal(panel, PANEL_RB_LOCKX, tmpx); 
					SetCtrlVal(panel, PANEL_RB_LOCKY, tmpy);
					if(curRid <= sys->rb[curRobotId].lastRid)//tank pos
					{
						if(curRid == sys->rb[curRobotId].firstRid && curRobotId > 0 )//overlap tank  pos
						{
							sys->rtk[curRid].MvLock2 = tmpx * 10000; 
							sys->rtk[curRid].MvPosV2 = tmpy * 10000;
						}
						else //normal tank pos
						{
							sys->rtk[curRid].MvLock = tmpx * 10000; 
							sys->rtk[curRid].MvPosV = tmpy * 10000;
						}
					}
					else//clean pos
					{
						sys->rb[curRobotId].cleanLock = tmpx * 10000; 
						sys->rb[curRobotId].cleanPosV = tmpy * 10000;
					}
				}
				
				if(curRid <= sys->rb[curRobotId].lastRid)
					SavePositionData(curRobotId,curRid,TANK_POS);
				else
					SavePositionData(curRobotId,curRid,CLEAN_POS);
				
				ActionLog(RB_POS_SAVE_ACT_EVENT,curRobotId,1,curRid,0,0); 
				
			}
			else if(control == PANEL_RB_SET_SAV_HI)
			{
				if(state)
				{
					GetCtrlVal(panel, PANEL_RB_SAV_HI, &tmpy);
					sys->rb[curRobotId].safeHight = tmpy * 10000;
				}
				else
				{
					GetCtrlVal(panel, PANEL_RB_CURR_POS_Y, &tmpy);
					SetCtrlVal(panel, PANEL_RB_SAV_HI, tmpy);
					sys->rb[curRobotId].safeHight = tmpy * 10000; 
				}
				
				SavePositionData(curRobotId,curRid,SAFE_POS);
				ActionLog(RB_POS_SAVE_ACT_EVENT,curRobotId,2,0,0,0);
			}
	
			SetCtrlAttribute(panel,PANEL_RB_SET_POS, ATTR_DIMMED, 1); 
			SetCtrlAttribute(panel,PANEL_RB_SET_LCK, ATTR_DIMMED, 1);
			SetCtrlAttribute(panel,PANEL_RB_SET_SAV_HI, ATTR_DIMMED, 1);
			SetCtrlVal (panel, PANEL_RB_CHECKBOX_2, 0);

			break;
	}
	
	return 0;
}
Esempio n. 10
0
int CVICALLBACK RobotManuAdj (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_LEFT_CLICK:
			if(CheckAuth(OP_ROBOT) == 0)
				return 0;
			
			if(control == PANEL_RB_MOT_ADJ_U)
			{
				resetBit(sys->rb[curRobotId].hsJogSpdY);
				setBit(sys->rb[curRobotId].hsJogPY); 
				resetBit(sys->rb[curRobotId].hsJogNY);
				
				ActionLog(RB_UP_ACT_EVENT,curRobotId,0,0,0,0); 
			}
			else if(control == PANEL_RB_MOT_ADJ_UU)
			{
				setBit(sys->rb[curRobotId].hsJogSpdY);
				setBit(sys->rb[curRobotId].hsJogPY); 
				resetBit(sys->rb[curRobotId].hsJogNY);
				
				ActionLog(RB_UUP_ACT_EVENT,curRobotId,0,0,0,0);
			}
			else if(control == PANEL_RB_MOT_ADJ_D)
			{
				resetBit(sys->rb[curRobotId].hsJogSpdY);
				resetBit(sys->rb[curRobotId].hsJogPY); 
				setBit(sys->rb[curRobotId].hsJogNY);
				
				ActionLog(RB_DOWN_ACT_EVENT,curRobotId,0,0,0,0);
			}
			else if(control == PANEL_RB_MOT_ADJ_DD)
			{
				setBit(sys->rb[curRobotId].hsJogSpdY);
				resetBit(sys->rb[curRobotId].hsJogPY); 
				setBit(sys->rb[curRobotId].hsJogNY);
				
				ActionLog(RB_DDOWN_ACT_EVENT,curRobotId,0,0,0,0);
			}
			////////////////////////////////////////////
			else if(control == PANEL_RB_MOT_ADJ_L)
			{
				resetBit(sys->rb[curRobotId].hsJogSpdX);
				if(curRobotId == RB03)
				{
					resetBit(sys->rb[curRobotId].hsJogPX); 
					setBit(sys->rb[curRobotId].hsJogNX);
				}
				else
				{
					setBit(sys->rb[curRobotId].hsJogPX); 
					resetBit(sys->rb[curRobotId].hsJogNX);	
				}
				ActionLog(RB_LEFT_ACT_EVENT,curRobotId,0,0,0,0);
			}
			else if(control == PANEL_RB_MOT_ADJ_LL)
			{
				setBit(sys->rb[curRobotId].hsJogSpdX);
				if(curRobotId == RB03)
				{
					resetBit(sys->rb[curRobotId].hsJogPX); 
					setBit(sys->rb[curRobotId].hsJogNX);
				}
				else
				{
					setBit(sys->rb[curRobotId].hsJogPX); 
					resetBit(sys->rb[curRobotId].hsJogNX);	
				}
				ActionLog(RB_LLEFT_ACT_EVENT,curRobotId,0,0,0,0);
			}
			else if(control == PANEL_RB_MOT_ADJ_R)
			{
				resetBit(sys->rb[curRobotId].hsJogSpdX);
				if(curRobotId != RB03)
				{
					resetBit(sys->rb[curRobotId].hsJogPX); 
					setBit(sys->rb[curRobotId].hsJogNX);
				}
				else
				{
					setBit(sys->rb[curRobotId].hsJogPX); 
					resetBit(sys->rb[curRobotId].hsJogNX);	
				}
				ActionLog(RB_RIGHT_ACT_EVENT,curRobotId,0,0,0,0);
			}
			else if(control == PANEL_RB_MOT_ADJ_RR)
			{
				setBit(sys->rb[curRobotId].hsJogSpdX);
				if(curRobotId != RB03)
				{
					resetBit(sys->rb[curRobotId].hsJogPX); 
					setBit(sys->rb[curRobotId].hsJogNX);
				}
				else
				{
					setBit(sys->rb[curRobotId].hsJogPX); 
					resetBit(sys->rb[curRobotId].hsJogNX);	
				}
				ActionLog(RB_RRIGHT_ACT_EVENT,curRobotId,0,0,0,0);
			}
			break;
		case EVENT_LEFT_CLICK_UP: 
			resetBit(sys->rb[curRobotId].hsJogSpdX);
			resetBit(sys->rb[curRobotId].hsJogPX);
			resetBit(sys->rb[curRobotId].hsJogNX); 
			
			resetBit(sys->rb[curRobotId].hsJogSpdY);
			resetBit(sys->rb[curRobotId].hsJogPY);
			resetBit(sys->rb[curRobotId].hsJogNY); 

			break;
	}
	return 0;
}
Esempio n. 11
0
int CVICALLBACK Command (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	if(event != EVENT_LEFT_CLICK)
		return 0;
	
	if(CheckAuth(OP_TANK) == 0)
		return 0;
	if (!ButtonConfirm (panel,control))		
		return 0; 
	
	switch (control) {
		case PANEL_TANK_AMAKE_OFF:
			if(testBit(sys->tk[curTankId].hsMakeEnd,RB) > 0)
			{
				MessagePopup("¾Þ§@±ø¥ó¤£º¡¨¬","½Ð¥ý±Æ©ñ¡A¤~¥i°õ¦æ°t¼Ñ¡I");
				break;
			}
			if(g_setupMake == 0)
			{
				resetBit(sys->tk[curTankId].hsMakeStop); 
				GetCtrlVal(panel,PANEL_TANK_AC1_MAKE,&sys->tk[curTankId].MakeCH1);
				GetCtrlVal(panel,PANEL_TANK_AC2_MAKE,&sys->tk[curTankId].MakeCH2); 
				GetCtrlVal(panel,PANEL_TANK_AC3_MAKE,&sys->tk[curTankId].MakeCH3);
				GetCtrlVal(panel,PANEL_TANK_AC4_MAKE,&sys->tk[curTankId].MakeCH4);
				g_makeBit = sys->tk[curTankId].hsMake;
				g_setupMake = 1;
				
				ActionLog(TANK_MAKE_ACT_EVENT,curTankId,1,sys->tk[curTankId].MakeCH1,sys->tk[curTankId].MakeCH2,sys->tk[curTankId].MakeCH3);
			}
			break;
		case PANEL_TANK_AMAKE_ON:
			setBit(sys->tk[curTankId].hsMakeStop);
			
			ActionLog(TANK_MAKE_ACT_EVENT,curTankId,0,0,0,0);
			break;
			
		case PANEL_TANK_MMAKE_OFF:
			if(testBit(sys->tk[curTankId].hsMakeEnd,RB) == 0)
			{
				MessagePopup("¾Þ§@±ø¥ó¤£º¡¨¬","°t¼Ñ¥¼§¹¦¨¡A¤£¥i²K¥[¡I");
				break;
			}
			if(g_setupMMake == 0)
			{
				resetBit(sys->tk[curTankId].hsMMakeStop); 
				GetCtrlVal(panel,PANEL_TANK_AC1_MAKE,&sys->tk[curTankId].MMakeCH1);
				GetCtrlVal(panel,PANEL_TANK_AC2_MAKE,&sys->tk[curTankId].MMakeCH2); 
				GetCtrlVal(panel,PANEL_TANK_AC3_MAKE,&sys->tk[curTankId].MMakeCH3);
				GetCtrlVal(panel,PANEL_TANK_AC4_MAKE,&sys->tk[curTankId].MMakeCH4);
				g_mmakeBit = sys->tk[curTankId].hsMMake;
				g_setupMMake = 1;
				
				ActionLog(TANK_MMAKE_ACT_EVENT,curTankId,1,sys->tk[curTankId].MMakeCH1,sys->tk[curTankId].MMakeCH2,sys->tk[curTankId].MMakeCH3);
			}
			break;
		case PANEL_TANK_MMAKE_ON:
			setBit(sys->tk[curTankId].hsMMakeStop);
			
			ActionLog(TANK_MAKE_ACT_EVENT,curTankId,0,0,0,0);
			break;	
			
		case PANEL_TANK_AC1_DOS_OFF:
			setBit(sys->tk[curTankId].hsAC1Dos);
			ActionLog(TANK_DOS_ACT_EVENT,curTankId,1,1,0,0);
			
			break;
		case PANEL_TANK_AC1_DOS_ON:
			resetBit(sys->tk[curTankId].hsAC1Dos);
			
			ActionLog(TANK_DOS_ACT_EVENT,curTankId,1,0,0,0);
			break;	
			
		case PANEL_TANK_AC2_DOS_OFF:
			setBit(sys->tk[curTankId].hsAC2Dos);
			ActionLog(TANK_DOS_ACT_EVENT,curTankId,2,1,0,0);
			
			break;
		case PANEL_TANK_AC2_DOS_ON:
			resetBit(sys->tk[curTankId].hsAC2Dos);
			
			ActionLog(TANK_DOS_ACT_EVENT,curTankId,2,0,0,0);
			break;
			
		case PANEL_TANK_AC3_DOS_OFF:
			setBit(sys->tk[curTankId].hsAC3Dos);
			ActionLog(TANK_DOS_ACT_EVENT,curTankId,3,1,0,0);
			
			break;
		case PANEL_TANK_AC3_DOS_ON:
			resetBit(sys->tk[curTankId].hsAC3Dos);
			
			ActionLog(TANK_DOS_ACT_EVENT,curTankId,3,0,0,0);
			break;	
			
		case PANEL_TANK_AC4_DOS_OFF:
			setBit(sys->tk[curTankId].hsAC4Dos);
			ActionLog(TANK_DOS_ACT_EVENT,curTankId,4,1,0,0);
			
			break;
		case PANEL_TANK_AC4_DOS_ON:
			resetBit(sys->tk[curTankId].hsAC4Dos);
			
			ActionLog(TANK_DOS_ACT_EVENT,curTankId,4,0,0,0);
			break;	
			
        case PANEL_TANK_WASH_OFF:
			setBit(sys->tk[curTankId].hsWash);
			
			ActionLog(TANK_WASH_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_WASH_ON:
			resetBit(sys->tk[curTankId].hsWash);
			
			ActionLog(TANK_WASH_ACT_EVENT,curTankId,0,0,0,0);
			break;
			
		case PANEL_TANK_DOWN_OFF:
			/*if(testBit(sys->tk[curTankId].hsMakeEnd,RB) == 0)
			{
				MessagePopup("¾Þ§@±ø¥ó¤£º¡¨¬","°t¼Ñ¥¼§¹¦¨¡A¤£¥i±Æ©ñ¡I¡I");
				break;
			}  */
			setBit(sys->tk[curTankId].hsDown);
			ActionLog(TANK_DOWN_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_DOWN_ON:
			resetBit(sys->tk[curTankId].hsDown);
			ActionLog(TANK_DOWN_ACT_EVENT,curTankId,0,0,0,0);
			break;
			
		case PANEL_TANK_PUMP_OFF:
			resetBit(sys->tk[curTankId].hsPump);
			ActionLog(TANK_PUMP_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_PUMP_ON:
			ActionLog(TANK_PUMP_ACT_EVENT,curTankId,0,0,0,0);
			setBit(sys->tk[curTankId].hsPump);
			break;
			
		case PANEL_TANK_PUMPIN_OFF:
			resetBit(sys->tk[curTankId].hsPumpIn);
			ActionLog(TANK_PUMP_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_PUMPIN_ON:
			ActionLog(TANK_PUMP_ACT_EVENT,curTankId,0,0,0,0);
			setBit(sys->tk[curTankId].hsPumpIn);
			break;	
			
		case PANEL_TANK_HEAT_OFF:
			resetBit(sys->tk[curTankId].hsHeat);
			ActionLog(TANK_HEAT_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_HEAT_ON:
			setBit(sys->tk[curTankId].hsHeat);
			ActionLog(TANK_HEAT_ACT_EVENT,curTankId,0,0,0,0);
			break;
			
		case PANEL_TANK_ADD_WATER_OFF:
			setBit(sys->tk[curTankId].hsAddWater);
			ActionLog(TANK_ADD_WATER_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_ADD_WATER_ON:
			resetBit(sys->tk[curTankId].hsAddWater);
			ActionLog(TANK_ADD_WATER_ACT_EVENT,curTankId,0,0,0,0);
			break;	
			
		case PANEL_TANK_SHUT_OFF:
			setBit(sys->tk[curTankId].hsShutOpen);
			resetBit(sys->tk[curTankId].hsShutClose);
			ActionLog(TANK_SHUT_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_SHUT_ON:
			setBit(sys->tk[curTankId].hsShutClose);
			resetBit(sys->tk[curTankId].hsShutOpen);
			ActionLog(TANK_SHUT_ACT_EVENT,curTankId,0,0,0,0);
			break;	
			
/*		case PANEL_TANK_BUBB_OFF:
			setBit(sys->tk[curTankId].hsBubble);
			ActionLog(TANK_BUBB_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_BUBB_ON:
			resetBit(sys->tk[curTankId].hsBubble);
			ActionLog(TANK_BUBB_ACT_EVENT,curTankId,0,0,0,0);
			break;
					   
		case PANEL_TANK_DRAIN_OFF:
			setBit(sys->tk[curTankId].hsDrain);
			ActionLog(TANK_DRAIN_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_DRAIN_ON:
			resetBit(sys->tk[curTankId].hsDrain);
			ActionLog(TANK_DRAIN_ACT_EVENT,curTankId,0,0,0,0);
			break;	
	*/	
			
		case PANEL_TANK_FILL_OFF:
			//ChangFillStatus(sys->rtk[curRTankId1].hsFill,1);
			setBit(sys->rtk[curRTankId1].hsFill);
			GetCurrentDateTime(&sys->rtk[curRTankId1].car.iPrcTM[curTankId]);
			ActionLog(TANK_CAR_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_FILL_ON:
			resetBit(sys->rtk[curRTankId1].hsFill);
			//ChangFillStatus(sys->rtk[curRTankId1].hsFill,0);
			ActionLog(TANK_CAR_ACT_EVENT,curTankId,0,0,0,0);
			break;	
			
		case PANEL_TANK_FILL2_OFF:
			setBit(sys->rtk[curRTankId2].hsFill);
			GetCurrentDateTime(&sys->rtk[curRTankId2].car.iPrcTM[curTankId]);
			//ChangFillStatus(sys->rtk[curRTankId2].hsFill,1);
			ActionLog(TANK_CAR_ACT_EVENT,curTankId,1,0,0,0);
			break;
		case PANEL_TANK_FILL2_ON:
			resetBit(sys->rtk[curRTankId2].hsFill);
			//ChangFillStatus(sys->rtk[curRTankId2].hsFill,0);
			ActionLog(TANK_CAR_ACT_EVENT,curTankId,0,0,0,0);
			break;	
	}
	
	return 0;
}