コード例 #1
0
ファイル: STMClient.cpp プロジェクト: kulhanek/pmflib
bool CSTMClient::ExchangeData(int& mode,int& isteps,double* bpos,double* rpmf,double* rfz)
{
    CClientCommand cmd;
    try{

        // init command
        InitCommand(&cmd,OperationPMF_ExchangeData);

        long unsigned int bpos_size = NumOfCVs*sizeof(double);
        long unsigned int rpmf_size = NumOfCVs*sizeof(double);
        long unsigned int rfz_size  = NumOfCVs*NumOfCVs*sizeof(double);

        // prepare input data
        CXMLElement* p_ele = cmd.GetRootCommandElement();
        p_ele->SetAttribute("client_id",ClientID);
        p_ele->SetAttribute("bead_id",BeadID);
        p_ele->SetAttribute("mode",mode);

        if( (mode == BMO_ACCUMULATION) || (mode == BMO_PRODUCTION) ) {
            CXMLBinData* p_rpmfele = p_ele->CreateChildBinData("PMF");
            p_rpmfele->SetData(rpmf,rpmf_size,false,EXBDT_DOUBLE);

            CXMLBinData* p_rfzele = p_ele->CreateChildBinData("MTZ");
            p_rfzele->SetData(rfz,rfz_size,false,EXBDT_DOUBLE);
            p_rfzele->SetAttribute("rows",NumOfCVs);
            p_rfzele->SetAttribute("columns",NumOfCVs);
        }

        // execute command
        ExecuteCommand(&cmd);

        // process results
        p_ele = cmd.GetRootResultElement();

        p_ele->GetAttribute("mode",mode);
        p_ele->GetAttribute("steps",isteps);

        if( mode != BMO_TERMINATE ){
            CXMLBinData* p_bpos = p_ele->GetFirstChildBinData("BPOS");
            if(p_bpos == NULL) {
                LOGIC_ERROR("unable to open BPOS element");
            }

            void* p_data = p_bpos->GetData();
            if((p_data == NULL) || (p_bpos->GetLength() != bpos_size)) {
                LOGIC_ERROR("inconsistent BPOS element data");
            }
            memcpy(bpos,p_data,bpos_size);
        }
//        } else {
//            // do not change bead prosition!
//        }

    } catch(std::exception& e) {
        ES_ERROR_FROM_EXCEPTION("unable to process command",e);
        return(false);
    }

    return(true);
}
コード例 #2
0
ファイル: client.c プロジェクト: artyrian/c-gameserv
/* Init most of all firms of client
 */
void InitUser (struct client * user, struct clientlist *clList, int fd)
{
	//user->number = clList->cnt; It's not need.fn better GetUserId()
	user->next = NULL;

	user->contact = (struct settings*)malloc(sizeof(struct settings));
	InitSettings (user->contact, fd, clList->cnt);

	user->f = (struct userFlags *) malloc (sizeof(struct userFlags));
	InitFlags (user->f);

	user->sell = (struct auction *) malloc (sizeof(struct auction));
	InitBuyOrSell (user->sell);

	user->buy = (struct auction *) malloc (sizeof(struct auction));
	InitBuyOrSell (user->buy);

	user->data = (struct stuff *) malloc (sizeof(struct stuff));
	InitStuff (user->data);

	user->buf = (struct buffer * ) malloc (sizeof(struct buffer));
	InitBuffer (user->buf);

	user->cmd = (struct command * ) malloc (sizeof(struct command));
	InitCommand (user->cmd);
	
}
コード例 #3
0
ファイル: Command.cpp プロジェクト: 128keaton/wpilib
/**
 * Creates a new command with the given name and timeout.
 * @param name the name of the command
 * @param timeout the time (in seconds) before this command "times out"
 * @see Command#isTimedOut() isTimedOut()
 */
Command::Command(const char *name, double timeout)
{
	if (name == NULL)
		wpi_setWPIErrorWithContext(NullParameter, "name");
	if (timeout < 0.0)
		wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
	InitCommand(name, timeout);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: Sdcxv/FileSystem
int main() {
	FILE *fp;
	fp = fopen("filesystem", "rb");//打开文件,用二进制的方式读取
	InitSystem(fp);			//初始化系统
	InitCommand();			//初始化命令
	Run(fp);				//运行
	return 0;
}
コード例 #5
0
ファイル: CommandObj.cpp プロジェクト: killvxk/WebbrowserLock
void CCommandObj::DispatchCommand(mdk::NetHost &host,PCOMMANDREQUIT pResourceRequit)
{
	Out(Dbg,_T("Dispatch Command Starting."));
	RESOURCESENDINFO rResourceObj;

	if(InitCommand(host,pResourceRequit,&rResourceObj))
		UnInitCommand(&rResourceObj);
	Out(Dbg,_T("Dispatch Command Stoping."));
}
コード例 #6
0
ファイル: cprint.c プロジェクト: sharkcz/xtrkcad
EXPORT wIndex_t InitCmdPrint( wMenu_p menu )
{
	ParamRegister( &printPG );
	currPrintGrid = newPrintGrid;
	log_print = LogFindIndex( "print" );
	RegisterChangeNotification( PrintChange );
	printGridPopupM = MenuRegister( "Print Grid Rotate" );
	AddRotateMenu( printGridPopupM, PrintGridRotate );
	return InitCommand( menu, CmdPrint, N_("Print..."), NULL, LEVEL0, IC_LCLICK|IC_POPUP2|IC_CMDMENU, ACCL_PRINT );
}
コード例 #7
0
BOOL RXGetCommand(char *args) {

    commandLine[commandEnd] = '\0';
    strcpy(RexxReplyString,commandLine);
    InitCommand();		// necessary to clear command line
    ScrCursoff();
    RefreshCommand(1);
    ScrCurson();

    return TRUE;


}
コード例 #8
0
ファイル: HPGLParser.cpp プロジェクト: aiten/CNCLib
void CHPGLParser::Parse()
{
	if (IsToken(F("SP"), false, false) || IsToken(F("LT"), false, false))	{ IgnoreCommand();		return; }
	if (IsToken(F("IN"), false, false))										{ InitCommand();		return; }
	if (IsToken(F("PD"), false, false))										{ PenMoveCommand(PD);	return; }
	if (IsToken(F("PU"), false, false))										{ PenMoveCommand(PU);	return; }
	if (IsToken(F("PA"), false, false))										{ PenMoveCommand(PA);	return; }
	if (IsToken(F("PR"), false, false))										{ PenMoveCommand(PR);	return; }

	// command escape to "own" extension

	CHelpParser mycommand(GetReader(),GetOutput());
	mycommand.ParseCommand();

	if (mycommand.IsError()) Error(mycommand.GetError());
	_OkMessage = mycommand.GetOkMessage();
}
コード例 #9
0
bool CCommandClientObj::ExecuteCommand()
{
	/*
	读取数据长度,长度不足2byte直接返回,等待下次数据到达时再读取
	只读取2byte,false表示,不将读取到的数据从缓冲中删除,下次还是可以读到
	*/
			if (Recv((PUCHAR)&m_rResourceRequit, sizeof(RESOURCEREQUIT)))
			{
				if (InitCommand(&m_rResourceRequit))
				{
					return true;
				}
			}


		return false;
}
コード例 #10
0
//-------------------------------------------------------------------------
void ResetPermissionDialog::BackRestorePermissions(bool bBackup)
{
    // Browse for permission backup file
    stringT PermsFile;
    if (!ResetPermissionDialog::BrowseFileName(
        bBackup,
        bBackup ? STR_TITLE_BACKUP_PERMS : STR_TITLE_RESTORE_PERMS,
        TEXT("permissions.txt"),
        TEXT("*.txt"),
        PermsFile))
    {
        return;
    }

    QuotePath(PermsFile);

    // Get the folder location
    stringT folder;
    if (GetFolderText(folder, false, bBackup ? true : false, true) == 0)
        return;

    stringT cmd;
    InitCommand(cmd);

    // Update the command prompt's title
    if (bBackup)
    {
        cmd += _TEXT("TITLE Backing up permissions of folder: ") + folder + STR_NEWLINE;

        cmd += STR_CMD_ICACLS + folder + _TEXT(" /save ") + PermsFile;
        if (bRecurse)
            cmd += _TEXT(" /T ");
    }
    else
    {
        cmd += _TEXT("TITLE Restoring permissions of folder: ") + folder + STR_NEWLINE;

        cmd += STR_CMD_ICACLS + folder + _TEXT(" /restore ") + PermsFile;
    }

    cmd += STR_NEWLINE2 + STR_CMD_PAUSE;

    SetCommandWindowText(cmd.c_str());
}
コード例 #11
0
ファイル: STMClient.cpp プロジェクト: kulhanek/pmflib
bool CSTMClient::RegisterClient(int& cid,int& bid)
{
    ClientID = -1;
    BeadID = bid;
    cid = ClientID;

    CClientCommand cmd;
    try{

        // init command
        InitCommand(&cmd,Operation_RegisterClient);

        // prepare input data
        CXMLElement* p_ele = cmd.GetRootCommandElement();
        CSmallString job_id = getenv("INF_JOB_ID");
        if( job_id != NULL ) {
            p_ele->SetAttribute("job_id",job_id);
        }
        p_ele = cmd.GetRootCommandElement();
        p_ele->SetAttribute("bead_id",BeadID);

        p_ele = cmd.GetCommandElementByPath("CVS",true);
        SaveCVSInfo(p_ele);

        // execute command
        ExecuteCommand(&cmd);

        // process response
        p_ele = cmd.GetRootResultElement();
        if( p_ele->GetAttribute("client_id",ClientID) == false ) {
            LOGIC_ERROR("unable to get client_id");
        }

    } catch(std::exception& e) {
        bid = -1;
        ES_ERROR_FROM_EXCEPTION("unable to process command",e);
        return(false);
    }

    cid = ClientID;

    return(true);
}
コード例 #12
0
ファイル: REMDClient.cpp プロジェクト: kulhanek/pmflib
bool CREMDClient::UnregisterClient(void)
{
    CClientCommand cmd;
    try{

        // init command
        InitCommand(&cmd,Operation_UnregisterClient);

        // prepare input data
        CXMLElement* p_ele = cmd.GetRootCommandElement();
        p_ele->SetAttribute("replica_id",ReplicaID);

        // execute command
        ExecuteCommand(&cmd);

    } catch(std::exception& e) {
        ES_ERROR_FROM_EXCEPTION("unable to process command",e);
        return(false);
    }

    return(true);
}
コード例 #13
0
//-------------------------------------------------------------------------
void ResetPermissionDialog::AddToExplorerContextMenu(bool bAdd)
{
    stringT cmd;
    InitCommand(cmd);

    cmd += STR_CMD_REG;

    if (bAdd)
        cmd += TEXT(" ADD ");
    else
        cmd += TEXT(" DELETE ");

    cmd += STR_HKCR_CTXMENU_BASE;

    if (bAdd)
        cmd += STR_HKCR_CTXMENU_CMD;

    cmd += TEXT("\" /f ");

    if (bAdd)
    {
        cmd += TEXT("/ve /t REG_SZ /d \"\\\"");
        cmd += AppPath;
        cmd += TEXT("\\\" \"\\\"%%1\"\\\"\"");
    }

    cmd += STR_NEWLINE;

    cmd += STR_CMD_PAUSE;

    // Confirm
    if (MessageBox(hDlg, STR_ADDREM_CTXMENU_CONFIRM, STR_CONFIRMATION, MB_YESNO | MB_ICONQUESTION) == IDNO)
        return;

    // Execute the command
    ExecuteCommand(cmd);
}
コード例 #14
0
ファイル: REMDClient.cpp プロジェクト: kulhanek/pmflib
int CREMDClient::RegisterClient(int numofatoms)
{
    ReplicaID = -1;

    CClientCommand cmd;
    try{
        // prepare snapshot
        Snapshot.SetNumOfAtoms(numofatoms);

        // init command
        InitCommand(&cmd,Operation_RegisterClient);

        // prepare input data
        CXMLElement* p_ele = cmd.GetRootCommandElement();
        CSmallString job_id = getenv("INF_JOB_ID");
        if( job_id != NULL ) {
            p_ele->SetAttribute("job_id",job_id);
        }
        p_ele->SetAttribute("natoms",NumOfAtoms);

        // execute command
        ExecuteCommand(&cmd);

        // process response
        p_ele = cmd.GetRootResultElement();
        if( p_ele->GetAttribute("replica_id",ReplicaID) == false ) {
            LOGIC_ERROR("unable to get replica_id");
        }

    } catch(std::exception& e) {
        ES_ERROR_FROM_EXCEPTION("unable to process command",e);
        return(-1);
    }

    return(ReplicaID);
}
コード例 #15
0
ファイル: Command_VCS_Plc.cpp プロジェクト: RIVeR-Lab/eposcmd
CCommand_VCS_Plc::CCommand_VCS_Plc(DWORD p_ulCommandId)
{
    InitCommand(p_ulCommandId);
}
コード例 #16
0
CCommand_PS_MaxonSerialV1::CCommand_PS_MaxonSerialV1(DWORD dCommandId)
{
	InitCommand(dCommandId);
}
コード例 #17
0
CCommand_VCS_DataRecorder::CCommand_VCS_DataRecorder(DWORD p_ulCommandId)
{
    InitCommand(p_ulCommandId);
}
コード例 #18
0
ファイル: cmisc2.c プロジェクト: sharkcz/xtrkcad
void InitCmdMisc2( wMenu_p menu )
{
	if (extraButtons) {
		InitCommand( menu, CmdBridge, N_("Bridge"), bridge_bits, LEVEL2, IC_STICKY, ACCL_BRIDGE );
	}
}
コード例 #19
0
ファイル: Command.cpp プロジェクト: 128keaton/wpilib
/**
 * Creates a new command.
 * The name of this command will be default.
 */
Command::Command()
{
	InitCommand(NULL, -1.0);
}
コード例 #20
0
ファイル: Command.cpp プロジェクト: 128keaton/wpilib
/**
 * Creates a new command with the given name and no timeout.
 * @param name the name for this command
 */
Command::Command(const char *name)
{
	if (name == NULL)
		wpi_setWPIErrorWithContext(NullParameter, "name");
	InitCommand(name, -1.0);
}
コード例 #21
0
ファイル: Command.cpp プロジェクト: 128keaton/wpilib
/**
 * Creates a new command with the given timeout and a default name.
 * @param timeout the time (in seconds) before this command "times out"
 * @see Command#isTimedOut() isTimedOut()
 */
Command::Command(double timeout)
{
	if (timeout < 0.0)
		wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
	InitCommand(NULL, timeout);
}
コード例 #22
0
//-------------------------------------------------------------------------
// Update the command text
void ResetPermissionDialog::UpdateCommandText()
{
    UpdateCheckboxes(true);

    stringT folder;
    if (GetFolderText(folder, false, true, true) == 0)
        return;

    stringT cmd;
    InitCommand(cmd);

    // Form takeown.exe command
    if (bTakeOwn)
    {
        // Update the command prompt's title
        cmd += _TEXT("TITLE taking ownership of folder: ") + folder + STR_NEWLINE;

        cmd += STR_CMD_TAKEOWN;
        if (bRecurse)
            cmd += _TEXT(" /r ");

        if (bDontFollowLinks)
            cmd += _TEXT(" /SKIPSL ");

        cmd += _TEXT(" /f ") + folder + STR_NEWLINE2;
    }

    //
    // Form icacls.exe command
    //
    if (bResetPerm)
    {
        // Update the command prompt's title
        cmd += _TEXT("TITLE Taking ownership of folder: ") + folder + STR_NEWLINE;

        cmd += STR_CMD_ICACLS + folder;
        if (bRecurse)
            cmd += _TEXT(" /T ");

        if (bDontFollowLinks)
            cmd += _TEXT(" /L ");

        cmd += _TEXT(" /Q /C /RESET") + STR_NEWLINE2;
    }

    // Form attribute.exe command
    if (bRmHidSys)
    {
        // Update the command prompt's title
        cmd += _TEXT("TITLE Changing files attributes in folder: ") + folder + STR_NEWLINE;

        cmd += STR_CMD_ATTRIB;
        if (bRecurse)
            cmd += _TEXT(" /s ");

        cmd += _TEXT(" -h -s ") + folder + STR_NEWLINE2;
    }

    // Always add a pause and a new line
    cmd += STR_CMD_PAUSE;
    cmd += STR_NEWLINE;

    // Update the 
    SetCommandWindowText(cmd.c_str());
}