Пример #1
0
int COctopusScope::GetBFW( void )
{
	CString BFFW;

	if( !Scope_initialized ) 
		return 0;

	while ( ReadScope( 1 ) != "\0" ) 
		{ ; } //clear the buffer

	WriteScope("1CD?\r\n");
	
	Sleep(30);

	if ( ReadScope( 4 ).Find("1CD ") >= 0 ) 
	{
		return atol( ReadScope( 1 ) );//_wtol( ReadScope( 1 ) );
	} 
	else 
	{
		while ( ReadScope( 1 ) != "\0" ) 
			{ ; } //clear the buffer
	}
	return 0;
}
Пример #2
0
void COctopusScope::GetPosition( void )
{
	CString position;
	CString temp;

	if( !Scope_initialized ) 
		return;

	while ( ReadScope( 1 ) != "\0" ) 
		{ ; } //clear the buffer

	WriteScope("2POS?\r\n");
	
	Sleep(50);

	if ( ReadScope(5).Find("2POS ") >= 0 ) 
	{
		while ( temp != '\n') 
		{
			temp = ReadScope(1);
			position.Append(temp);
		}
		position_now = _tstof(position);
	} 
	else 
	{
		while ( ReadScope( 1 ) != "\0" ) 
			{ ; } //clear the buffer
	}
}
Пример #3
0
// ------------------------------------------------------------------------------------------------
bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, const char* end, bool const is64bits)
{
    // the first word contains the offset at which this block ends
	const uint64_t end_offset = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);

    // we may get 0 if reading reached the end of the file -
    // fbx files have a mysterious extra footer which I don't know
    // how to extract any information from, but at least it always
    // starts with a 0.
    if(!end_offset) {
        return false;
    }

    if(end_offset > Offset(input, end)) {
        TokenizeError("block offset is out of range",input, cursor);
    }
    else if(end_offset < Offset(input, cursor)) {
        TokenizeError("block offset is negative out of range",input, cursor);
    }

    // the second data word contains the number of properties in the scope
	const uint64_t prop_count = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);

    // the third data word contains the length of the property list
	const uint64_t prop_length = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end);

    // now comes the name of the scope/key
    const char* sbeg, *send;
    ReadString(sbeg, send, input, cursor, end);

    output_tokens.push_back(new_Token(sbeg, send, TokenType_KEY, Offset(input, cursor) ));

    // now come the individual properties
    const char* begin_cursor = cursor;
    for (unsigned int i = 0; i < prop_count; ++i) {
        ReadData(sbeg, send, input, cursor, begin_cursor + prop_length);

        output_tokens.push_back(new_Token(sbeg, send, TokenType_DATA, Offset(input, cursor) ));

        if(i != prop_count-1) {
            output_tokens.push_back(new_Token(cursor, cursor + 1, TokenType_COMMA, Offset(input, cursor) ));
        }
    }

    if (Offset(begin_cursor, cursor) != prop_length) {
        TokenizeError("property length not reached, something is wrong",input, cursor);
    }

    // at the end of each nested block, there is a NUL record to indicate
    // that the sub-scope exists (i.e. to distinguish between P: and P : {})
    // this NUL record is 13 bytes long on 32 bit version and 25 bytes long on 64 bit.
	const size_t sentinel_block_length = is64bits ? (sizeof(uint64_t)* 3 + 1) : (sizeof(uint32_t)* 3 + 1);

    if (Offset(input, cursor) < end_offset) {
        if (end_offset - Offset(input, cursor) < sentinel_block_length) {
            TokenizeError("insufficient padding bytes at block end",input, cursor);
        }

        output_tokens.push_back(new_Token(cursor, cursor + 1, TokenType_OPEN_BRACKET, Offset(input, cursor) ));

        // XXX this is vulnerable to stack overflowing ..
        while(Offset(input, cursor) < end_offset - sentinel_block_length) {
			ReadScope(output_tokens, input, cursor, input + end_offset - sentinel_block_length, is64bits);
        }
        output_tokens.push_back(new_Token(cursor, cursor + 1, TokenType_CLOSE_BRACKET, Offset(input, cursor) ));

        for (unsigned int i = 0; i < sentinel_block_length; ++i) {
            if(cursor[i] != '\0') {
                TokenizeError("failed to read nested block sentinel, expected all bytes to be 0",input, cursor);
            }
        }
        cursor += sentinel_block_length;
    }

    if (Offset(input, cursor) != end_offset) {
        TokenizeError("scope length not reached, something is wrong",input, cursor);
    }

    return true;
}
Пример #4
0
bool COctopusScope::Init( void )
{
	if( Scope_initialized ) 
	{
		AfxMessageBox(_T("Microscope already init()ed..."));
		return false;
	}

	pPortScope = new CPort;
	
	if( pPortScope == NULL ) 
	{
		AfxMessageBox(_T("pPortScope is a Null pointer..."));
		return false;
	}

	pPortScope->mPort.Format(_T("COM6"));
	
	if( pPortScope->OpenCPort() )//open and setup the comm port
	{
		Scope_initialized = true;

		//get rid of garbage in channel
		WriteScope("1UNIT?\r\n"); //anyone out there?	
		Sleep(30);
		while ( ReadScope(1) != "\0" ) 
			{ ; } //clear the buffer

		WriteScope("1UNIT?\r\n"); //anyone out there?
		Sleep(30);
		while ( ReadScope(1) != "\0" ) 
			{ ; } //clear the buffer
		
		WriteScope("1UNIT?\r\n"); //anyone out there?
		Sleep(30);

		if ( ReadScope(9).Find("1UNIT IX2") >=0 ) 
		{
			
			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("1LOG IN\r\n"));
			Sleep(30);
			
			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("2LOG IN\r\n"));
			Sleep(30);

			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("1SW ON\r\n"));
			Sleep(30);

			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("1SNDOB ON\r\n"));
			Sleep(30);
			
			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("2maxspd 70000,300000,250\r\n"));
			Sleep(30);
			
			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("2JOG ON\r\n"));
			Sleep(30);

			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("2NEARLMT 3000000\r\n"));
			Sleep(30);
			
			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("2FARLMT 100\r\n"));
			Sleep(30);
			
			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope("2JOGSNS 7\r\n"); //something like 100 microns per turn
			Sleep(30);
			
			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer
			WriteScope(_T("2joglmt ON\r\n"));
			Sleep(30);
			
			while ( ReadScope( 1 ) != "\0" ) { ; } //clear the buffer

			Sleep(100);

			int ob  = GetObj();
			int fw  = GetFW();
			int bfw = GetBFW();

			m_Radio_OBJ  = ob  - 1; 
			m_Radio_FW   = fw  - 1; 
			m_Radio_BFW  = bfw - 1; 

			UpdateData( false );

			return true;
		} 
		else 
		{
			Close();
			return false;
		}
	}
	else 
	{
		Close();
		return false;
	}
}
Пример #5
0
void COctopusScope::Objective( int obj )
{
	KillTimer( TIMER_SCOPE );
		
	GetPosition();
	
	int old_obj = GetObj();


	Sleep(100);

	old_position = u32(position_now); //this is where we will go back to. 

	//from pos 1 (10 x)
	//10x is too low relative to standard ref frame
	if ( old_obj == 1 ) 
		old_position = old_position + 39398;

	//from pos 3 (5 x)
	//5x is too high relative to standard ref frame
	if ( old_obj == 3 ) 
		old_position = old_position - 81380;
	
	//now we are in stanrd frame
	//add the correct offsets back
		
	//to pos 1 (10 x)
	//10x needs to be lowered relative to standard ref frame
	if ( obj == 1 ) 
		old_position = old_position - 39398;

	//to pos 3 (5 x)
	//5x needs to be augmented relative to standard ref frame
	if ( obj == 3 ) 
		old_position = old_position + 81380;

	while ( ReadScope( 1 ) != "\0" ) 
		{ ; } //clear the buffer

	//move to the bottom
	CString temp;
	temp.Format("2MOV d,%d\r\n", 10000 );
	
	//temp.Format("2MOV F,%d\r\n", old_position - 10000 );
	WriteScope( temp );

	while ( ReadScope( 6 ).Find(_T("2MOV +" )) == 0 )
	{
		Sleep( 200 );
	}

	ReadScope( 2 );

	//at bottom?
	GetPosition();
	GetPosition();

	if ( position_now < 15000 )
	{
		temp.Format(_T("1OB %d\r\n"), obj);
		WriteScope( temp );
		
		while ( ReadScope( 5 ).Find(_T("1OB +")) == 0 )
		{
			Sleep( 500 );
		}
		
		while ( GetObj() != obj )
		{
			Sleep( 500 );
		}

		temp.Format(_T("2MOV d,%d\r\n"), old_position );
		WriteScope( temp );
		Sleep(100);
	}

    SetTimer( TIMER_SCOPE, 250, NULL );
}
Пример #6
0
//----------------------------------------------------------------------------
VOID
ReadParameters2(
    IN  tNBTCONFIG  *pConfig,
    IN  HANDLE      ParmHandle
    )

/*++

Routine Description:

    This routine is called to read DHCPable parameters from the parameters
    section of the NBT section of the registry.

    This routine is primarily for the Vxd.

Arguments:

    pConfig     - A pointer to the configuration data structure.
    ParmHandle  - a handle to the parameters Key under Nbt

Return Value:

    Status

--*/

{
    ULONG           Node;
    ULONG           ReadOne;
    ULONG           ReadTwo;

    CTEPagedCode();

    Node = CTEReadSingleIntParameter(ParmHandle,     // handle of key to look under
                                     WS_NODE_TYPE,   // wide string name
                                     0,              // default value
                                     0);

    switch (Node)
    {
        case 2:
            NodeType = PNODE;
            break;

        case 4:
            NodeType = MNODE;
            break;

        case 8:
            NodeType = MSNODE;
            break;

        case 1:
            NodeType = BNODE;
            break;

        default:
            NodeType = BNODE | DEFAULT_NODE_TYPE;
            break;
    }

    // do a trick  here - read the registry twice for the same value, passing
    // in two different defaults, in order to determine if the registry
    // value has been defined or not - since it may be defined, but equal
    // to one default.
    ReadOne =  CTEReadSingleHexParameter(ParmHandle,
                                         WS_ALLONES_BCAST,
                                         DEFAULT_BCAST_ADDR,
                                         0);
    ReadTwo =  CTEReadSingleHexParameter(ParmHandle,
                                         WS_ALLONES_BCAST,
                                         0,
                                         0);
    if (ReadOne != ReadTwo)
    {
        NbtConfig.UseRegistryBcastAddr = FALSE;
    }
    else
    {
        NbtConfig.UseRegistryBcastAddr = TRUE;
        NbtConfig.RegistryBcastAddr = ReadTwo;
    }

    ReadScope(pConfig,ParmHandle);
}