REMOVE DLLCHR.Add TCP/IP COMM.

This commit is contained in:
TAO Cheng
2014-10-29 16:55:31 +08:00
parent d9932e709c
commit 02f1c7e503
12 changed files with 524 additions and 47 deletions
@@ -6,7 +6,7 @@
//--------------------------------------------------------------------
cAcqEasy::cAcqEasy(MCHR_ID SensorID)
{
#ifdef _DEBUG
#ifndef _REMOVE_DLLCHR
DWORD dwThreadId = 0;
int nIndex = 0, idx = 0, jdx = 0;
@@ -62,7 +62,7 @@ cAcqEasy::cAcqEasy(MCHR_ID SensorID)
//--------------------------------------------------------------------
cAcqEasy::~cAcqEasy()
{
#ifdef _DEBUG
#ifndef _REMOVE_DLLCHR
int nIndex = 0;
@@ -99,7 +99,7 @@ cAcqEasy::~cAcqEasy()
#endif //_DEBUG
}
#ifdef _DEBUG
#ifndef _REMOVE_DLLCHR
//-------------------------------------------------------------------------------------------------
void cAcqEasy::_ReleaseAcqBuffer(int NumberOfBuffers)
{
@@ -134,6 +134,7 @@ void CSTIL_CCS_PRIMA_Laser::ResetParam()
}
BOOL CSTIL_CCS_PRIMA_Laser::InitChrLib()
{
#ifndef _REMOVE_DLLCHR
char szVersion[MAX_CHAR];
//DLL initialization
@@ -151,10 +152,14 @@ BOOL CSTIL_CCS_PRIMA_Laser::InitChrLib()
}
TRACE1("DLL CHR V%s\n", szVersion);
return(TRUE);
#else
return FALSE;
#endif
}
BOOL CSTIL_CCS_PRIMA_Laser::OpenCom (enChrConnection connectionType, int comPort, int baudrate)
{
#ifndef _REMOVE_DLLCHR
TRACE ("Init Chr Lib\n");
m_ErrorCode = SPARKSHI_ERROR_NONE;
m_nBaudrate = static_cast<WORD>(baudrate);
@@ -208,11 +213,18 @@ BOOL CSTIL_CCS_PRIMA_Laser::OpenCom (enChrConnection connectionType, int comPort
{
return(FALSE);
}
#else
UNREFERENCED_PARAMETER(connectionType);
UNREFERENCED_PARAMETER(comPort);
UNREFERENCED_PARAMETER(baudrate);
return FALSE;
#endif
}
//-----------------------------------------------------------------------------------------
BOOL CSTIL_CCS_PRIMA_Laser::CreateEvents(cAcqEasy *pAcquisitionEasy, HANDLE *pAcquisitionEvent)
{
#ifndef _REMOVE_DLLCHR
m_ErrorCode = SPARKSHI_ERROR_NONE;
if (pAcquisitionEasy == NULL)
{
@@ -231,6 +243,11 @@ BOOL CSTIL_CCS_PRIMA_Laser::CreateEvents(cAcqEasy *pAcquisitionEasy, HANDLE *pAc
}
m_ErrorCode = SPARKSHI_ERROR_CREATE_EVENT;
return (FALSE);
#else
UNREFERENCED_PARAMETER(pAcquisitionEasy);
UNREFERENCED_PARAMETER(pAcquisitionEvent);
return FALSE;
#endif
}
//-----------------------------------------------------------------------------------------
BOOL CSTIL_CCS_PRIMA_Laser::ReleaseEvents(HANDLE *pAcquisitionEvent)
@@ -246,6 +263,7 @@ BOOL CSTIL_CCS_PRIMA_Laser::ReleaseEvents(HANDLE *pAcquisitionEvent)
BOOL CSTIL_CCS_PRIMA_Laser::InitAcquisition (eAcqEasyFunc selectedFunction, enTriggerType selectedTrigger, int numberOfPointTRE)
{
#ifndef _REMOVE_DLLCHR
DWORD readLong;
m_ErrorCode = SPARKSHI_ERROR_NONE;
@@ -336,11 +354,18 @@ BOOL CSTIL_CCS_PRIMA_Laser::InitAcquisition (eAcqEasyFunc selectedFunction, enTr
else
return (FALSE);
return (TRUE);
#else
UNREFERENCED_PARAMETER(selectedFunction);
UNREFERENCED_PARAMETER(selectedTrigger);
UNREFERENCED_PARAMETER(numberOfPointTRE);
return FALSE;
#endif
}
BOOL CSTIL_CCS_PRIMA_Laser::ReleaseAcquisition ()
{
#ifndef _REMOVE_DLLCHR
if (m_pAcqEasy)
{
m_pAcqEasy->StopAcquisition();
@@ -378,6 +403,9 @@ BOOL CSTIL_CCS_PRIMA_Laser::ReleaseAcquisition ()
m_pAcqEasy = NULL;
}
return (TRUE);
#else
return FALSE;
#endif
}
WORD CSTIL_CCS_PRIMA_Laser::GetLastError ()
@@ -387,6 +415,7 @@ WORD CSTIL_CCS_PRIMA_Laser::GetLastError ()
BOOL CSTIL_CCS_PRIMA_Laser::CloseCom ()
{
#ifndef _REMOVE_DLLCHR
BOOL bStatus(FALSE);
m_ErrorCode = SPARKSHI_ERROR_NONE;
if (m_SensorId != 0)
@@ -409,11 +438,15 @@ BOOL CSTIL_CCS_PRIMA_Laser::CloseCom ()
bStatus=(FALSE);
}
return bStatus;
#else
return FALSE;
#endif
}
BOOL CSTIL_CCS_PRIMA_Laser::GetDistanceValue(double &dblDistance, double &dblIntensity, bool bSoftTrigger)
{
#ifndef _REMOVE_DLLCHR
int DataCount = 0;
m_ErrorCode = SPARKSHI_ERROR_NONE;
if (m_pAcqEasy == NULL)
@@ -479,11 +512,18 @@ BOOL CSTIL_CCS_PRIMA_Laser::GetDistanceValue(double &dblDistance, double &dblInt
return(SPARKSHI_ERROR);
else
return (SPARKSHI_ERROR_NONE);
#else
UNREFERENCED_PARAMETER(dblDistance);
UNREFERENCED_PARAMETER(dblIntensity);
UNREFERENCED_PARAMETER(bSoftTrigger);
return FALSE;
#endif
}
BOOL CSTIL_CCS_PRIMA_Laser::GetThicknessValue(double &dblThickness, double &dblDistance1, double &dblDistance2, double &dblIntensity1, double &dblIntensity2, bool bSoftTrigger)
{
{
#ifndef _REMOVE_DLLCHR
int DataCount = 0;
m_ErrorCode = SPARKSHI_ERROR_NONE;
if (m_pAcqEasy == NULL)
@@ -586,12 +626,21 @@ BOOL CSTIL_CCS_PRIMA_Laser::GetThicknessValue(double &dblThickness, double &dblD
return(SPARKSHI_ERROR);
else
return (SPARKSHI_ERROR_NONE);
#else
UNREFERENCED_PARAMETER(dblThickness);
UNREFERENCED_PARAMETER(dblDistance1);
UNREFERENCED_PARAMETER(dblDistance2);
UNREFERENCED_PARAMETER(dblIntensity1);
UNREFERENCED_PARAMETER(dblIntensity2);
UNREFERENCED_PARAMETER(bSoftTrigger);
return FALSE;
#endif
}
BOOL CSTIL_CCS_PRIMA_Laser::SetRefractiveIndex (double indice)
{
#ifndef _REMOVE_DLLCHR
if (MCHR_SetRefractiveIndex (m_SensorId, (float) indice) == MCHR_ERROR)
{
m_ErrorCode = MCHR_GetLastError (m_SensorId);
@@ -602,12 +651,17 @@ BOOL CSTIL_CCS_PRIMA_Laser::SetRefractiveIndex (double indice)
m_RefractiveIndex = (float) indice;
return (SPARKSHI_ERROR_NONE);
}
#else
UNREFERENCED_PARAMETER(indice);
return FALSE;
#endif
}
BOOL CSTIL_CCS_PRIMA_Laser::GetRefractiveIndex (double &indice)
{
#ifndef _REMOVE_DLLCHR
float convParam = (float) indice;
if (MCHR_GetRefractiveIndex (m_SensorId, &convParam) == MCHR_ERROR)
{
@@ -620,6 +674,9 @@ BOOL CSTIL_CCS_PRIMA_Laser::GetRefractiveIndex (double &indice)
indice = convParam;
return (SPARKSHI_ERROR_NONE);
}
#else
UNREFERENCED_PARAMETER(indice);
return FALSE;
#endif
}
#endif //_DEBUG
@@ -0,0 +1,169 @@
#include "StdAfx.h"
#include <WinDef.h>
#include <WinBase.h>
#include "So7_TCPIP.h"
const int WSA_MAJOR_VERSION = 1;
const int WSA_MINOR_VERSION = 1;
#define WSA_VERSION MAKEWORD(WSA_MAJOR_VERSION, WSA_MINOR_VERSION)
#define SOCKADDR_LEN sizeof(SOCKADDR_IN)
//================================================================
CSo7_TCPIP::CSo7_TCPIP()
{
m_socket=INVALID_SOCKET;
m_pszNetworkAddr="127.0.0.1";
m_nPortNumber=8000;
m_bDisableTimeout=false;
}
//================================================================
CSo7_TCPIP::~CSo7_TCPIP()
{
//DisConnect();
}
//================================================================
int CSo7_TCPIP::Init_Winsock()
{
int nRet;
static int first = TRUE;
if (first)
{
WSADATA stWSAData; /* WinSock DLL Info */
nRet = WSAStartup(WSA_VERSION, &stWSAData);
if (nRet)
{
return FALSE;
}
first = FALSE;
}
return TRUE;
}
//================================================================
TCPIP_RETURN_CODE CSo7_TCPIP::Connect()
{
TCPIP_RETURN_CODE rCode=TCPIP_CONNECT_OK;
//DisConnect();
int retVal(0), errorCode(0);
retVal=Init_Winsock();
if(!retVal)
{
return TCPIP_INIT_WINSOCK_ERROR;
}
// 创建套节字
m_socket = socket(AF_INET, SOCK_STREAM, 0);
if(m_socket == INVALID_SOCKET)
{
rCode=TCPIP_INVAILD_SOCKET;
}
else
{
// 设置socket为窗口通知消息类型
::WSAAsyncSelect(m_socket, m_hMsgWnd,
WM_SOCKET, FD_CONNECT | FD_CLOSE | FD_WRITE | FD_READ);
// 假定szAddr是IP地址
ULONG uAddr = inet_addr(m_pszNetworkAddr);
if(uAddr == INADDR_NONE)
{
// 不是IP地址,就认为这是主机名称
// 从主机名取得IP地址
hostent* pHost = ::gethostbyname(m_pszNetworkAddr);
if(pHost == NULL)
{
closesocket(m_socket);
m_socket = INVALID_SOCKET;
return TCPIP_INVAILD_SOCKET;
}
// 得到以网络字节顺序排列的IP地址
uAddr = ((struct in_addr*)*(pHost->h_addr_list))->s_addr;
}
// 填写服务器地址信息
sockaddr_in remote;
remote.sin_addr.S_un.S_addr = uAddr;
remote.sin_family = AF_INET;
remote.sin_port = htons(m_nPortNumber);
// 连接到远程机
retVal=connect(m_socket, (sockaddr*)&remote, sizeof(sockaddr));
if(retVal)
{
errorCode = WSAGetLastError();
rCode=(TCPIP_RETURN_CODE)errorCode;
}
}
return rCode;
}
//================================================================
TCPIP_RETURN_CODE CSo7_TCPIP::DisConnect()
{
if(m_socket == INVALID_SOCKET)
{
return TCPIP_INVAILD_SOCKET;
}
::closesocket(m_socket);
m_socket = INVALID_SOCKET;
return TCPIP_CONNECT_OK;
}
//================================================================
TCPIP_RETURN_CODE CSo7_TCPIP::Send()
{
if(m_socket == INVALID_SOCKET)
{
return TCPIP_INVAILD_SOCKET;
}
BYTE bSendData[20]={1,2,3,4,5};
int iSendDataLength=20;
if(::send(m_socket,(const char*)(bSendData),iSendDataLength,0) != -1)
{
return TCPIP_CONNECT_OK;
}
return TCPIP_CONNECT_OK;
}
//================================================================
TCPIP_RETURN_CODE CSo7_TCPIP::Recv()
{
if(m_socket == INVALID_SOCKET)
{
return TCPIP_INVAILD_SOCKET;
}
return TCPIP_CONNECT_OK;
}
//================================================================
LRESULT CSo7_TCPIP::OnSocket(WPARAM wParam, LPARAM lParam)
{
// 取得有事件发生的套节字句柄
SOCKET s = wParam;
// 查看是否出错
int errorCode = WSAGETSELECTERROR(lParam);
if(errorCode)
return errorCode; //should put a message up here
int event = WSAGETSELECTEVENT(lParam);
switch(event)
{
case FD_CONNECT:
{
}
break;
case FD_READ:
{
char szText[1024] = { 0 };
::recv(s, szText, 1024, 0);
Recv();
}
break;
case FD_WRITE:
//This event happens when the tcp buffers are ready for another send.
//So if there is not enough room for the first write the event will happen
//and then the buffers are ready for more.
break;
case FD_CLOSE:
break;
}
return 0;
}
@@ -0,0 +1,48 @@
// protocol for control SevenOcean's Machine
//
//////////////////////////////////////////////////////////////////////
#ifndef SO7_TCPIP_H_INCLUDED_
#define SO7_TCPIP_H_INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxwin.h>
#include <afxcmn.h>
#include <Winsock2.h>
#define WM_SOCKET WM_USER + 0x1
typedef enum {
TCPIP_CONNECT_OK=0,
TCPIP_INIT_WINSOCK_ERROR,
TCPIP_INVAILD_SOCKET,
TCPIP_INVAILD_IP_ADDRESS,
TCPIP_INVAILD_PORT_NUMBER,
TCPIP_CONNECT_SERVER_FAILED,
} TCPIP_RETURN_CODE;
//======================================================================================
class CSo7_TCPIP
{
public:
CSo7_TCPIP();
virtual ~CSo7_TCPIP();
TCPIP_RETURN_CODE Connect();
TCPIP_RETURN_CODE Send();
TCPIP_RETURN_CODE Recv();
TCPIP_RETURN_CODE DisConnect();
HWND m_hMsgWnd;
LRESULT OnSocket(WPARAM wParam, LPARAM lParam);
private:
SOCKET m_socket;
LPCSTR m_pszNetworkAddr;
u_short m_nPortNumber;
bool m_bDisableTimeout;
int Init_Winsock();
};
#endif
@@ -16,7 +16,7 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Chinese (Simplified, PRC) resources
// 中文(简体,中国) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
@@ -396,7 +396,7 @@ BEGIN
EDITTEXT IDC_EDIT_ZOOM_TIME,14,159,112,112,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
END
IDD_SO7_OPTION_DIALOG DIALOGEX 0, 0, 290, 163
IDD_SO7_OPTION_DIALOG DIALOGEX 0, 0, 290, 185
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Utility for SO7"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
@@ -405,8 +405,8 @@ BEGIN
CONTROL "SV2000E视频卡",IDC_RADIO_VIDEOCARD_SV2000E,"Button",BS_AUTORADIOBUTTON,24,48,69,10
CONTROL "SV4000E视频卡",IDC_RADIO_VIDEOCARD_SV4000E,"Button",BS_AUTORADIOBUTTON,24,64,68,10
CONTROL "TC4000视频卡",IDC_RADIO_VIDEOCARD_TC4000,"Button",BS_AUTORADIOBUTTON,24,80,69,10
CONTROL "IP Camera",IDC_RADIO_SO7_IP_CAMERA,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,195,96,62,10
CONTROL "USB Camera",IDC_RADIO_SO7_USB_CAMERA,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,195,112,62,10
CONTROL "IP Camera",IDC_RADIO_SO7_IP_CAMERA,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,24,115,62,10
CONTROL "USB Camera",IDC_RADIO_SO7_USB_CAMERA,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,21,130,62,10
CONTROL "LK_G激光",IDC_RADIO_KEYENCE_LASER,"Button",BS_AUTORADIOBUTTON,100,32,76,10
CONTROL "LK_H激光(USB)",IDC_RADIO_KEYENCE_LASER_LK_H,"Button",BS_AUTORADIOBUTTON,100,48,76,10
CONTROL "LK_H激光(ETHERNET)",IDC_RADIO_KEYENCE_LASER_LKH_ETHERNET,
@@ -418,12 +418,13 @@ BEGIN
CONTROL "控制器(USB R",IDC_RADIO_CONTROLLER2,"Button",BS_AUTORADIOBUTTON,195,47,75,10
CONTROL "控制器(RS232",IDC_RADIO__SO7_RS232,"Button",BS_AUTORADIOBUTTON,195,63,77,10
CONTROL "Verifcation algorithm",IDC_RADIO_SO7_VERIFICATION_ALGORITHM,
"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,8,140,81,10
"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,7,168,81,10
CONTROL "Image.dll",IDC_RADIO_TEST_IMAGE_DLL,"Button",BS_AUTORADIOBUTTON,195,80,45,10
DEFPUSHBUTTON "OK",IDOK,145,142,50,14
PUSHBUTTON "Cancel",IDCANCEL,225,142,50,14
GROUPBOX "²âÊÔÑ¡Ïî",IDC_STATIC,10,8,265,123
DEFPUSHBUTTON "OK",IDOK,145,164,50,14
PUSHBUTTON "Cancel",IDCANCEL,225,164,50,14
GROUPBOX "测试选项",IDC_STATIC,10,8,265,153
CONTROL "MV900视频卡",IDC_RADIO_VIDEOCARD_MV900,"Button",BS_AUTORADIOBUTTON,24,96,69,10
CONTROL "CJ2M PLC",IDC_RADIO_SO7_OMRON_PLC,"Button",BS_AUTORADIOBUTTON,101,129,62,10
END
IDD_SO7_VIDEOCARD_SDK3000 DIALOGEX 0, 0, 488, 316
@@ -1035,6 +1036,24 @@ BEGIN
PUSHBUTTON "默认参数",IDC_BUTTON_MV900_DEFAULT_PARA,520,130,53,14
END
IDD_SO7_UTIL_PLC_TCPIP DIALOGEX 0, 0, 338, 251
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "PLC TCP/IP "
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Exit",IDCANCEL,292,230,39,14
GROUPBOX "TCP/IP Control",IDC_STATIC,17,12,87,81
PUSHBUTTON "Connect",IDC_BUTTON_PLC_TCPIP_CONNECT,29,29,63,18
PUSHBUTTON "Disconnect",IDC_BUTTON_PLC_TCPIP_DISCONNECT,29,64,63,18
EDITTEXT IDC_EDIT_MSG,19,97,265,130,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
PUSHBUTTON "Clear",IDC_BUTTON_PLC_TCPIP_CLEAR_MSG,289,156,39,14
PUSHBUTTON "Read Data",IDC_BUTTON_PLC_TCPIP_READ,203,30,63,18
PUSHBUTTON "Write Data",IDC_BUTTON_PLC_TCPIP_WRITE,203,62,63,18
GROUPBOX "TCP/IP Control",IDC_STATIC,110,12,174,81
EDITTEXT IDC_EDIT_PLC_TCPIP_ADDR,139,47,40,14,ES_AUTOHSCROLL
LTEXT "Addr",IDC_STATIC,116,50,16,8
END
/////////////////////////////////////////////////////////////////////////////
//
@@ -1072,7 +1091,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 275
TOPMARGIN, 6
BOTTOMMARGIN, 156
BOTTOMMARGIN, 178
END
IDD_SO7_VIDEOCARD_SDK3000, DIALOG
@@ -1215,6 +1234,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 352
END
IDD_SO7_UTIL_PLC_TCPIP, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 331
TOPMARGIN, 7
BOTTOMMARGIN, 244
END
END
#endif // APSTUDIO_INVOKED
@@ -1644,16 +1671,22 @@ IDB_BITMAP_X_RIGHT BITMAP "res\\bmp\\X_RIGHT.bmp"
STRINGTABLE
BEGIN
IDS_ABOUTBOX "&About Mv_Util..."
IDS_STRING_GERERAL_IO "通用IO"
IDS_STRING_TRIG_IO "触发IO"
END
#endif // Chinese (Simplified, PRC) resources
STRINGTABLE
BEGIN
IDS_SO7_ABOUTBOX "&About Utility for SO7..."
END
#endif // 中文(简体,中国) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
// 英语(美国) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
@@ -2612,33 +2645,7 @@ BEGIN
END
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United Kingdom) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_ABOUTBOX "&About Mv_Util..."
END
STRINGTABLE
BEGIN
IDS_SO7_ABOUTBOX "&About Utility for SO7..."
END
#endif // English (United Kingdom) resources
#endif // 英语(美国) resources
/////////////////////////////////////////////////////////////////////////////
@@ -55,6 +55,9 @@
#include "So7_Manual_Machine.h"
#include "So7_XBoxController.h"
#include "..\..\..\SevenOcean\So7_TCPIP.h"
#include "So7_Util_PLC_TCPIP.h"
#include "So7_Option.h"
#include "afxdialogex.h"
@@ -74,6 +77,8 @@ CXBOXController* XBoxPlayer =NULL;
CART_PCI8622* m_pART_PCI8622=NULL;
CSTIL_CCS_PRIMA_Laser* g_pSTIL_CCS_PRIMA=NULL;
CSo7_TCPIP* g_pSo7_TCPIP=NULL;
// CSo7_Option dialog
IMPLEMENT_DYNAMIC(CSo7_Option, CDialog)
@@ -141,6 +146,7 @@ BOOL CSo7_Option::OnInitDialog()
((CButton *)GetDlgItem(IDC_RADIO_SO7_VERIFICATION_ALGORITHM))->SetCheck(FALSE);
((CButton *)GetDlgItem(IDC_RADIO_TEST_IMAGE_DLL))->SetCheck(FALSE);
((CButton *)GetDlgItem(IDC_RADIO_ART_PCI8622))->SetCheck(FALSE);
((CButton *)GetDlgItem(IDC_RADIO_SO7_OMRON_PLC))->SetCheck(FALSE);
#ifdef _RELEASE_SO7_CONTROLER_ONLY
((CButton *)GetDlgItem(IDC_RADIO_VIDEOCARD_SDK3000))->EnableWindow(FALSE);
@@ -428,6 +434,21 @@ void CSo7_Option::OnBnClickedOk()
m_pSo7_Interface=NULL;
}
}
else if(((CButton *)GetDlgItem(IDC_RADIO_SO7_OMRON_PLC))->GetCheck())
{
if (!g_pSo7_TCPIP)
{
g_pSo7_TCPIP=new CSo7_TCPIP();
}
CSo7_Util_PLC_TCPIP* pSo7_Util_PLC_TCPIP=new CSo7_Util_PLC_TCPIP();
pSo7_Util_PLC_TCPIP->DoModal();
delete pSo7_Util_PLC_TCPIP;
if (g_pSo7_TCPIP)
{
delete g_pSo7_TCPIP;
g_pSo7_TCPIP=NULL;
}
}
else if(((CButton *)GetDlgItem(IDC_RADIO_SO7_VERIFICATION_ALGORITHM))->GetCheck())
{
CSO7_Verfication_Algorithm* pSO7_Verfication_Algorithm=new CSO7_Verfication_Algorithm();
@@ -0,0 +1,119 @@
// So7_Util_PLC_TCPIP.cpp : 实现文件
//
#include "stdafx.h"
#include "resource.h"
#include "..\..\..\SevenOcean\So7_TCPIP.h"
#include "So7_Util_PLC_TCPIP.h"
#include "afxdialogex.h"
extern CSo7_TCPIP* g_pSo7_TCPIP;
// CSo7_Util_PLC_TCPIP 对话框
IMPLEMENT_DYNAMIC(CSo7_Util_PLC_TCPIP, CDialog)
CSo7_Util_PLC_TCPIP::CSo7_Util_PLC_TCPIP(CWnd* pParent /*=NULL*/)
: CDialog(CSo7_Util_PLC_TCPIP::IDD, pParent)
{
}
CSo7_Util_PLC_TCPIP::~CSo7_Util_PLC_TCPIP()
{
}
void CSo7_Util_PLC_TCPIP::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_MSG, m_edMSG);
}
BEGIN_MESSAGE_MAP(CSo7_Util_PLC_TCPIP, CDialog)
ON_BN_CLICKED(IDC_BUTTON_PLC_TCPIP_CONNECT, &CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipConnect)
ON_BN_CLICKED(IDC_BUTTON_PLC_TCPIP_DISCONNECT, &CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipDisconnect)
ON_BN_CLICKED(IDC_BUTTON_PLC_TCPIP_READ, &CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipRead)
ON_BN_CLICKED(IDC_BUTTON_PLC_TCPIP_WRITE, &CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipWrite)
ON_BN_CLICKED(IDC_BUTTON_PLC_TCPIP_CLEAR_MSG, &CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipClearMsg)
ON_BN_CLICKED(IDCANCEL, &CSo7_Util_PLC_TCPIP::OnBnClickedCancel)
ON_MESSAGE(WM_SOCKET,&CSo7_Util_PLC_TCPIP::OnSocket)
ON_BN_CLICKED(IDCANCEL, &CSo7_Util_PLC_TCPIP::OnBnClickedCancel)
END_MESSAGE_MAP()
// CSo7_Util_PLC_TCPIP 消息处理程序
void CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipConnect()
{
g_pSo7_TCPIP->m_hMsgWnd=m_hWnd;
TCPIP_RETURN_CODE rCode=g_pSo7_TCPIP->Connect();
m_csMSG.Format(_T("Connect return code:%d."),rCode);
OutputWithScroll(m_csMSG,m_edMSG);
}
void CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipDisconnect()
{
TCPIP_RETURN_CODE rCode=g_pSo7_TCPIP->DisConnect();
m_csMSG.Format(_T("Connect return code:%d."),rCode);
OutputWithScroll(m_csMSG,m_edMSG);
}
void CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipRead()
{
;
}
void CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipWrite()
{
TCPIP_RETURN_CODE rCode=g_pSo7_TCPIP->Send();
m_csMSG.Format(_T("Connect return code:%d."),rCode);
OutputWithScroll(m_csMSG,m_edMSG);
}
void CSo7_Util_PLC_TCPIP::OnBnClickedButtonPlcTcpipClearMsg()
{
((CEdit *)GetDlgItem(IDC_EDIT_MSG))->SetWindowTextW(_T(""));
}
void CSo7_Util_PLC_TCPIP::OnBnClickedCancel()
{
// TODO: 在此添加控件通知处理程序代码
CDialog::OnCancel();
}
//=====================================================================================
//Print message on edit control
void CSo7_Util_PLC_TCPIP::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);
}
LRESULT CSo7_Util_PLC_TCPIP::OnSocket(WPARAM w, LPARAM p)
{
LRESULT lResult=0;
if( g_pSo7_TCPIP )
lResult = g_pSo7_TCPIP->OnSocket(w,p);
return( lResult );
}
@@ -0,0 +1,31 @@
#pragma once
// CSo7_Util_PLC_TCPIP 对话框
class CSo7_Util_PLC_TCPIP : public CDialog
{
DECLARE_DYNAMIC(CSo7_Util_PLC_TCPIP)
public:
CSo7_Util_PLC_TCPIP(CWnd* pParent = NULL); // 标准构造函数
virtual ~CSo7_Util_PLC_TCPIP();
// 对话框数据
enum { IDD = IDD_SO7_UTIL_PLC_TCPIP };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
void OutputWithScroll(const CString &strNewText,CEdit &edtOutput);
DECLARE_MESSAGE_MAP()
public:
CString m_csMSG;
CEdit m_edMSG;
afx_msg void OnBnClickedButtonPlcTcpipConnect();
afx_msg void OnBnClickedButtonPlcTcpipDisconnect();
afx_msg void OnBnClickedButtonPlcTcpipRead();
afx_msg void OnBnClickedButtonPlcTcpipWrite();
afx_msg void OnBnClickedButtonPlcTcpipClearMsg();
afx_msg void OnBnClickedCancel();
afx_msg LRESULT OnSocket(WPARAM w, LPARAM p);
};
@@ -129,7 +129,7 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_WARNINGS;_RELEASE_FULL_VERSION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_WARNINGS;_RELEASE_FULL_VERSION;_REMOVE_DLLCHR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -145,7 +145,7 @@
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<AdditionalDependencies>..\..\..\..\..\..\..\ThirdParty\UsbSupport\LibUsb_Win\Lib\Msvc\libusb.lib;..\..\..\Videocard\SDK3000\sdk3000_7130.lib;..\..\..\Videocard\TC4000\Sa7134Capture.lib;..\..\..\Videocard\SV4000E\dataAcq.lib;..\..\..\Videocard\SV4000E\DXMediaCap.lib;..\..\..\ART\PCI8622_32.lib;..\..\..\STIL\Dll_chr.lib;..\..\..\Videocard\MV900\Convert.lib;..\..\..\Videocard\MV900\MVSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>..\..\..\..\..\..\..\ThirdParty\UsbSupport\LibUsb_Win\Lib\Msvc\libusb.lib;..\..\..\Videocard\SDK3000\sdk3000_7130.lib;..\..\..\Videocard\TC4000\Sa7134Capture.lib;..\..\..\Videocard\SV4000E\dataAcq.lib;..\..\..\Videocard\SV4000E\DXMediaCap.lib;..\..\..\ART\PCI8622_32.lib;..\..\..\Videocard\MV900\Convert.lib;..\..\..\Videocard\MV900\MVSDK.lib;wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
@@ -323,6 +323,7 @@
<ClCompile Include="..\..\..\SevenOcean\So7_Interface.cpp" />
<ClCompile Include="..\..\..\SevenOcean\SO7_Proto.cpp" />
<ClCompile Include="..\..\..\SevenOcean\SO7_Proto_Aux.cpp" />
<ClCompile Include="..\..\..\SevenOcean\So7_TCPIP.cpp" />
<ClCompile Include="..\..\..\STIL\Common\src\cAcqEasy.cpp" />
<ClCompile Include="..\..\..\STIL\STIL_CCS_PRIMA_Laser.cpp" />
<ClCompile Include="..\..\..\Tesa\TesaStarE.cpp" />
@@ -366,6 +367,7 @@
<ClCompile Include="So7_UtilUsbCtlR.cpp" />
<ClCompile Include="So7_Util_External_Trig.cpp" />
<ClCompile Include="So7_Util_ImageDll.cpp" />
<ClCompile Include="So7_Util_PLC_TCPIP.cpp" />
<ClCompile Include="So7_Util_Program.cpp" />
<ClCompile Include="SO7_Verfication_Algorithm.cpp" />
<ClCompile Include="SO7_VolComp.cpp" />
@@ -414,6 +416,7 @@
<ClInclude Include="..\..\..\SevenOcean\So7_Interface.h" />
<ClInclude Include="..\..\..\SevenOcean\SO7_Proto.h" />
<ClInclude Include="..\..\..\SevenOcean\SO7_Proto_Aux.h" />
<ClInclude Include="..\..\..\SevenOcean\So7_TCPIP.h" />
<ClInclude Include="..\..\..\STIL\STIL_CCS_PRIMA_Laser.h" />
<ClInclude Include="..\..\..\Tesa\TesaStarE.h" />
<ClInclude Include="..\..\..\Videocard\SDK3000\sdk3000_7130.h" />
@@ -457,6 +460,7 @@
<ClInclude Include="So7_UtilUsbCtlR.h" />
<ClInclude Include="So7_Util_External_Trig.h" />
<ClInclude Include="So7_Util_ImageDll.h" />
<ClInclude Include="So7_Util_PLC_TCPIP.h" />
<ClInclude Include="So7_Util_Program.h" />
<ClInclude Include="SO7_Verfication_Algorithm.h" />
<ClInclude Include="SO7_VolComp.h" />
@@ -223,6 +223,12 @@
<ClCompile Include="Videocard_MV900.cpp">
<Filter>Sources Files</Filter>
</ClCompile>
<ClCompile Include="So7_Util_PLC_TCPIP.cpp">
<Filter>Sources Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\SevenOcean\So7_TCPIP.cpp">
<Filter>Sources Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CaptureDataDlg.h">
@@ -480,6 +486,12 @@
<ClInclude Include="Videocard_MV900.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\SevenOcean\So7_TCPIP.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="So7_Util_PLC_TCPIP.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
@@ -754,6 +754,7 @@
#define IDC_RADIO_SO7_IP_CAMERA2 1604
#define IDC_RADIO_SO7_USB_CAMERA 1604
#define IDC_RADIO_TC4000_CHANNEL2 1605
#define IDC_RADIO_SO7_OMRON_PLC 1605
#define IDC_RADIO_TC4000_CHANNEL3 1606
#define IDC_RADIO_TC4000_CHANNEL4 1607
#define IDC_RADIO_SV2000E_CHANNEL1 1608
@@ -874,6 +875,7 @@
#define IDD_SO7_ART_PCI8622 1721
#define IDD_DIALOG_STIL_CCS_PRIMA 1722
#define IDD_SO7_VIDEOCARD_MV900 1723
#define IDD_SO7_UTIL_PLC_TCPIP 1724
#define IDC_RADIO_SPEED_SLOW 1770
#define IDC_RADIO_SCALE 1772
#define IDC_EDIT_SPEED_X 1773
@@ -1000,6 +1002,7 @@
#define IDC_BUTTON_ART_PCI8622_STOP 1844
#define IDC_BUTTON_R1_HOME 1845
#define IDC_BUTTON_ART_PCI8622_READ_DATA 1845
#define IDC_BUTTON_PLC_TCPIP_CLEAR_MSG 1845
#define IDC_CHECK_SO7_R1_ENABLE 1846
#define IDC_EDIT_ART_PCI8622_LOG 1846
#define IDC_EDIT_R1_CURRENT_POSITION 1847
@@ -1044,6 +1047,12 @@
#define IDC_MV900_CHECK_MIRROR_VERTICALLY 1880
#define IDC_RADIO_MV900_GRAY 1881
#define IDC_RADIO_MV900_RGB 1882
#define IDC_BUTTON_PLC_TCPIP_CONNECT 1883
#define IDC_BUTTON_PLC_TCPIP_DISCONNECT 1884
#define IDC_BUTTON_PLC_TCPIP_READ 1885
#define IDC_BUTTON_PLC_TCPIP_WRITE 1886
#define IDC_EDIT_PLC_TCPIP_ADDR 1887
#define IDC_EDIT_MSG 1888
#define IDC_BUTTON_DIY_EXIT_BUTTON 32740
#define ID_EDIT_SO7_CONFIG_MOTION 32741
@@ -1053,7 +1062,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 193
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1883
#define _APS_NEXT_CONTROL_VALUE 1889
#define _APS_NEXT_SYMED_VALUE 104
#endif
#endif