增加手动机测试
This commit is contained in:
@@ -21,7 +21,7 @@ static char Codes[][6] =
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSerial() : Constructor
|
||||
// CPSerial() : Constructor
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSerialTask() : Function to run ReceiveTask() method as a task
|
||||
@@ -31,7 +31,7 @@ unsigned int WINAPI CSerialTask(LPVOID CSerialPtr)
|
||||
{
|
||||
TRACE( TEXT("Serial task has started \n") );
|
||||
// Call the ControlTask function in the specified plugin
|
||||
((CSerial *)CSerialPtr)->ReceiveTask();
|
||||
((CPSerial *)CSerialPtr)->ReceiveTask();
|
||||
|
||||
TRACE( TEXT("Serial task has completed \n") );
|
||||
|
||||
@@ -40,7 +40,7 @@ unsigned int WINAPI CSerialTask(LPVOID CSerialPtr)
|
||||
return(0);
|
||||
}
|
||||
|
||||
CSerial::CSerial()
|
||||
CPSerial::CPSerial()
|
||||
{
|
||||
// Serial port is not open
|
||||
m_PortHandle = INVALID_HANDLE_VALUE;
|
||||
@@ -93,9 +93,9 @@ CSerial::CSerial()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ~CSerial() : Destructor - Close the port and free up the CriticalSection
|
||||
// ~CPSerial() : Destructor - Close the port and free up the CriticalSection
|
||||
|
||||
CSerial::~CSerial()
|
||||
CPSerial::~CPSerial()
|
||||
{
|
||||
if( IsOpen( ) )
|
||||
{
|
||||
@@ -122,7 +122,7 @@ CSerial::~CSerial()
|
||||
// OpenPort() : Opens the serial port using the parameters set by default
|
||||
// or a call to SetPort
|
||||
|
||||
DWORD CSerial::Open()
|
||||
DWORD CPSerial::Open()
|
||||
{
|
||||
CString PortName;
|
||||
COMMTIMEOUTS CommTimeOut;
|
||||
@@ -201,7 +201,7 @@ DWORD CSerial::Open()
|
||||
// IsOpen() : returns true if the serial port is open
|
||||
//
|
||||
|
||||
int CSerial::IsOpen( )
|
||||
int CPSerial::IsOpen( )
|
||||
{
|
||||
return( m_PortHandle != INVALID_HANDLE_VALUE );
|
||||
}
|
||||
@@ -211,7 +211,7 @@ int CSerial::IsOpen( )
|
||||
// SetPort() : Store the serial settings. If the port is open then these
|
||||
// settings are applied now
|
||||
|
||||
int CSerial::SetPort(int Port,int Baud,char Parity,int Bits,int StopBits,int HandShake)
|
||||
int CPSerial::SetPort(int Port,int Baud,char Parity,int Bits,int StopBits,int HandShake)
|
||||
{
|
||||
// Use the current settings if the value has the default of 0
|
||||
m_Port = Port;
|
||||
@@ -243,7 +243,7 @@ int CSerial::SetPort(int Port,int Baud,char Parity,int Bits,int StopBits,int Han
|
||||
// GetPortData() : return the current settings
|
||||
//
|
||||
|
||||
void CSerial::GetPortData(int *Port,int *Baud,char *Parity,int *Bits,int *StopBits,int *HandShake)
|
||||
void CPSerial::GetPortData(int *Port,int *Baud,char *Parity,int *Bits,int *StopBits,int *HandShake)
|
||||
{
|
||||
// return the requested settings
|
||||
if( Port )
|
||||
@@ -265,7 +265,7 @@ void CSerial::GetPortData(int *Port,int *Baud,char *Parity,int *Bits,int *StopBi
|
||||
// ClosePort() : Close the port and shut down the monitoring thread
|
||||
//
|
||||
|
||||
DWORD CSerial::Close()
|
||||
DWORD CPSerial::Close()
|
||||
{
|
||||
//struct SerialList *Free;
|
||||
HANDLE Port;
|
||||
@@ -319,13 +319,13 @@ DWORD CSerial::Close()
|
||||
// Send functions // [8/11/2004]
|
||||
//
|
||||
|
||||
DWORD CSerial::Send(LPCSTR buffer, int l, BOOL /*needsResponse=FALSE*/)
|
||||
DWORD CPSerial::Send(LPCSTR buffer, int l, BOOL /*needsResponse=FALSE*/)
|
||||
{
|
||||
|
||||
return ( WritePort ((const char*) buffer, (DWORD) l));
|
||||
}
|
||||
/*
|
||||
DWORD CSerial::Send(CString buffer)
|
||||
DWORD CPSerial::Send(CString buffer)
|
||||
{
|
||||
char LocBuffer[MAX_OUTPUT_BUFFER_SIZE];
|
||||
int length = buffer.GetLength ();
|
||||
@@ -347,7 +347,7 @@ return res;
|
||||
// WritePort() : Writes the specifed bytes to the serial port
|
||||
//
|
||||
|
||||
DWORD CSerial::WritePort(const char *Buffer,DWORD Bytes)
|
||||
DWORD CPSerial::WritePort(const char *Buffer,DWORD Bytes)
|
||||
{
|
||||
DWORD BytesWritten, TotalWritten, Error;
|
||||
BOOL WriteState;
|
||||
@@ -413,7 +413,7 @@ DWORD CSerial::WritePort(const char *Buffer,DWORD Bytes)
|
||||
// ReceiveTask() : Internal function, this runs as a thread and provides the
|
||||
// OnRecieve and OnTransmit events
|
||||
|
||||
void CSerial::ReceiveTask( void )
|
||||
void CPSerial::ReceiveTask( void )
|
||||
{
|
||||
//DWORD BytesWritten;
|
||||
DWORD Events;
|
||||
@@ -478,7 +478,7 @@ void CSerial::ReceiveTask( void )
|
||||
// OnReceive() : Default OnReceive()
|
||||
// V114
|
||||
|
||||
void CSerial::OnReceive()
|
||||
void CPSerial::OnReceive()
|
||||
{
|
||||
// Dummy OnReceieve if not used
|
||||
char s[255]={0};
|
||||
@@ -510,7 +510,7 @@ void CSerial::OnReceive()
|
||||
// ReadPort() : Read the specifed number of bytes.
|
||||
//
|
||||
|
||||
DWORD CSerial::ReadPort(char *Buffer,DWORD Bytes)
|
||||
DWORD CPSerial::ReadPort(char *Buffer,DWORD Bytes)
|
||||
{
|
||||
DWORD BytesRead,Error;
|
||||
BOOL ReadState;
|
||||
@@ -564,7 +564,7 @@ DWORD CSerial::ReadPort(char *Buffer,DWORD Bytes)
|
||||
// ReadPort() : Read the specifed number of bytes into a CString class.
|
||||
//
|
||||
#if 0
|
||||
DWORD CSerial::ReadPort(CString &Buffer,DWORD Bytes)
|
||||
DWORD CPSerial::ReadPort(CString &Buffer,DWORD Bytes)
|
||||
{
|
||||
DWORD BytesRead;
|
||||
|
||||
@@ -581,7 +581,7 @@ DWORD CSerial::ReadPort(CString &Buffer,DWORD Bytes)
|
||||
// ProgramPort() : Internal function to setup the serial port
|
||||
//
|
||||
|
||||
int CSerial::ProgramPort(int Port,int Baud,char Parity,int Bits,int StopBits,int HandShake)
|
||||
int CPSerial::ProgramPort(int Port,int Baud,char Parity,int Bits,int StopBits,int HandShake)
|
||||
{
|
||||
CString Param,Params;
|
||||
DCB SerialDCB;
|
||||
@@ -728,7 +728,7 @@ int CSerial::ProgramPort(int Port,int Baud,char Parity,int Bits,int StopBits,int
|
||||
// OnTransmit() : Default OnTransmit()
|
||||
//
|
||||
|
||||
void CSerial::OnTransmit(int /*Item*/, DWORD /*Error*/)
|
||||
void CPSerial::OnTransmit(int /*Item*/, DWORD /*Error*/)
|
||||
{
|
||||
// Dummy OnTransmit if not used
|
||||
}
|
||||
@@ -738,7 +738,7 @@ void CSerial::OnTransmit(int /*Item*/, DWORD /*Error*/)
|
||||
// SetTimeouts() : Sets the rx and tx timeouts
|
||||
//
|
||||
|
||||
void CSerial::SetTimeouts( int RXTimeout, int TXTimeout )
|
||||
void CPSerial::SetTimeouts( int RXTimeout, int TXTimeout )
|
||||
{
|
||||
COMMTIMEOUTS CommTimeOut;
|
||||
|
||||
@@ -764,7 +764,7 @@ void CSerial::SetTimeouts( int RXTimeout, int TXTimeout )
|
||||
// AddToDebug() : Add the data to the debug output. State is 1 = rx 2 = tx
|
||||
// 3 = user
|
||||
|
||||
void CSerial::AddToDebug( const char * /*Ptr*/, DWORD /*BytesToCopy*/, int /*State*/ )
|
||||
void CPSerial::AddToDebug( const char * /*Ptr*/, DWORD /*BytesToCopy*/, int /*State*/ )
|
||||
{
|
||||
//ZH
|
||||
#if 0
|
||||
@@ -831,7 +831,7 @@ void CSerial::AddToDebug( const char * /*Ptr*/, DWORD /*BytesToCopy*/, int /*Sta
|
||||
// FlushPort() : Removes all characters in the serial buffer
|
||||
//
|
||||
/*
|
||||
int CSerial::FlushPort(void)
|
||||
int CPSerial::FlushPort(void)
|
||||
{
|
||||
int TXTimeout,RXTimeout;
|
||||
char FlushBuffer[256];
|
||||
@@ -879,7 +879,7 @@ return(BytesTotal);
|
||||
// MaxPort() :
|
||||
//
|
||||
|
||||
int CSerial::MaxPort()
|
||||
int CPSerial::MaxPort()
|
||||
{
|
||||
// return the max port, :-)
|
||||
return(8);
|
||||
@@ -892,7 +892,7 @@ int CSerial::MaxPort()
|
||||
// data sent.
|
||||
//
|
||||
|
||||
int CSerial::Transmit(const char * /*Buffer*/,DWORD /*Bytes*/)
|
||||
int CPSerial::Transmit(const char * /*Buffer*/,DWORD /*Bytes*/)
|
||||
{
|
||||
/*
|
||||
struct SerialList *Ptr;
|
||||
@@ -952,7 +952,7 @@ int CSerial::Transmit(const char * /*Buffer*/,DWORD /*Bytes*/)
|
||||
//
|
||||
|
||||
/*
|
||||
int CSerial::AddReceived( const char *Buffer,DWORD Bytes)
|
||||
int CPSerial::AddReceived( const char *Buffer,DWORD Bytes)
|
||||
{
|
||||
DWORD index = 0; //primary buffer index
|
||||
struct SerialList *Ptr;
|
||||
@@ -1081,7 +1081,7 @@ return(TRUE);
|
||||
//
|
||||
//ZH
|
||||
/*
|
||||
char *CSerial::GetNextReceived(void)
|
||||
char *CPSerial::GetNextReceived(void)
|
||||
{
|
||||
struct SerialList *Free;
|
||||
|
||||
@@ -1120,7 +1120,7 @@ return( m_RXTempPtr );
|
||||
// ascii hex
|
||||
//
|
||||
|
||||
int CSerial::HexToInt(char *Data, int Bytes)
|
||||
int CPSerial::HexToInt(char *Data, int Bytes)
|
||||
{
|
||||
int Byte;
|
||||
int HexChar, Value;
|
||||
@@ -1150,7 +1150,7 @@ int CSerial::HexToInt(char *Data, int Bytes)
|
||||
//
|
||||
//ZH
|
||||
/*
|
||||
void CSerial::RegisterDebugWindow()
|
||||
void CPSerial::RegisterDebugWindow()
|
||||
{
|
||||
// Register the CSerialRaw window for future use
|
||||
WNDCLASS wndcls;
|
||||
@@ -1160,7 +1160,7 @@ wndcls.hInstance = AfxGetInstanceHandle( );
|
||||
wndcls.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
|
||||
wndcls.lpszClassName = TEXT("CSerial");
|
||||
wndcls.lpszClassName = TEXT("CPSerial");
|
||||
AfxRegisterClass( &wndcls );
|
||||
}
|
||||
*/
|
||||
@@ -1172,7 +1172,7 @@ AfxRegisterClass( &wndcls );
|
||||
// SendBuffer() : Internal function, this writes the next block of data
|
||||
// queued to the serial port.
|
||||
|
||||
void CSerial::SendBuffer(int Next)
|
||||
void CPSerial::SendBuffer(int Next)
|
||||
{
|
||||
struct SerialList *Free;
|
||||
// DWORD BytesWritten;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*$!! Serial.h
|
||||
*$!!
|
||||
*$!! DESCRIPTION
|
||||
*$!! Header file for CSerial.
|
||||
*$!! Header file for CPSerial.
|
||||
*$!!
|
||||
*$!! AUTHOR
|
||||
*$!! M.J.S.Gooder.
|
||||
@@ -69,17 +69,17 @@ const int CS_DEFAULT_RX_TIMEOUT = 25;
|
||||
const int CS_DEFAULT_TX_TIMEOUT = 1000;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// The CSerial class
|
||||
// The CPSerial class
|
||||
|
||||
class CSerial : public CMMIO
|
||||
class CPSerial : public CMMIO
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CSerial();
|
||||
CPSerial();
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CSerial();
|
||||
virtual ~CPSerial();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
// Serial.cpp
|
||||
|
||||
#include "stdafx.h"
|
||||
#include<WinBase.h>
|
||||
#include<WinDef.h>
|
||||
#include "Serial.h"
|
||||
|
||||
CSerial::CSerial()
|
||||
{
|
||||
|
||||
memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) );
|
||||
memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) );
|
||||
m_hIDComDev = NULL;
|
||||
m_bOpened = FALSE;
|
||||
|
||||
}
|
||||
|
||||
CSerial::~CSerial()
|
||||
{
|
||||
|
||||
Close();
|
||||
|
||||
}
|
||||
|
||||
BOOL CSerial::Open( int nPort, int nBaud )
|
||||
{
|
||||
|
||||
if( m_bOpened ) return( TRUE );
|
||||
|
||||
TCHAR szPort[15];
|
||||
TCHAR szComParams[50];
|
||||
DCB dcb;
|
||||
|
||||
wsprintf( szPort, _T("COM%d"), nPort );
|
||||
m_hIDComDev = CreateFile( szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL );
|
||||
if( m_hIDComDev == NULL ) return( FALSE );
|
||||
|
||||
memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) );
|
||||
memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) );
|
||||
|
||||
COMMTIMEOUTS CommTimeOuts;
|
||||
CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF;
|
||||
CommTimeOuts.ReadTotalTimeoutMultiplier = 0;
|
||||
CommTimeOuts.ReadTotalTimeoutConstant = 0;
|
||||
CommTimeOuts.WriteTotalTimeoutMultiplier = 0;
|
||||
CommTimeOuts.WriteTotalTimeoutConstant = 5000;
|
||||
SetCommTimeouts( m_hIDComDev, &CommTimeOuts );
|
||||
|
||||
wsprintf( szComParams, _T("COM%d:%d,n,8,1"), nPort, nBaud );
|
||||
|
||||
m_OverlappedRead.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
|
||||
m_OverlappedWrite.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
|
||||
|
||||
dcb.DCBlength = sizeof( DCB );
|
||||
GetCommState( m_hIDComDev, &dcb );
|
||||
dcb.BaudRate = nBaud;
|
||||
dcb.ByteSize = 8;
|
||||
unsigned char ucSet;
|
||||
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_DTRDSR ) != 0 );
|
||||
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_RTSCTS ) != 0 );
|
||||
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_XONXOFF ) != 0 );
|
||||
if( !SetCommState( m_hIDComDev, &dcb ) ||
|
||||
!SetupComm( m_hIDComDev, 10000, 10000 ) ||
|
||||
m_OverlappedRead.hEvent == NULL ||
|
||||
m_OverlappedWrite.hEvent == NULL ){
|
||||
DWORD dwError(0);
|
||||
dwError = GetLastError();
|
||||
if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent );
|
||||
if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent );
|
||||
CloseHandle( m_hIDComDev );
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
m_bOpened = TRUE;
|
||||
|
||||
return( m_bOpened );
|
||||
|
||||
}
|
||||
|
||||
BOOL CSerial::Close( void )
|
||||
{
|
||||
|
||||
if( !m_bOpened || m_hIDComDev == NULL ) return( TRUE );
|
||||
|
||||
if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent );
|
||||
if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent );
|
||||
CloseHandle( m_hIDComDev );
|
||||
m_bOpened = FALSE;
|
||||
m_hIDComDev = NULL;
|
||||
|
||||
return( TRUE );
|
||||
|
||||
}
|
||||
|
||||
BOOL CSerial::WriteCommByte( unsigned char ucByte )
|
||||
{
|
||||
BOOL bWriteStat;
|
||||
DWORD dwBytesWritten;
|
||||
|
||||
bWriteStat = WriteFile( m_hIDComDev, (LPSTR) &ucByte, 1, &dwBytesWritten, &m_OverlappedWrite );
|
||||
if( !bWriteStat && ( GetLastError() == ERROR_IO_PENDING ) ){
|
||||
if( WaitForSingleObject( m_OverlappedWrite.hEvent, 1000 ) ) dwBytesWritten = 0;
|
||||
else{
|
||||
GetOverlappedResult( m_hIDComDev, &m_OverlappedWrite, &dwBytesWritten, FALSE );
|
||||
m_OverlappedWrite.Offset += dwBytesWritten;
|
||||
}
|
||||
}
|
||||
|
||||
return( TRUE );
|
||||
|
||||
}
|
||||
|
||||
int CSerial::SendData( const char *buffer, int size )
|
||||
{
|
||||
|
||||
if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );
|
||||
|
||||
DWORD dwBytesWritten = 0;
|
||||
int i;
|
||||
for( i=0; i<size; i++ ){
|
||||
WriteCommByte( buffer[i] );
|
||||
dwBytesWritten++;
|
||||
}
|
||||
|
||||
return( (int) dwBytesWritten );
|
||||
|
||||
}
|
||||
|
||||
int CSerial::ReadDataWaiting( void )
|
||||
{
|
||||
|
||||
if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );
|
||||
|
||||
DWORD dwErrorFlags;
|
||||
COMSTAT ComStat;
|
||||
|
||||
ClearCommError( m_hIDComDev, &dwErrorFlags, &ComStat );
|
||||
|
||||
return( (int) ComStat.cbInQue );
|
||||
|
||||
}
|
||||
|
||||
int CSerial::ReadData( void *buffer, int limit )
|
||||
{
|
||||
|
||||
if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );
|
||||
|
||||
BOOL bReadStatus;
|
||||
DWORD dwBytesRead, dwErrorFlags;
|
||||
COMSTAT ComStat;
|
||||
|
||||
ClearCommError( m_hIDComDev, &dwErrorFlags, &ComStat );
|
||||
if( !ComStat.cbInQue ) return( 0 );
|
||||
|
||||
dwBytesRead = (DWORD) ComStat.cbInQue;
|
||||
if( limit < (int) dwBytesRead ) dwBytesRead = (DWORD) limit;
|
||||
|
||||
bReadStatus = ReadFile( m_hIDComDev, buffer, dwBytesRead, &dwBytesRead, &m_OverlappedRead );
|
||||
if( !bReadStatus ){
|
||||
if( GetLastError() == ERROR_IO_PENDING ){
|
||||
WaitForSingleObject( m_OverlappedRead.hEvent, 2000 );
|
||||
return( (int) dwBytesRead );
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
return( (int) dwBytesRead );
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// Serial.h
|
||||
|
||||
#ifndef __SERIAL_H__
|
||||
#define __SERIAL_H__
|
||||
|
||||
#define FC_DTRDSR 0x01
|
||||
#define FC_RTSCTS 0x02
|
||||
#define FC_XONXOFF 0x04
|
||||
#define ASCII_BEL 0x07
|
||||
#define ASCII_BS 0x08
|
||||
#define ASCII_LF 0x0A
|
||||
#define ASCII_CR 0x0D
|
||||
#define ASCII_XON 0x11
|
||||
#define ASCII_XOFF 0x13
|
||||
|
||||
class CSerial
|
||||
{
|
||||
|
||||
public:
|
||||
CSerial();
|
||||
~CSerial();
|
||||
|
||||
BOOL Open( int nPort = 2, int nBaud = 9600 );
|
||||
BOOL Close( void );
|
||||
|
||||
int ReadData( void *, int );
|
||||
int SendData( const char *, int );
|
||||
int ReadDataWaiting( void );
|
||||
|
||||
BOOL IsOpened( void ){ return( m_bOpened ); }
|
||||
|
||||
protected:
|
||||
BOOL WriteCommByte( unsigned char );
|
||||
|
||||
HANDLE m_hIDComDev;
|
||||
OVERLAPPED m_OverlappedRead, m_OverlappedWrite;
|
||||
BOOL m_bOpened;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1103,3 +1103,8 @@ Construct Cso7_Proto.
|
||||
|
||||
Init:Open device succeed .
|
||||
|
||||
_start_machine
|
||||
Exit: Exit_SO7Usb
|
||||
|
||||
Destruct Cso7_Proto.
|
||||
|
||||
|
||||
@@ -582,15 +582,14 @@ BEGIN
|
||||
CONTROL "4",IDC_RADIO_TC4000_CHANNEL4,"Button",BS_AUTORADIOBUTTON,451,213,20,10
|
||||
END
|
||||
|
||||
IDD_SO7_UTIL_MANUAL_MACHINE DIALOGEX 0, 0, 333, 330
|
||||
IDD_SO7_UTIL_MANUAL_MACHINE DIALOGEX 0, 0, 356, 330
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Manual Machine"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
PUSHBUTTON "Exit",IDCANCEL,276,292,50,14
|
||||
PUSHBUTTON "Exit",IDCANCEL,299,292,50,14
|
||||
PUSHBUTTON "Start Machine",IDC_BUTTON_SO7_MANUAL_MACHINE_START_MACHINE,24,39,50,14
|
||||
PUSHBUTTON "Stop Machine",IDC_BUTTON_SO7_MANUAL_MACHINE_STOP_MACHINE,24,65,50,14
|
||||
EDITTEXT IDC_EDIT1,20,217,252,58,ES_AUTOHSCROLL
|
||||
GROUPBOX "Position",IDC_STATIC,19,99,297,107
|
||||
GROUPBOX "Send Data",IDC_STATIC,86,18,237,76
|
||||
PUSHBUTTON "Send",IDC_BUTTON_SO7_MANUAL_MACHINE_SEND_DATA,267,74,50,14
|
||||
@@ -620,6 +619,7 @@ BEGIN
|
||||
LTEXT "Scale resolution",IDC_STATIC,209,119,51,11
|
||||
PUSHBUTTON "Clear All",IDC_BUTTON_SO7_MANUAL_MACHINE_CLEAR_MSG,280,224,40,17
|
||||
PUSHBUTTON "Save as...",IDC_BUTTON_SO7_MANUAL_MACHINE_SAVE_MSG,280,249,40,17
|
||||
EDITTEXT IDC_EDIT_MANUAL_MACHINE_MSG,19,216,254,63,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
|
||||
END
|
||||
|
||||
IDD_SO7_UTIL_VERIFICATION_ALGORITHM DIALOGEX 0, 0, 617, 254
|
||||
@@ -801,7 +801,7 @@ BEGIN
|
||||
IDD_SO7_UTIL_MANUAL_MACHINE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 326
|
||||
RIGHTMARGIN, 349
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 306
|
||||
END
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "SO7_Move_Location.h"
|
||||
#include "SO7_Automatic_Zoom.h"
|
||||
|
||||
extern CSerial* m_pSO7_Serial;
|
||||
extern CPSerial* m_pSO7_PCDSerial;
|
||||
extern CSO7_Proto* m_pSO7_Proto;
|
||||
extern CLogger* g_pLoggerDebug;
|
||||
#define PI 3.1415926535897932384626433
|
||||
@@ -143,9 +143,9 @@ BOOL CSO7_Automatic_Zoom::OnInitDialog()
|
||||
int arWidth[] = {330,450, -1 };
|
||||
m_StatusBar.SetParts(3, arWidth);
|
||||
((CButton *)GetDlgItem(IDC_RADIO_SENDCMD))->SetCheck(true);
|
||||
if (m_pSO7_Serial)
|
||||
if (m_pSO7_PCDSerial)
|
||||
{
|
||||
m_pSO7_Serial->GetPortData(&Port,&Baud,&Parity,&Bits,&StopBits,&HandShake);
|
||||
m_pSO7_PCDSerial->GetPortData(&Port,&Baud,&Parity,&Bits,&StopBits,&HandShake);
|
||||
Params.Format( TEXT("[COM%d]"), Port );
|
||||
Param.Format( TEXT(" Baud=%d"), Baud );
|
||||
Params += Param;
|
||||
@@ -157,7 +157,7 @@ BOOL CSO7_Automatic_Zoom::OnInitDialog()
|
||||
Params += Param;
|
||||
m_StatusBar.SetText(Params, 0, 0);
|
||||
|
||||
if(m_pSO7_Serial->Open())
|
||||
if(m_pSO7_PCDSerial->Open())
|
||||
{
|
||||
m_StatusBar.SetText(_T("成功打开串口。"), 1, 0);
|
||||
|
||||
@@ -408,8 +408,8 @@ void CSO7_Automatic_Zoom::OnBnClickedCancel()
|
||||
{
|
||||
delete g_pLoggerDebug;
|
||||
g_pLoggerDebug=NULL;
|
||||
delete m_pSO7_Serial;
|
||||
m_pSO7_Serial=NULL;
|
||||
delete m_pSO7_PCDSerial;
|
||||
m_pSO7_PCDSerial=NULL;
|
||||
KillTimer(1);
|
||||
KillTimer(2);
|
||||
KillTimer(3);
|
||||
@@ -532,24 +532,24 @@ double CSO7_Automatic_Zoom::ReadZoomAngle()
|
||||
{
|
||||
double dZoomAngle(-1);
|
||||
char sendData[6]={'A','D',':','0',13,10};
|
||||
DWORD iWriteByte=m_pSO7_Serial->Send(sendData,6);
|
||||
DWORD iWriteByte=m_pSO7_PCDSerial->Send(sendData,6);
|
||||
|
||||
INT iRetrys(0);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(10);
|
||||
}
|
||||
if (m_pSO7_Serial->m_iRecvState)
|
||||
if (m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
Sleep(50);
|
||||
|
||||
USES_CONVERSION;
|
||||
char *cRecvData= NULL;
|
||||
char *token = NULL;
|
||||
char cTemp[20]={0};
|
||||
cRecvData=T2A(m_pSO7_Serial->m_csRecv);
|
||||
cRecvData=T2A(m_pSO7_PCDSerial->m_csRecv);
|
||||
char seps[] = "$AD:";
|
||||
|
||||
token = strtok(cRecvData,seps);
|
||||
@@ -567,8 +567,8 @@ double CSO7_Automatic_Zoom::ReadZoomAngle()
|
||||
};
|
||||
token=NULL;
|
||||
cRecvData=NULL;
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
|
||||
return dZoomAngle;
|
||||
|
||||
@@ -588,72 +588,72 @@ BOOL CSO7_Automatic_Zoom::CalibrateEncoder()
|
||||
csRightRecv.Format(_T("@OK\r\n"));
|
||||
INT iRetrys(0);
|
||||
DWORD iWriteByte(0);
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
|
||||
//Phase I
|
||||
iWriteByte=m_pSO7_Serial->Send(sendDataI,12);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20 && iWriteByte==12)
|
||||
iWriteByte=m_pSO7_PCDSerial->Send(sendDataI,12);
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20 && iWriteByte==12)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(50);
|
||||
}
|
||||
|
||||
if (m_pSO7_Serial->m_iRecvState)
|
||||
if (m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
Sleep(100);
|
||||
|
||||
if(m_pSO7_Serial->m_csRecv==csRightRecv)
|
||||
if(m_pSO7_PCDSerial->m_csRecv==csRightRecv)
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
iRetrys=0;
|
||||
iWriteByte=0;
|
||||
//Phase II
|
||||
|
||||
iWriteByte=m_pSO7_Serial->Send(sendDataII,6);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
iWriteByte=m_pSO7_PCDSerial->Send(sendDataII,6);
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(50);
|
||||
}
|
||||
if(m_pSO7_Serial->m_iRecvState)
|
||||
if(m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
Sleep(100);
|
||||
|
||||
if(m_pSO7_Serial->m_csRecv==csRightRecv)
|
||||
if(m_pSO7_PCDSerial->m_csRecv==csRightRecv)
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
iRetrys=0;
|
||||
iWriteByte=0;
|
||||
//Phase III
|
||||
|
||||
iWriteByte=m_pSO7_Serial->Send(sendDataIII,6);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
iWriteByte=m_pSO7_PCDSerial->Send(sendDataIII,6);
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(50);
|
||||
}
|
||||
if(m_pSO7_Serial->m_iRecvState)
|
||||
if(m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
Sleep(100);
|
||||
|
||||
if(m_pSO7_Serial->m_csRecv==csRightRecv)
|
||||
if(m_pSO7_PCDSerial->m_csRecv==csRightRecv)
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
iRetrys=0;
|
||||
iWriteByte=0;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -664,8 +664,8 @@ BOOL CSO7_Automatic_Zoom::CalibrateEncoder()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -677,8 +677,8 @@ BOOL CSO7_Automatic_Zoom::CalibrateEncoder()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -749,7 +749,7 @@ void CSO7_Automatic_Zoom::OnBnClickedButtonSendData()
|
||||
UpdateData(TRUE);
|
||||
CString csSendData("");
|
||||
GetDlgItem(IDC_EDIT_DATASEND)->GetWindowText(csSendData);
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
USES_CONVERSION;
|
||||
//加上回车换行符
|
||||
CString csTemp;
|
||||
@@ -759,7 +759,7 @@ void CSO7_Automatic_Zoom::OnBnClickedButtonSendData()
|
||||
const char* cSendData;
|
||||
cSendData=T2A(csSendData);
|
||||
DWORD iSendDataLength=csSendData.GetLength();
|
||||
DWORD iWriteByte=m_pSO7_Serial->Send(cSendData,iSendDataLength);
|
||||
DWORD iWriteByte=m_pSO7_PCDSerial->Send(cSendData,iSendDataLength);
|
||||
|
||||
((CListBox *)GetDlgItem(IDC_LIST_SHOWMESSAGE))->InsertString(-1,CString(_T("[Send]: "))+cSendData);//
|
||||
|
||||
@@ -767,36 +767,36 @@ void CSO7_Automatic_Zoom::OnBnClickedButtonSendData()
|
||||
m_StatusBar.SetText(csSendData, 1, 0);
|
||||
//接受数据
|
||||
INT iRetrys(0);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20)
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(100);
|
||||
}
|
||||
if (m_pSO7_Serial->m_iRecvState)
|
||||
if (m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
{
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
INT iRetrys2(0);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys2<60)
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys2<60)
|
||||
{
|
||||
iRetrys2++;
|
||||
Sleep(100);
|
||||
}
|
||||
((CListBox *)GetDlgItem(IDC_LIST_SHOWMESSAGE))->InsertString(-1,CString(_T("[Recv]: "))+m_pSO7_Serial->m_csRecv);
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
csSendData.Format(_T("Recv(%dByte)"),m_pSO7_Serial->m_iRecvByte);
|
||||
((CListBox *)GetDlgItem(IDC_LIST_SHOWMESSAGE))->InsertString(-1,CString(_T("[Recv]: "))+m_pSO7_PCDSerial->m_csRecv);
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
csSendData.Format(_T("Recv(%dByte)"),m_pSO7_PCDSerial->m_iRecvByte);
|
||||
m_StatusBar.SetText(csSendData, 2, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
((CListBox *)GetDlgItem(IDC_LIST_SHOWMESSAGE))->InsertString(-1,CString(_T("[Recv]: "))+m_pSO7_Serial->m_csRecv);
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
csSendData.Format(_T("Recv(%dByte)"),m_pSO7_Serial->m_iRecvByte);
|
||||
((CListBox *)GetDlgItem(IDC_LIST_SHOWMESSAGE))->InsertString(-1,CString(_T("[Recv]: "))+m_pSO7_PCDSerial->m_csRecv);
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
csSendData.Format(_T("Recv(%dByte)"),m_pSO7_PCDSerial->m_iRecvByte);
|
||||
m_StatusBar.SetText(csSendData, 2, 0);
|
||||
|
||||
}
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "SO7_UtilDlg.h"
|
||||
// CSO7_UtilDlg ¶Ô»°¿ò
|
||||
|
||||
extern CSerial* m_pSO7_Serial;
|
||||
extern CPSerial* m_pSO7_PCDSerial;
|
||||
extern CSO7_Proto* m_pSO7_Proto;
|
||||
CLogger* g_pLoggerDebug=NULL;
|
||||
CSO7_VolComp* g_pVolComp=NULL;
|
||||
@@ -437,9 +437,6 @@ void CSO7_UtilDlg::OnBnClickedButtonSo7ResetXyz()
|
||||
//=====================================================================
|
||||
void CSO7_UtilDlg::OnBnClickedButtonMoveTo()
|
||||
{
|
||||
if (!m_pSO7_Serial)
|
||||
m_pSO7_Serial = new CSerial();
|
||||
|
||||
if(!g_pVolComp)
|
||||
g_pVolComp=new CSO7_VolComp();
|
||||
|
||||
@@ -448,11 +445,6 @@ void CSO7_UtilDlg::OnBnClickedButtonMoveTo()
|
||||
delete pSO7_Move_Location;
|
||||
pSO7_Move_Location=NULL;
|
||||
|
||||
if (m_pSO7_Serial)
|
||||
{
|
||||
delete m_pSO7_Serial;
|
||||
m_pSO7_Serial=NULL;
|
||||
}
|
||||
if (g_pVolComp)
|
||||
{
|
||||
delete g_pVolComp;
|
||||
@@ -465,8 +457,8 @@ void CSO7_UtilDlg::OnBnClickedButtonMoveTo()
|
||||
void CSO7_UtilDlg::OnBnClickedButtonAutoZoom()
|
||||
{
|
||||
|
||||
if (!m_pSO7_Serial)
|
||||
m_pSO7_Serial = new CSerial();
|
||||
if (!m_pSO7_PCDSerial)
|
||||
m_pSO7_PCDSerial = new CPSerial();
|
||||
|
||||
delete g_pLoggerDebug;
|
||||
g_pLoggerDebug=NULL;
|
||||
@@ -956,17 +948,17 @@ void CSO7_UtilDlg::OnBnClickedButtonLoadSo7config()
|
||||
void CSO7_UtilDlg::OnBnClickedButtonSetupSo7config()
|
||||
{
|
||||
KillTimer(1);
|
||||
if (!m_pSO7_Serial)
|
||||
m_pSO7_Serial = new CSerial();
|
||||
if (!m_pSO7_PCDSerial)
|
||||
m_pSO7_PCDSerial = new CPSerial();
|
||||
|
||||
CSetup_so7config* pSetup_so7config=new CSetup_so7config;
|
||||
pSetup_so7config->DoModal();
|
||||
delete pSetup_so7config;
|
||||
|
||||
if (m_pSO7_Serial)
|
||||
if (m_pSO7_PCDSerial)
|
||||
{
|
||||
delete m_pSO7_Serial;
|
||||
m_pSO7_Serial=NULL;
|
||||
delete m_pSO7_PCDSerial;
|
||||
m_pSO7_PCDSerial=NULL;
|
||||
}
|
||||
SetTimer(1,150,NULL);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ protected:
|
||||
protected:
|
||||
CFont m_BTNFont;
|
||||
public:
|
||||
BOOL ThreePntsConstructionPanel(Struct_3DPoint* pArr,double* Coe);
|
||||
double PointToPanelDistance(Struct_3DPoint PntPos,double* Coe);
|
||||
BOOL ThreePntsConstructPlane(Struct_3DPoint* pArr,double* Coe);
|
||||
double PointToPlaneDistance(Struct_3DPoint PntPos,double* Coe);
|
||||
|
||||
afx_msg void OnBnClickedButtonImagedll2laserCalculate();
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
#include "Setup_so7config.h"
|
||||
extern CSerial* m_pSO7_Serial;
|
||||
extern CPSerial* m_pSO7_PCDSerial;
|
||||
extern CSO7_Proto* m_pSO7_Proto;
|
||||
#define PI 3.1415926535897932384626433
|
||||
// CSetup_so7config dialog
|
||||
@@ -96,9 +96,9 @@ BOOL CSetup_so7config::OnInitDialog()
|
||||
m_pSO7_Proto->g_machine.zm._Move_Speed_Gear=2;
|
||||
|
||||
((CButton *)GetDlgItem(IDC_RADIO_SO7CONFIG_ZOOM_MOVE_FAST))->SetCheck(true);
|
||||
if (m_pSO7_Serial)
|
||||
if (m_pSO7_PCDSerial)
|
||||
{
|
||||
if(m_pSO7_Serial->Open())
|
||||
if(m_pSO7_PCDSerial->Open())
|
||||
{
|
||||
ChangGUIWithStep(m_nStep);
|
||||
m_csMsg.Format(_T("´®¿Ú´ò¿ªÕý³££¡"));
|
||||
@@ -389,24 +389,24 @@ double CSetup_so7config::ReadZoomAngle()
|
||||
_bReading=true;
|
||||
double dZoomAngle(-1);
|
||||
char sendData[6]={'A','D',':','0',13,10};
|
||||
DWORD iWriteByte=m_pSO7_Serial->Send(sendData,6);
|
||||
DWORD iWriteByte=m_pSO7_PCDSerial->Send(sendData,6);
|
||||
|
||||
INT iRetrys(0);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(10);
|
||||
}
|
||||
if (m_pSO7_Serial->m_iRecvState)
|
||||
if (m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
Sleep(40);//200
|
||||
|
||||
char *cRecvData= NULL;
|
||||
char *token = NULL;
|
||||
char cTemp[20]={0};
|
||||
USES_CONVERSION;
|
||||
cRecvData=T2A(m_pSO7_Serial->m_csRecv);
|
||||
cRecvData=T2A(m_pSO7_PCDSerial->m_csRecv);
|
||||
|
||||
char seps[] = "$AD:";
|
||||
|
||||
@@ -419,8 +419,8 @@ double CSetup_so7config::ReadZoomAngle()
|
||||
};
|
||||
token=NULL;
|
||||
cRecvData=NULL;
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
_bReading=false;
|
||||
return dZoomAngle;
|
||||
}
|
||||
@@ -484,72 +484,72 @@ BOOL CSetup_so7config::CalibrateEncoder()
|
||||
csRightRecv.Format(_T("@OK\r\n"));
|
||||
INT iRetrys(0);
|
||||
DWORD iWriteByte(0);
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
|
||||
//Phase I
|
||||
iWriteByte=m_pSO7_Serial->Send(sendDataI,12);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20 && iWriteByte==12)
|
||||
iWriteByte=m_pSO7_PCDSerial->Send(sendDataI,12);
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20 && iWriteByte==12)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(50);
|
||||
}
|
||||
|
||||
if (m_pSO7_Serial->m_iRecvState)
|
||||
if (m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
Sleep(100);
|
||||
|
||||
if(m_pSO7_Serial->m_csRecv==csRightRecv)
|
||||
if(m_pSO7_PCDSerial->m_csRecv==csRightRecv)
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
iRetrys=0;
|
||||
iWriteByte=0;
|
||||
//Phase II
|
||||
|
||||
iWriteByte=m_pSO7_Serial->Send(sendDataII,6);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
iWriteByte=m_pSO7_PCDSerial->Send(sendDataII,6);
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(50);
|
||||
}
|
||||
if(m_pSO7_Serial->m_iRecvState)
|
||||
if(m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
Sleep(100);
|
||||
|
||||
if(m_pSO7_Serial->m_csRecv==csRightRecv)
|
||||
if(m_pSO7_PCDSerial->m_csRecv==csRightRecv)
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
iRetrys=0;
|
||||
iWriteByte=0;
|
||||
//Phase III
|
||||
|
||||
iWriteByte=m_pSO7_Serial->Send(sendDataIII,6);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
iWriteByte=m_pSO7_PCDSerial->Send(sendDataIII,6);
|
||||
while(!m_pSO7_PCDSerial->m_iRecvState && iRetrys<20 && iWriteByte==6)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(50);
|
||||
}
|
||||
if(m_pSO7_Serial->m_iRecvState)
|
||||
if(m_pSO7_PCDSerial->m_iRecvState)
|
||||
{
|
||||
if(m_pSO7_Serial->m_csRecv==_T(""))
|
||||
if(m_pSO7_PCDSerial->m_csRecv==_T(""))
|
||||
Sleep(100);
|
||||
|
||||
if(m_pSO7_Serial->m_csRecv==csRightRecv)
|
||||
if(m_pSO7_PCDSerial->m_csRecv==csRightRecv)
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
iRetrys=0;
|
||||
iWriteByte=0;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -560,8 +560,8 @@ BOOL CSetup_so7config::CalibrateEncoder()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -573,8 +573,8 @@ BOOL CSetup_so7config::CalibrateEncoder()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
m_pSO7_Serial->m_iRecvState=FALSE;
|
||||
m_pSO7_PCDSerial->m_csRecv=_T("");
|
||||
m_pSO7_PCDSerial->m_iRecvState=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "resource.h"
|
||||
#include "..\..\..\SevenOcean\CMMIO_SERIAL.H"
|
||||
#include "..\..\..\SevenOcean\Serial.h"
|
||||
#include "So7_Manual_Machine.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
#define MAX_OUTPUT_BUFFER_SIZE 512
|
||||
extern CSerial* m_pSO7_Serial;
|
||||
// CSo7_Manual_Machine dialog
|
||||
|
||||
@@ -24,6 +25,7 @@ CSo7_Manual_Machine::~CSo7_Manual_Machine()
|
||||
|
||||
void CSo7_Manual_Machine::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
DDX_Control(pDX, IDC_EDIT_MANUAL_MACHINE_MSG, m_edMSG);
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
@@ -95,26 +97,11 @@ void CSo7_Manual_Machine::OnBnClickedButtonSo7ManualMachineStartMachine()
|
||||
{
|
||||
if (m_pSO7_Serial)
|
||||
{
|
||||
CString Param,Params;
|
||||
int Port;
|
||||
int Baud;
|
||||
char Parity;
|
||||
int Bits;
|
||||
int StopBits;
|
||||
int HandShake;
|
||||
m_pSO7_Serial->GetPortData(&Port,&Baud,&Parity,&Bits,&StopBits,&HandShake);
|
||||
Params.Format( TEXT("[COM%d]"), Port );
|
||||
Param.Format( TEXT(" Baud=%d"), Baud );
|
||||
Params += Param;
|
||||
Param.Format( TEXT(" Parity=%c"), Parity );
|
||||
Params += Param;
|
||||
Param.Format( TEXT(" Data=%d"), Bits );
|
||||
Params += Param;
|
||||
Param.Format( TEXT(" Stop=%d"), StopBits );
|
||||
Params += Param;
|
||||
CString Params;
|
||||
Params =_T("[COM1]Baud=19200,Parity=N,Data=8,Stop=0");
|
||||
m_StatusBar.SetText(Params, 0, 0);
|
||||
|
||||
if(m_pSO7_Serial->Open())
|
||||
if(m_pSO7_Serial->Open(1,19200))
|
||||
{
|
||||
m_StatusBar.SetText(_T("³É¹¦´ò¿ª´®¿Ú"), 1, 0);
|
||||
GetDlgItem(IDC_BUTTON_SO7_MANUAL_MACHINE_SEND_DATA)->EnableWindow(TRUE);
|
||||
@@ -130,6 +117,10 @@ void CSo7_Manual_Machine::OnBnClickedButtonSo7ManualMachineStartMachine()
|
||||
//===================================================
|
||||
void CSo7_Manual_Machine::OnBnClickedButtonSo7ManualMachineStopMachine()
|
||||
{
|
||||
if (m_pSO7_Serial)
|
||||
{
|
||||
m_pSO7_Serial->Close();
|
||||
}
|
||||
GetDlgItem(IDC_BUTTON_SO7_MANUAL_MACHINE_SEND_DATA)->EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
@@ -166,50 +157,64 @@ void CSo7_Manual_Machine::OnBnClickedRadioSo7ManualMachineSendDataTypeAnscii()
|
||||
//===================================================
|
||||
void CSo7_Manual_Machine::OnBnClickedButtonSo7ManualMachineSendData()
|
||||
{
|
||||
/*
|
||||
UpdateData(TRUE);
|
||||
USES_CONVERSION;
|
||||
CString csSendData(L"");
|
||||
|
||||
GetDlgItem(IDC_EDIT_SO7_MANUAL_MACHINE_DATA)->GetWindowText(csSendData);
|
||||
const char* cSendData=T2A(csSendData);
|
||||
|
||||
int iSendDataLength(0);
|
||||
int iWriteByte(0);
|
||||
int iReadByte(0);
|
||||
|
||||
if (m_SendType==HEXADECIMAL)
|
||||
{
|
||||
char* stop;
|
||||
BYTE bSendData[MAX_OUTPUT_BUFFER_SIZE]={0};
|
||||
INT iSendDataLength=(csSendData.GetLength()+1)/3;
|
||||
for(INT i=0;i<iSendDataLength;i++)
|
||||
{
|
||||
bSendData[i]=(BYTE)strtol(cSendData+i*3,&stop,16);
|
||||
}
|
||||
char* stop;
|
||||
BYTE bSendData[MAX_OUTPUT_BUFFER_SIZE]={0};
|
||||
iSendDataLength=(csSendData.GetLength()+1)/3;
|
||||
for(int i=0;i<iSendDataLength;i++)
|
||||
{
|
||||
bSendData[i]=(BYTE)strtol(cSendData+i*3,&stop,16);
|
||||
}
|
||||
iWriteByte=m_pSO7_Serial->SendData((const char*)bSendData,iSendDataLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSO7_Serial->m_csRecv=_T("");
|
||||
|
||||
//¼ÓÉϻسµ»»Ðзû
|
||||
CString csTemp;
|
||||
csTemp.Format(_T("\r\n"));
|
||||
csSendData+=csTemp;
|
||||
|
||||
|
||||
cSendData=T2A(csSendData);
|
||||
//¼ÓÉϻسµ»»Ðзû
|
||||
CString csTemp;
|
||||
csTemp.Format(_T("\r\n"));
|
||||
csSendData+=csTemp;
|
||||
cSendData=T2A(csSendData);
|
||||
iSendDataLength=csSendData.GetLength();
|
||||
iWriteByte=m_pSO7_Serial->SendData(cSendData,iSendDataLength);
|
||||
}
|
||||
DWORD iSendDataLength=csSendData.GetLength();
|
||||
DWORD iWriteByte=m_pSO7_Serial->Send(cSendData,iSendDataLength);
|
||||
|
||||
((CListBox *)GetDlgItem(IDC_LIST_SHOWMESSAGE))->InsertString(-1,CString(_T("[Send]: "))+cSendData);//
|
||||
m_OutMessage=_T("[Send] ")+csSendData;
|
||||
OutputWithScroll(m_OutMessage,m_edMSG);
|
||||
|
||||
csSendData.Format(_T("Send(%dByte)"),iWriteByte);
|
||||
m_StatusBar.SetText(csSendData, 1, 0);
|
||||
m_OutMessage.Format(_T("Send(%dByte)"),iWriteByte);
|
||||
m_StatusBar.SetText(m_OutMessage, 1, 0);
|
||||
//½ÓÊÜÊý¾Ý
|
||||
INT iRetrys(0);
|
||||
while(!m_pSO7_Serial->m_iRecvState && iRetrys<20)
|
||||
while(!m_pSO7_Serial->ReadDataWaiting() && iRetrys<20)
|
||||
{
|
||||
iRetrys++;
|
||||
Sleep(100);
|
||||
}
|
||||
*/
|
||||
if (iRetrys<20)
|
||||
{
|
||||
BYTE RecvData[MAX_OUTPUT_BUFFER_SIZE]={0};
|
||||
iReadByte=m_pSO7_Serial->ReadData(RecvData,MAX_OUTPUT_BUFFER_SIZE);
|
||||
m_OutMessage.Format(_T("[Recv]%s"),RecvData);
|
||||
OutputWithScroll(m_OutMessage,m_edMSG);
|
||||
m_OutMessage.Format(_T("Recv(%dByte)"),iReadByte);
|
||||
m_StatusBar.SetText(m_OutMessage, 2, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_StatusBar.SetText(_T("Time Out!"), 2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//===================================================
|
||||
@@ -248,3 +253,25 @@ void CSo7_Manual_Machine::OnBnClickedCancel()
|
||||
OnBnClickedButtonSo7ManualMachineStopMachine();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
//Print message on edit control
|
||||
void CSo7_Manual_Machine::OutputWithScroll(const CString &strNewText,CEdit &edtOutput)
|
||||
{
|
||||
CString strOutput;
|
||||
edtOutput.GetWindowText(strOutput);
|
||||
strOutput += strNewText;
|
||||
if ("\r\n" != strOutput.Right(2))
|
||||
{
|
||||
strOutput += "\r\n";
|
||||
}
|
||||
|
||||
int iCount = strOutput.GetLength();
|
||||
|
||||
edtOutput.SetRedraw(FALSE);
|
||||
edtOutput.SetWindowText(strOutput);
|
||||
int iLine = edtOutput.GetLineCount();
|
||||
edtOutput.LineScroll(iLine, 0);
|
||||
edtOutput.SetSel(iCount, iCount);
|
||||
edtOutput.SetRedraw(TRUE);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ protected:
|
||||
DECLARE_MESSAGE_MAP()
|
||||
protected:
|
||||
CStatusBarCtrl m_StatusBar;
|
||||
CEdit m_edit_Log;
|
||||
char m_SendType;
|
||||
CString m_OutMessage;
|
||||
CEdit m_edMSG;
|
||||
char m_SendType;
|
||||
void OutputWithScroll(const CString &strNewText,CEdit &edtOutput);
|
||||
public:
|
||||
afx_msg void OnBnClickedButtonSo7ManualMachineStartMachine();
|
||||
afx_msg void OnBnClickedButtonSo7ManualMachineStopMachine();
|
||||
|
||||
@@ -32,12 +32,15 @@
|
||||
|
||||
#include "SO7_Verfication_Algorithm.h"
|
||||
|
||||
#include "..\..\..\SevenOcean\Serial.h"
|
||||
#include "So7_Manual_Machine.h"
|
||||
|
||||
#include "So7_Option.h"
|
||||
#include "afxdialogex.h"
|
||||
//#define _RELEASE_ONLY_ONE_FUNCTION
|
||||
|
||||
|
||||
CSerial* m_pSO7_Serial=NULL;
|
||||
CPSerial* m_pSO7_PCDSerial=NULL;
|
||||
CSO7_Proto* m_pSO7_Proto=NULL;
|
||||
CKeyence_Laser* m_pKeyence_Laser=NULL;
|
||||
CKeyence_Laser_LK_H* m_pKeyence_Laser_LK_H=NULL;
|
||||
@@ -101,9 +104,9 @@ BOOL CSo7_Option::OnInitDialog()
|
||||
((CButton *)GetDlgItem(IDC_RADIO_VIDEOCARD_SDK3000))->SetCheck(FALSE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO_VIDEOCARD_SV2000E))->SetCheck(FALSE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO_VIDEOCARD_TC4000))->SetCheck(FALSE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO_KEYENCE_LASER))->SetCheck(TRUE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO_KEYENCE_LASER))->SetCheck(FALSE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO_SO7_IP_CAMERA))->SetCheck(FALSE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO__SO7_RS232))->SetCheck(FALSE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO__SO7_RS232))->SetCheck(TRUE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO_SO7_VERIFICATION_ALGORITHM))->SetCheck(FALSE);
|
||||
|
||||
#ifdef _RELEASE_ONLY_ONE_FUNCTION
|
||||
@@ -157,7 +160,7 @@ void CSo7_Option::OnBnClickedOk()
|
||||
m_pKeyence_Proto=NULL;
|
||||
delete m_pSO7_Proto;
|
||||
m_pSO7_Proto=NULL;
|
||||
}
|
||||
}
|
||||
else if (((CButton *)GetDlgItem(IDC_RADIO_VIDEOCARD_SDK3000))->GetCheck())
|
||||
{
|
||||
CVideocard_SDK3000* pVideocard_SDK3000=new CVideocard_SDK3000();
|
||||
@@ -196,6 +199,20 @@ void CSo7_Option::OnBnClickedOk()
|
||||
CSO7_Verfication_Algorithm* pSO7_Verfication_Algorithm=new CSO7_Verfication_Algorithm();
|
||||
pSO7_Verfication_Algorithm->DoModal();
|
||||
}
|
||||
else if (((CButton *)GetDlgItem(IDC_RADIO__SO7_RS232))->GetCheck())
|
||||
{
|
||||
if (!m_pSO7_Serial)
|
||||
m_pSO7_Serial = new CSerial();
|
||||
|
||||
CSo7_Manual_Machine* pSo7_Manual_Machine=new CSo7_Manual_Machine();
|
||||
pSo7_Manual_Machine->DoModal();
|
||||
|
||||
if (m_pSO7_Serial)
|
||||
{
|
||||
delete m_pSO7_Serial;
|
||||
m_pSO7_Serial=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef _RELEASE_ONLY_ONE_FUNCTION
|
||||
|
||||
@@ -213,6 +213,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\SevenOcean\CMMIO_BASE.CPP" />
|
||||
<ClCompile Include="..\..\..\SevenOcean\CMMIO_SERIAL.CPP" />
|
||||
<ClCompile Include="..\..\..\SevenOcean\Serial.cpp" />
|
||||
<ClCompile Include="..\..\..\SevenOcean\So7_Interface.cpp" />
|
||||
<ClCompile Include="..\..\..\SevenOcean\SO7_Proto.cpp" />
|
||||
<ClCompile Include="..\LOGGER.CPP" />
|
||||
@@ -267,6 +268,7 @@
|
||||
<ClInclude Include="..\..\..\SevenOcean\CMMIO_SERIAL.H" />
|
||||
<ClInclude Include="..\..\..\SevenOcean\DLL.h" />
|
||||
<ClInclude Include="..\..\..\SevenOcean\NewDataStruct.h" />
|
||||
<ClInclude Include="..\..\..\SevenOcean\Serial.h" />
|
||||
<ClInclude Include="..\..\..\SevenOcean\So7_Interface.h" />
|
||||
<ClInclude Include="..\..\..\SevenOcean\SO7_Proto.h" />
|
||||
<ClInclude Include="..\..\..\Videocard\SDK3000\sdk3000_7130.h" />
|
||||
|
||||
@@ -121,7 +121,12 @@
|
||||
<ClCompile Include="So7_Manual_Machine.cpp">
|
||||
<Filter>Sources Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SO7_Verfication_Algorithm.cpp" />
|
||||
<ClCompile Include="SO7_Verfication_Algorithm.cpp">
|
||||
<Filter>Sources Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\SevenOcean\Serial.cpp">
|
||||
<Filter>Sources Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CaptureDataDlg.h">
|
||||
@@ -274,7 +279,12 @@
|
||||
<ClInclude Include="So7_Manual_Machine.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SO7_Verfication_Algorithm.h" />
|
||||
<ClInclude Include="SO7_Verfication_Algorithm.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\SevenOcean\Serial.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
|
||||
@@ -345,6 +345,8 @@
|
||||
#define IDC_EDIT_IMAGEDLL_2LASER_TOPZ1 1274
|
||||
#define IDC_EDIT_FRESHSPEED_X2 1275
|
||||
#define IDC_EDIT_IMAGEDLL_2LASER_TOPZ2 1275
|
||||
#define IDC_EDIT_REPRETEST2 1275
|
||||
#define IDC_EDIT_MANUAL_MACHINE_MSG 1275
|
||||
#define IDC_EDIT_FRESHSPEED_X3 1276
|
||||
#define IDC_EDIT_IMAGEDLL_2LASER_TOPZ3 1276
|
||||
#define IDC_BUTTON_ZERO_SET 1277
|
||||
@@ -356,7 +358,6 @@
|
||||
#define IDC_EDIT_FRESHSPEED_Y1 1279
|
||||
#define IDC_EDIT_IMAGEDLL_2LASER_TOPZ6 1279
|
||||
#define IDC_BUTTON_SAVE 1280
|
||||
#define IDC_EDIT_IMAGEDLL_2LASER_TOPZ7 1280
|
||||
#define IDC_EDIT_IMAGEDLL_2LASER_BOTTOMZ__CALIBRATE 1280
|
||||
#define IDC_BUTTON_SAVE_PARAMETER 1281
|
||||
#define IDC_EDIT_IMAGEDLL_2LASER_TOPZ_CALIBRATE 1281
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user