a
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
// D:\zm\GeomativeV2.5\cpp\logging\CDialogLoggingCreateTaskWnd.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "logging\CDialogLoggingCreateTaskWnd.h"
|
||||
#include "logging\CLoggingDataOper.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
#define LOGGING_MESSAGEBOX_TITLE _T("CDialogLoggingCreateTaskWnd")
|
||||
extern int g_iUILanguage;
|
||||
// CDialogLoggingCreateTaskWnd 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CDialogLoggingCreateTaskWnd, CDialog)
|
||||
|
||||
CDialogLoggingCreateTaskWnd::CDialogLoggingCreateTaskWnd(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialogLoggingCreateTaskWnd::IDD, pParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CDialogLoggingCreateTaskWnd::~CDialogLoggingCreateTaskWnd()
|
||||
{
|
||||
}
|
||||
|
||||
void CDialogLoggingCreateTaskWnd::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_COMBO_WAVEFORM, m_comWaveform);
|
||||
DDX_Control(pDX, IDC_COMBO_LOGGING_DIRECTION, m_comLoggingDirection);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialogLoggingCreateTaskWnd, CDialog)
|
||||
ON_BN_CLICKED(IDOK, &CDialogLoggingCreateTaskWnd::OnBnClickedOk)
|
||||
ON_BN_CLICKED(IDCANCEL, &CDialogLoggingCreateTaskWnd::OnBnClickedCancel)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CDialogLoggingCreateTaskWnd 消息处理程序
|
||||
|
||||
BOOL CDialogLoggingCreateTaskWnd::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
GetDlgItem(IDC_EDIT_TRACE)->SetWindowTextA(_T("0"));
|
||||
m_comWaveform.AddString(_T("0+0-"));
|
||||
m_comWaveform.SetCurSel(0);
|
||||
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowTextA(_T("新建任务"));
|
||||
GetDlgItem(IDC_STATIC_TASK_NAME)->SetWindowTextA(_T("任务名*:"));
|
||||
GetDlgItem(IDC_STATIC_TEST_LOCATION)->SetWindowTextA(_T("测试地点:"));
|
||||
GetDlgItem(IDC_STATIC)->SetWindowTextA(_T("测井类型*"));
|
||||
GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG)->SetWindowTextA(_T("长电位测井"));
|
||||
GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG)->SetWindowTextA(_T("短电位测井"));
|
||||
GetDlgItem(IDC_CHECK_GRADIENT_LOG)->SetWindowTextA(_T("梯度测井"));
|
||||
GetDlgItem(IDC_CHECK_SP_LOG)->SetWindowTextA(_T("SP测井"));
|
||||
GetDlgItem(IDC_STATIC_TRACE)->SetWindowTextA(_T("迭代次数:"));
|
||||
GetDlgItem(IDC_STATIC_WAVEFORM)->SetWindowTextA(_T("发射波形:"));
|
||||
GetDlgItem(IDC_STATIC_SAMPLING_INTERVAL)->SetWindowTextA(_T("采样间隔:"));
|
||||
GetDlgItem(IDC_STATIC_INITIAL_DEPTH)->SetWindowTextA(_T("初始深度*:"));
|
||||
GetDlgItem(IDC_STATIC_END_DEPTH)->SetWindowTextA(_T("结束深度*:"));
|
||||
GetDlgItem(IDC_STATIC_LOGGING_DIRECTION)->SetWindowTextA(_T("测井方向*:"));
|
||||
GetDlgItem(IDC_STATIC_LOGGING_INTERVAL)->SetWindowTextA(_T("测井间隔*:"));
|
||||
GetDlgItem(IDC_STATIC_INSTRUMENT_ZERO_LENGTH)->SetWindowTextA(_T("仪器零长*:"));
|
||||
GetDlgItem(IDC_STATIC_PERIOD)->SetWindowTextA(_T("周期*:"));
|
||||
GetDlgItem(IDOK)->SetWindowTextA(_T("确定"));
|
||||
GetDlgItem(IDCANCEL)->SetWindowTextA(_T("取消"));
|
||||
|
||||
m_comLoggingDirection.AddString(_T("向上"));
|
||||
m_comLoggingDirection.AddString(_T("向下"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_comLoggingDirection.AddString(_T("up"));
|
||||
m_comLoggingDirection.AddString(_T("down"));
|
||||
}
|
||||
m_comLoggingDirection.SetCurSel(0);
|
||||
// TODO: 在此添加额外的初始化
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void CDialogLoggingCreateTaskWnd::OnBnClickedOk()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CString strTaskName;
|
||||
GetDlgItem(IDC_EDIT_TASK_NAME)->GetWindowTextA(strTaskName);
|
||||
if (strTaskName.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("任务名不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Task name cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strTestLocation;
|
||||
GetDlgItem(IDC_EDIT_TEST_LOCATION)->GetWindowTextA(strTestLocation);
|
||||
|
||||
BYTE byLogTypes = 0;
|
||||
int iTemp = -1;
|
||||
iTemp = ((CButton*)GetDlgItem(IDC_CHECK_SP_LOG))->GetCheck();
|
||||
if (iTemp > 0)
|
||||
{
|
||||
byLogTypes |= 1;
|
||||
}
|
||||
iTemp = ((CButton*)GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG))->GetCheck();
|
||||
if (iTemp > 0)
|
||||
{
|
||||
byLogTypes |= 2;
|
||||
}
|
||||
iTemp = ((CButton*)GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG))->GetCheck();
|
||||
if (iTemp > 0)
|
||||
{
|
||||
byLogTypes |= 4;
|
||||
}
|
||||
iTemp = ((CButton*)GetDlgItem(IDC_CHECK_GRADIENT_LOG))->GetCheck();
|
||||
if (iTemp > 0)
|
||||
{
|
||||
byLogTypes |= 8;
|
||||
}
|
||||
|
||||
if (byLogTypes <= 0)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择测井类型"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select the logging type"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strTrace;
|
||||
GetDlgItem(IDC_EDIT_TRACE)->GetWindowTextA(strTrace);
|
||||
if (strTrace.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("迭代次数不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Number of iterations cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
int iWaveform = m_comWaveform.GetCurSel();
|
||||
if (iWaveform < 0)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择发射波形"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select the launch waveform"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strSamplingInterval;
|
||||
GetDlgItem(IDC_EDIT_SAMPLING_INTERVAL)->GetWindowTextA(strSamplingInterval);
|
||||
if (strSamplingInterval.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("采样间隔不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Sampling interval must not be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strInitialDepth;
|
||||
GetDlgItem(IDC_EDIT_INITIAL_DEPTH)->GetWindowTextA(strInitialDepth);
|
||||
if (strInitialDepth.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("初始深度不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Initial depth cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strEndDepth;
|
||||
GetDlgItem(IDC_EDIT_END_DEPTH)->GetWindowTextA(strEndDepth);
|
||||
if (strEndDepth.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("结束深度不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("End depth cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
int iLogDir = m_comLoggingDirection.GetCurSel();
|
||||
if (iLogDir < 0)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择测井方向"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select the logging direction"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strLoggingInterval;
|
||||
GetDlgItem(IDC_EDIT_LOGGING_INTERVAL)->GetWindowTextA(strLoggingInterval);
|
||||
if (strLoggingInterval.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("测井间隔不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Log interval must not be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strInstrumentZeroLength;
|
||||
GetDlgItem(IDC_EDIT_INSTRUMENT_ZERO_LENGTH)->GetWindowTextA(strInstrumentZeroLength);
|
||||
if (strInstrumentZeroLength.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("仪器零长不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Instrument zero length cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strPeriod;
|
||||
GetDlgItem(IDC_EDIT_PERIOD)->GetWindowTextA(strPeriod);
|
||||
if (strPeriod.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("周期不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Period cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
//将数据希尔
|
||||
BOOL bRes = CLoggingDataOper::GetInstance()->SaveTaskInfoIntoDB(strTaskName, strTestLocation, byLogTypes, strTrace, iWaveform, strSamplingInterval, strInitialDepth, strEndDepth, iLogDir, strLoggingInterval,strInstrumentZeroLength,strPeriod);
|
||||
if (bRes)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("创建任务成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Create task successful"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("创建任务失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Failed to create task"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CDialogLoggingCreateTaskWnd::OnBnClickedCancel()
|
||||
{
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
// D:\zm\GeomativeV2.5\cpp\logging\CDialogLoggingEditSymbolBoard.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "logging\CDialogLoggingEditSymbolBoard.h"
|
||||
#include "logging\CLoggingDataOper.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// CDialogLoggingEditSymbolBoard 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CDialogLoggingEditSymbolBoard, CDialogEx)
|
||||
|
||||
CDialogLoggingEditSymbolBoard::CDialogLoggingEditSymbolBoard(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialogLoggingEditSymbolBoard::IDD, pParent)
|
||||
{
|
||||
m_bSaveBmp = FALSE;
|
||||
//m_strLithologyPic.Empty();
|
||||
}
|
||||
|
||||
CDialogLoggingEditSymbolBoard::~CDialogLoggingEditSymbolBoard()
|
||||
{
|
||||
m_mapPointStatus.clear();
|
||||
//memset(m_iPointStatusArray, 0, sizeof(m_iPointStatusArray));
|
||||
}
|
||||
|
||||
CDialogLoggingEditSymbolBoard* CDialogLoggingEditSymbolBoard::GetInstance()
|
||||
{
|
||||
static CDialogLoggingEditSymbolBoard dlg;
|
||||
return &dlg;
|
||||
}
|
||||
|
||||
void CDialogLoggingEditSymbolBoard::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialogLoggingEditSymbolBoard, CDialog)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_LBUTTONUP()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BOOL CDialogLoggingEditSymbolBoard::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
m_mapPointStatus.clear();
|
||||
//memset(m_iPointStatusArray, 0, sizeof(m_iPointStatusArray));
|
||||
//m_strLithologyPic.Empty();
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
// CDialogLoggingEditSymbolBoard 消息处理程序
|
||||
void CDialogLoggingEditSymbolBoard::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
// 不为绘图消息调用 CDialogEx::OnPaint()
|
||||
RECT rcWnd;
|
||||
GetClientRect(&rcWnd);
|
||||
dc.FillSolidRect(&rcWnd, RGB(255, 255, 255));
|
||||
|
||||
//加载图片
|
||||
/*if (!m_strLithologyPic.IsEmpty())
|
||||
{
|
||||
RECT rcWnd;
|
||||
GetClientRect(&rcWnd);
|
||||
|
||||
CDC memDC;
|
||||
memDC.CreateCompatibleDC(&dc);
|
||||
HBITMAP hBmp = (HBITMAP)LoadImage(AfxGetInstanceHandle(), m_strLithologyPic, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
//CBitmap* pBmp = memDC.SelectObject(&hBmp);
|
||||
CBitmap bmp;
|
||||
if (bmp.Attach(hBmp))
|
||||
{
|
||||
BITMAP bitMap;
|
||||
bmp.GetBitmap(&bitMap);
|
||||
CBitmap* pBmp = memDC.SelectObject(&bmp);
|
||||
dc.StretchBlt(rcWnd.left, rcWnd.top, rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top, &memDC, 0, 0, bitMap.bmWidth, bitMap.bmHeight, SRCCOPY);
|
||||
dc.SelectObject(pBmp);
|
||||
}
|
||||
}*/
|
||||
|
||||
//绘制网格
|
||||
if (!m_bSaveBmp)
|
||||
{
|
||||
CPen pen, BlackPen;
|
||||
BlackPen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
|
||||
|
||||
pen.CreatePen(PS_SOLID, 1, RGB(195, 195, 195));
|
||||
dc.SelectObject(pen);
|
||||
//dc.Rectangle(&rcWnd);
|
||||
//绘制竖线
|
||||
for (int x = rcWnd.left; x <= rcWnd.left+GRID_SIZE*GRID_X_DIRECTION_SIZE; x += GRID_SIZE)
|
||||
{
|
||||
dc.MoveTo(x, rcWnd.top);
|
||||
dc.LineTo(x, rcWnd.bottom);
|
||||
}
|
||||
|
||||
//绘制横线
|
||||
for (int y = rcWnd.top; y <= rcWnd.top + GRID_SIZE*GRID_Y_DIRECTION_SIZE; y += GRID_SIZE)
|
||||
{
|
||||
dc.MoveTo(rcWnd.left, y);
|
||||
dc.LineTo(rcWnd.right, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBrush BlackBrush;
|
||||
BlackBrush.CreateSolidBrush(RGB(0, 0, 0));
|
||||
dc.SelectObject(BlackBrush);
|
||||
|
||||
//绘制点
|
||||
RECT rcPoint;
|
||||
map<int, map<int, bool>>::iterator iterX = m_mapPointStatus.begin();
|
||||
map<int, bool>::iterator iterY;
|
||||
for (; iterX != m_mapPointStatus.end(); iterX++)
|
||||
{
|
||||
iterY = iterX->second.begin();
|
||||
for (; iterY != iterX->second.end(); iterY++)
|
||||
{
|
||||
if (iterY->second == true)
|
||||
{
|
||||
rcPoint.left = iterX->first * GRID_SIZE;
|
||||
rcPoint.right = rcPoint.left + GRID_SIZE;
|
||||
rcPoint.top = iterY->first* GRID_SIZE;
|
||||
rcPoint.bottom = rcPoint.top + GRID_SIZE;
|
||||
dc.Rectangle(&rcPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*//绘制点
|
||||
RECT rcPoint;
|
||||
int i, j;
|
||||
for (i = 0; i < GRID_X_DIRECTION_SIZE; i++)
|
||||
{
|
||||
for (j = 0; j < GRID_Y_DIRECTION_SIZE; j++)
|
||||
{
|
||||
if (m_iPointStatusArray[i][j] == 1)
|
||||
{
|
||||
rcPoint.left = i* GRID_SIZE;
|
||||
rcPoint.right = rcPoint.left + GRID_SIZE;
|
||||
rcPoint.top = j*GRID_SIZE;
|
||||
rcPoint.bottom = rcPoint.top + GRID_SIZE;
|
||||
dc.Rectangle(&rcPoint);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
CString CDialogLoggingEditSymbolBoard::CaptureScreen(LPRECT lpRect, CString strLithologyType)//lpRect为NULL时表示全屏幕截图
|
||||
{
|
||||
int iDestX, iDestY;
|
||||
if (lpRect)
|
||||
{
|
||||
iDestX = lpRect->right - lpRect->left;
|
||||
iDestY = lpRect->bottom - lpRect->top;
|
||||
}
|
||||
else
|
||||
{
|
||||
iDestX = GetSystemMetrics(SM_CXSCREEN);
|
||||
iDestY = GetSystemMetrics(SM_CYSCREEN);
|
||||
}
|
||||
|
||||
CDC* pdc = GetDC();
|
||||
HDC hdc = CreateCompatibleDC(pdc->GetSafeHdc());
|
||||
HBITMAP hBitmap = CreateCompatibleBitmap(hdc, iDestX, iDestY);
|
||||
SelectObject(hdc, hBitmap);
|
||||
|
||||
BitBlt(hdc, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, pdc->GetSafeHdc(), 0, 0, SRCCOPY);
|
||||
ReleaseDC(pdc);
|
||||
|
||||
|
||||
HDC dc = CreateCompatibleDC(hdc);
|
||||
HBITMAP hBmp = CreateCompatibleBitmap(dc, iDestX, iDestY);
|
||||
SelectObject(dc, hBmp);
|
||||
BitBlt(dc, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, hdc, lpRect->left, lpRect->top, SRCCOPY);
|
||||
|
||||
CString strFile;
|
||||
strFile.Format(_T("./lithology/%s.bmp"), strLithologyType);
|
||||
|
||||
//先删除之前的
|
||||
DeleteFile(strFile);
|
||||
|
||||
SaveBmp(hBmp, strFile);
|
||||
|
||||
DeleteDC(hdc);
|
||||
return strFile;
|
||||
}
|
||||
BOOL CDialogLoggingEditSymbolBoard::SaveBmp(HBITMAP hBitmap, const TCHAR* FileName)
|
||||
{
|
||||
HDC hDC;
|
||||
//当前分辨率下每象素所占字节数
|
||||
int iBits;
|
||||
//位图中每象素所占字节数
|
||||
WORD wBitCount;
|
||||
//定义调色板大小, 位图中像素字节大小 ,位图文件大小 , 写入文件字节数
|
||||
DWORD dwPaletteSize = 0, dwBmBitsSize = 0, dwDIBSize = 0, dwWritten = 0;
|
||||
//位图属性结构
|
||||
BITMAP Bitmap;
|
||||
//位图文件头结构
|
||||
BITMAPFILEHEADER bmfHdr;
|
||||
//位图信息头结构
|
||||
BITMAPINFOHEADER bi;
|
||||
//指向位图信息头结构
|
||||
LPBITMAPINFOHEADER lpbi;
|
||||
//定义文件,分配内存句柄,调色板句柄
|
||||
HANDLE fh, hDib, hPal, hOldPal = NULL;
|
||||
|
||||
//计算位图文件每个像素所占字节数
|
||||
hDC = CreateDC(("DISPLAY"), NULL, NULL, NULL);
|
||||
iBits = GetDeviceCaps(hDC, BITSPIXEL) *GetDeviceCaps(hDC, PLANES);
|
||||
DeleteDC(hDC);
|
||||
if (iBits <= 1)
|
||||
{
|
||||
wBitCount = 1;
|
||||
}
|
||||
else if (iBits <= 4)
|
||||
{
|
||||
wBitCount = 4;
|
||||
}
|
||||
else if (iBits <= 8)
|
||||
{
|
||||
wBitCount = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
wBitCount = 24;
|
||||
}
|
||||
|
||||
GetObject(hBitmap, sizeof(Bitmap), (LPSTR)&Bitmap);
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = Bitmap.bmWidth;
|
||||
bi.biHeight = Bitmap.bmHeight;
|
||||
bi.biPlanes = 1;
|
||||
bi.biBitCount = wBitCount;
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage = 0;
|
||||
bi.biXPelsPerMeter = 0;
|
||||
bi.biYPelsPerMeter = 0;
|
||||
bi.biClrImportant = 0;
|
||||
bi.biClrUsed = 0;
|
||||
|
||||
dwBmBitsSize = ((Bitmap.bmWidth * wBitCount + 31) / 32) * 4 * Bitmap.bmHeight;
|
||||
|
||||
//为位图内容分配内存
|
||||
hDib = GlobalAlloc(GHND, dwBmBitsSize + dwPaletteSize + sizeof(BITMAPINFOHEADER));
|
||||
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDib);
|
||||
*lpbi = bi;
|
||||
|
||||
// 处理调色板
|
||||
hPal = GetStockObject(DEFAULT_PALETTE);
|
||||
if (hPal)
|
||||
{
|
||||
hDC = ::GetDC(NULL);
|
||||
hOldPal = ::SelectPalette(hDC, (HPALETTE)hPal, FALSE);
|
||||
RealizePalette(hDC);
|
||||
}
|
||||
|
||||
// 获取该调色板下新的像素值
|
||||
GetDIBits(hDC,
|
||||
hBitmap,
|
||||
0,
|
||||
(UINT)Bitmap.bmHeight,
|
||||
(LPSTR)lpbi + sizeof(BITMAPINFOHEADER) + dwPaletteSize,
|
||||
(BITMAPINFO *)lpbi,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
//恢复调色板
|
||||
if (hOldPal)
|
||||
{
|
||||
::SelectPalette(hDC, (HPALETTE)hOldPal, TRUE);
|
||||
RealizePalette(hDC);
|
||||
::ReleaseDC(NULL, hDC);
|
||||
}
|
||||
|
||||
//创建位图文件
|
||||
fh = CreateFile((LPCSTR)FileName,
|
||||
GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);/* FILE_FLAG_SEQUENTIAL_SCAN, NULL); */
|
||||
|
||||
if (fh == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 设置位图文件头
|
||||
bmfHdr.bfType = 0x4D42; // "BM"
|
||||
dwDIBSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dwPaletteSize + dwBmBitsSize;
|
||||
bmfHdr.bfSize = dwDIBSize;
|
||||
bmfHdr.bfReserved1 = 0;
|
||||
bmfHdr.bfReserved2 = 0;
|
||||
bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER) + dwPaletteSize;
|
||||
// 写入位图文件头
|
||||
WriteFile(fh, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL);
|
||||
// 写入位图文件其余内容
|
||||
WriteFile(fh, (LPSTR)lpbi, dwDIBSize, &dwWritten, NULL);
|
||||
//清除
|
||||
GlobalUnlock(hDib);
|
||||
GlobalFree(hDib);
|
||||
CloseHandle(fh);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//保存岩性图片
|
||||
CString CDialogLoggingEditSymbolBoard::SaveLithologyBitmap(CString strLithologyType, CString strLithologyName)
|
||||
{
|
||||
m_bSaveBmp = TRUE;
|
||||
RedrawWindow();
|
||||
|
||||
RECT rcWnd;
|
||||
GetClientRect(&rcWnd);
|
||||
CString strFile = CaptureScreen(&rcWnd, strLithologyType);
|
||||
m_bSaveBmp = FALSE;
|
||||
RedrawWindow();
|
||||
|
||||
//保存图片到数据库
|
||||
CLoggingDataOper::GetInstance()->InsertDBLithologyBitmap(strLithologyType, strLithologyName, strFile, m_mapPointStatus);
|
||||
return strFile;
|
||||
}
|
||||
|
||||
//删除岩性图片
|
||||
BOOL CDialogLoggingEditSymbolBoard::DeleteLithologyBitmap(CString strLithologyType, CString strLithologyPicPath)
|
||||
{
|
||||
//清空面板
|
||||
m_mapPointStatus.clear();
|
||||
//memset(m_iPointStatusArray, 0, sizeof(m_iPointStatusArray));
|
||||
//m_strLithologyPic.Empty();
|
||||
|
||||
//删除数据库图片文件
|
||||
CLoggingDataOper::GetInstance()->DeleteDBLithologyBitmap(strLithologyType);
|
||||
|
||||
RedrawWindow();
|
||||
return DeleteFile(strLithologyPicPath);
|
||||
}
|
||||
|
||||
//加载岩性图片
|
||||
BOOL CDialogLoggingEditSymbolBoard::LoadLithologyBitmap(CString strBmpFile)
|
||||
{
|
||||
//清空面板
|
||||
m_mapPointStatus.clear();
|
||||
//memset(m_iPointStatusArray, 0, sizeof(m_iPointStatusArray));
|
||||
m_mapPointStatus = CLoggingDataOper::GetInstance()->LoadLithologyBitmapFromDB(strBmpFile);
|
||||
//m_strLithologyPic = strBmpFile;
|
||||
RedrawWindow();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CDialogLoggingEditSymbolBoard::OnLButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
int iPointX = point.x / GRID_SIZE;
|
||||
int iPointY = point.y / GRID_SIZE;
|
||||
//m_iPointStatusArray[iPointX][iPointY] = !m_iPointStatusArray[iPointX][iPointY];
|
||||
map<int, bool> mapY;
|
||||
map<int, map<int, bool>>::iterator iterX = m_mapPointStatus.find(iPointX);
|
||||
if (iterX == m_mapPointStatus.end())
|
||||
{
|
||||
//未找到
|
||||
mapY[iPointY] = true;
|
||||
m_mapPointStatus[iPointX] = mapY;//覆盖
|
||||
}
|
||||
else
|
||||
{
|
||||
//找到
|
||||
map<int, bool>::iterator iterY = iterX->second.find(iPointY);
|
||||
if (iterY == iterX->second.end())
|
||||
{
|
||||
iterX->second.insert(make_pair(iPointY, true));//向已有map中插入
|
||||
}
|
||||
else
|
||||
{
|
||||
iterX->second.erase(iPointY);
|
||||
}
|
||||
}
|
||||
|
||||
RedrawWindow();
|
||||
CDialog::OnLButtonDown(nFlags, point);
|
||||
}
|
||||
|
||||
void CDialogLoggingEditSymbolBoard::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
|
||||
CDialog::OnLButtonUp(nFlags, point);
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
// D:\zm\GeomativeV2.5\cpp\logging\CDialogLoggingLithologicWnd.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "logging\CLoggingDataOper.h"
|
||||
#include "logging\CDialogLoggingLithologicWnd.h"
|
||||
#include "logging\CDialogLoggingSymbolEditor.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// CDialogLoggingLithologicWnd 对话框
|
||||
extern CGeoMativeApp theApp;
|
||||
IMPLEMENT_DYNAMIC(CDialogLoggingLithologicWnd, CDialog)
|
||||
|
||||
CDialogLoggingLithologicWnd::CDialogLoggingLithologicWnd(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialogLoggingLithologicWnd::IDD, pParent)
|
||||
{
|
||||
m_strCurPicPath.Empty();
|
||||
}
|
||||
|
||||
CDialogLoggingLithologicWnd::~CDialogLoggingLithologicWnd()
|
||||
{
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::SetStartEndDepth(float fStartDepth, float fEndDepth)
|
||||
{
|
||||
m_fStartDepth = fStartDepth;
|
||||
m_fEndDepth = fEndDepth;
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::SetProfileList(std::vector<STLithologyProfile> vecProfileList)
|
||||
{
|
||||
m_vecProfileList = vecProfileList;
|
||||
}
|
||||
|
||||
vector<STLithologyProfile> CDialogLoggingLithologicWnd::GetProfileList()
|
||||
{
|
||||
return m_vecProfileList;
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_LIST_PROFILE, m_listProfile);
|
||||
DDX_Control(pDX, IDC_COMBO_LITHOLOGY_NAME, m_comLithologyName);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialogLoggingLithologicWnd, CDialog)
|
||||
ON_BN_CLICKED(IDC_BTN_LITHOLOGY_EDITOR, &CDialogLoggingLithologicWnd::OnBnClickedBtnLithologyEditor)
|
||||
ON_BN_CLICKED(IDC_BTN_ADD_PROFILE, &CDialogLoggingLithologicWnd::OnBnClickedBtnAddProfile)
|
||||
ON_BN_CLICKED(IDC_BTN_DELETE_PROFILE, &CDialogLoggingLithologicWnd::OnBnClickedBtnDeleteProfile)
|
||||
ON_BN_CLICKED(IDOK, &CDialogLoggingLithologicWnd::OnBnClickedOk)
|
||||
ON_BN_CLICKED(IDCANCEL, &CDialogLoggingLithologicWnd::OnBnClickedCancel)
|
||||
ON_CBN_SELCHANGE(IDC_COMBO_LITHOLOGY_NAME, &CDialogLoggingLithologicWnd::OnCbnSelchangeComboLithologyName)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_DESTROY()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// CDialogLoggingLithologicWnd 消息处理程序
|
||||
BOOL CDialogLoggingLithologicWnd::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
RECT rcList;
|
||||
m_listProfile.GetClientRect(&rcList);
|
||||
int iWidth = rcList.right - rcList.left;
|
||||
DWORD dwStyle = m_listProfile.GetExtendedStyle();
|
||||
dwStyle |= LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT;
|
||||
m_listProfile.SetExtendedStyle(dwStyle);
|
||||
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowText(_T("岩性剖面窗口"));
|
||||
SetDlgItemText(IDC_STATIC_SELECT_LITHOLOGY, _T("选择岩性"));
|
||||
SetDlgItemText(IDC_STATIC_PREVIEW, _T("预览:"));
|
||||
SetDlgItemText(IDC_BTN_LITHOLOGY_EDITOR, _T("岩性编辑"));
|
||||
SetDlgItemText(IDC_STATIC_DEPTH_RANGE, _T("深度范围"));
|
||||
SetDlgItemText(IDC_STATIC_START_DEPTH, _T("从"));
|
||||
SetDlgItemText(IDC_STATIC_END_DEPTH, _T("到"));
|
||||
SetDlgItemText(IDC_BTN_ADD_PROFILE, _T("添加剖面"));
|
||||
SetDlgItemText(IDC_BTN_DELETE_PROFILE, _T("删除剖面"));
|
||||
SetDlgItemText(IDC_STATIC_PROFILE_LIST, _T("剖面列表"));
|
||||
SetDlgItemText(IDOK, _T("确定"));
|
||||
SetDlgItemText(IDCANCEL, _T("取消"));
|
||||
|
||||
m_listProfile.InsertColumn(0, _T("起始深度"));
|
||||
m_listProfile.InsertColumn(1, _T("终止深度"));
|
||||
m_listProfile.InsertColumn(2, _T("岩性"));
|
||||
m_listProfile.InsertColumn(3, _T(""));//岩性图片
|
||||
}
|
||||
else
|
||||
{
|
||||
m_listProfile.InsertColumn(0, _T("Start Depth"));
|
||||
m_listProfile.InsertColumn(1, _T("End Depth"));
|
||||
m_listProfile.InsertColumn(2, _T("Lithology"));
|
||||
m_listProfile.InsertColumn(3, _T(""));//岩性图片
|
||||
}
|
||||
QueryLithologyNameFromDB();
|
||||
|
||||
m_listProfile.SetColumnWidth(0, iWidth / 3);
|
||||
m_listProfile.SetColumnWidth(1, iWidth / 3);
|
||||
m_listProfile.SetColumnWidth(2, iWidth - iWidth / 3 - iWidth / 3);
|
||||
m_listProfile.SetColumnWidth(3, 0);
|
||||
|
||||
CString strText;
|
||||
strText.Format(_T("%.1f"), m_fStartDepth);
|
||||
SetDlgItemText(IDC_EDIT_START_DEPTH, strText);
|
||||
|
||||
strText.Format(_T("%.1f"), m_fEndDepth);
|
||||
SetDlgItemText(IDC_EDIT_END_DEPTH, strText);
|
||||
|
||||
//初始化列表数据
|
||||
int iItemCount = m_vecProfileList.size();
|
||||
if (iItemCount > 0)
|
||||
{
|
||||
for (int i = 0; i < iItemCount; i++)
|
||||
{
|
||||
m_listProfile.InsertItem(i, _T(""));
|
||||
strText.Format(_T("%.1f"), m_vecProfileList[i].fStartDepth);
|
||||
m_listProfile.SetItemText(i, 0, strText);
|
||||
|
||||
strText.Format(_T("%.1f"), m_vecProfileList[i].fEndDepth);
|
||||
m_listProfile.SetItemText(i, 1, strText);
|
||||
|
||||
m_listProfile.SetItemText(i, 2, m_vecProfileList[i].szLithologyName);
|
||||
|
||||
m_listProfile.SetItemText(i, 3, m_vecProfileList[i].szLithologyPic);
|
||||
}
|
||||
}
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::ReleaseComboBox()
|
||||
{
|
||||
int iItemCount = m_comLithologyName.GetCount();
|
||||
char* pszLithologyPic = NULL;
|
||||
for (int i = 0; i < iItemCount; i++)
|
||||
{
|
||||
pszLithologyPic = (char*)m_comLithologyName.GetItemData(i);
|
||||
if (pszLithologyPic != NULL)
|
||||
{
|
||||
delete[] pszLithologyPic;
|
||||
pszLithologyPic = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
m_comLithologyName.ResetContent();
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::QueryLithologyNameFromDB()
|
||||
{
|
||||
ReleaseComboBox();
|
||||
m_mapLithologyInfo.clear();
|
||||
|
||||
m_mapLithologyInfo = CLoggingDataOper::GetInstance()->QueryLithologyInfo();
|
||||
int iItemCount = m_mapLithologyInfo.size();
|
||||
if (iItemCount > 0)
|
||||
{
|
||||
map<CString, STLoggingLithologyInfo>::iterator iter = m_mapLithologyInfo.begin();
|
||||
int iLength = 0;
|
||||
char* pszLithologyPic = NULL;
|
||||
for (int i = 0; iter != m_mapLithologyInfo.end(), i < iItemCount; iter++, i++)
|
||||
{
|
||||
m_comLithologyName.AddString(iter->second.szLithologyName);
|
||||
|
||||
iLength = sizeof(iter->second.szLithologyPic);
|
||||
pszLithologyPic = new char[iLength];
|
||||
strcpy(pszLithologyPic, iter->second.szLithologyPic);
|
||||
m_comLithologyName.SetItemData(i, (DWORD_PTR)pszLithologyPic);
|
||||
}
|
||||
|
||||
m_comLithologyName.SetCurSel(0);
|
||||
OnCbnSelchangeComboLithologyName();
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::OnBnClickedBtnLithologyEditor()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CDialogLoggingSymbolEditor dlgSymbolEditor;
|
||||
dlgSymbolEditor.DoModal();
|
||||
QueryLithologyNameFromDB();
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::OnBnClickedBtnAddProfile()
|
||||
{
|
||||
CString strStartDepth, strEndDepth, strLithologyName, strLithologyPic;
|
||||
GetDlgItemTextA(IDC_EDIT_START_DEPTH, strStartDepth);
|
||||
GetDlgItemTextA(IDC_EDIT_END_DEPTH, strEndDepth);
|
||||
strStartDepth.Format(_T("%.1f"), atof(strStartDepth));
|
||||
strEndDepth.Format(_T("%.1f"), atof(strEndDepth));
|
||||
|
||||
int iItemCount = m_listProfile.GetItemCount();
|
||||
CString strListStartDepth, strListEndDepth;
|
||||
for (int i = 0; i < iItemCount; i++)
|
||||
{
|
||||
strListStartDepth.Format(_T("%.1f"), atof(m_listProfile.GetItemText(i, 0)));
|
||||
strListEndDepth.Format(_T("%.1f"), atof(m_listProfile.GetItemText(i, 1)));
|
||||
if ((atof(strStartDepth) > atof(strListStartDepth) && atof(strStartDepth) < atof(strListEndDepth))
|
||||
|| (atof(strEndDepth) > atof(strListStartDepth) && atof(strEndDepth) < atof(strListEndDepth))
|
||||
|| (atof(strListStartDepth) == atof(strStartDepth) && atof(strListEndDepth) == atof(strEndDepth)))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("输入的深度范围和之前的岩性图范围有交叠,请重新输入!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Input depth range overlaps with the previous lithology map range, please re-enter!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int iSel = m_comLithologyName.GetCurSel();
|
||||
m_comLithologyName.GetWindowTextA(strLithologyName);
|
||||
strLithologyPic = (char*)m_comLithologyName.GetItemData(iSel);
|
||||
|
||||
m_listProfile.InsertItem(iItemCount, _T(""));
|
||||
m_listProfile.SetItemText(iItemCount, 0, strStartDepth);
|
||||
m_listProfile.SetItemText(iItemCount, 1, strEndDepth);
|
||||
m_listProfile.SetItemText(iItemCount, 2, strLithologyName);
|
||||
m_listProfile.SetItemText(iItemCount, 3, strLithologyPic);
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::OnBnClickedBtnDeleteProfile()
|
||||
{
|
||||
int iItem = -1;
|
||||
while (m_listProfile.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED) != -1)
|
||||
{
|
||||
iItem = m_listProfile.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
|
||||
m_listProfile.DeleteItem(iItem);
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::OnBnClickedOk()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
m_vecProfileList.clear();
|
||||
|
||||
STLithologyProfile stProfile;
|
||||
int iItemCount = m_listProfile.GetItemCount();
|
||||
for (int i = 0; i < iItemCount; i++)
|
||||
{
|
||||
stProfile.fStartDepth = atof(m_listProfile.GetItemText(i, 0));
|
||||
stProfile.fEndDepth = atof(m_listProfile.GetItemText(i, 1));
|
||||
strcpy(stProfile.szLithologyName,m_listProfile.GetItemText(i, 2));
|
||||
strcpy(stProfile.szLithologyPic, m_listProfile.GetItemText(i, 3));
|
||||
m_vecProfileList.push_back(stProfile);
|
||||
}
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::OnBnClickedCancel()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
|
||||
void CDialogLoggingLithologicWnd::OnCbnSelchangeComboLithologyName()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
int iCurSel = m_comLithologyName.GetCurSel();
|
||||
if (iCurSel != -1)
|
||||
{
|
||||
m_strCurPicPath = (char*)m_comLithologyName.GetItemData(iCurSel);
|
||||
|
||||
RECT rcPic;
|
||||
GetDlgItem(IDC_STATIC_PIC_LITHOLOGY)->GetWindowRect(&rcPic);
|
||||
ScreenToClient(&rcPic);
|
||||
RedrawWindow(&rcPic);
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
CBitmap bmp;
|
||||
CDC dcMem;
|
||||
dcMem.CreateCompatibleDC(&dc); //创建与对话框dc兼容的内存dc
|
||||
RECT rcPic;
|
||||
GetDlgItem(IDC_STATIC_PIC_LITHOLOGY)->GetWindowRect(&rcPic);
|
||||
ScreenToClient(&rcPic);
|
||||
|
||||
HBITMAP hBmp = (HBITMAP)LoadImage(AfxGetInstanceHandle(), m_strCurPicPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
|
||||
if (bmp.Attach(hBmp))
|
||||
{
|
||||
BITMAP bitMap;
|
||||
bmp.GetBitmap(&bitMap);
|
||||
|
||||
CBitmap* pBmp = dcMem.SelectObject(&bmp);
|
||||
dc.StretchBlt(rcPic.left, rcPic.top, rcPic.right-rcPic.left, rcPic.bottom - rcPic.top, &dcMem, 0, 0, bitMap.bmWidth, bitMap.bmHeight, SRCCOPY);
|
||||
dc.SelectObject(pBmp);
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogLoggingLithologicWnd::OnDestroy()
|
||||
{
|
||||
ReleaseComboBox();
|
||||
CDialog::OnDestroy();
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
}
|
||||
@@ -0,0 +1,356 @@
|
||||
// D:\zm\GeomativeV2.5\cpp\logging\CDialogLoggingParameterSetting.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "logging\CDialogLoggingParameterSetting.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
#define LOGGING_MESSAGEBOX_TITLE _T("CDialogLoggingParameterSetting")
|
||||
// CDialogLoggingParameterSetting 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CDialogLoggingParameterSetting, CDialog)
|
||||
|
||||
CDialogLoggingParameterSetting::CDialogLoggingParameterSetting(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialogLoggingParameterSetting::IDD, pParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CDialogLoggingParameterSetting::~CDialogLoggingParameterSetting()
|
||||
{
|
||||
}
|
||||
|
||||
void CDialogLoggingParameterSetting::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_COMBO_TASK_NAME_LIST, m_comTaskList);
|
||||
DDX_Control(pDX, IDC_COMBO_WAVEFORM, m_comWaveform);
|
||||
DDX_Control(pDX, IDC_COMBO_LOGGING_DIRECTION, m_comLoggingDirection);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialogLoggingParameterSetting, CDialog)
|
||||
ON_BN_CLICKED(IDOK, &CDialogLoggingParameterSetting::OnBnClickedOk)
|
||||
ON_BN_CLICKED(IDCANCEL, &CDialogLoggingParameterSetting::OnBnClickedCancel)
|
||||
ON_CBN_SELCHANGE(IDC_COMBO_TASK_NAME_LIST, &CDialogLoggingParameterSetting::OnCbnSelchangeComboTaskNameList)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BOOL CDialogLoggingParameterSetting::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
GetDlgItem(IDC_EDIT_TRACE)->SetWindowTextA(_T("0"));
|
||||
m_comWaveform.AddString(_T("0+0-"));
|
||||
m_comWaveform.SetCurSel(0);
|
||||
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowTextA(_T("测量参数设置"));
|
||||
GetDlgItem(IDC_STATIC_TASK_NAME)->SetWindowTextA(_T("任务名*:"));
|
||||
GetDlgItem(IDC_STATIC_TEST_LOCATION)->SetWindowTextA(_T("测试地点:"));
|
||||
GetDlgItem(IDC_STATIC)->SetWindowTextA(_T("测井类型*"));
|
||||
GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG)->SetWindowTextA(_T("长电位测井"));
|
||||
GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG)->SetWindowTextA(_T("短电位测井"));
|
||||
GetDlgItem(IDC_CHECK_GRADIENT_LOG)->SetWindowTextA(_T("梯度测井"));
|
||||
GetDlgItem(IDC_CHECK_SP_LOG)->SetWindowTextA(_T("SP测井"));
|
||||
GetDlgItem(IDC_STATIC_TRACE)->SetWindowTextA(_T("迭代次数:"));
|
||||
GetDlgItem(IDC_STATIC_WAVEFORM)->SetWindowTextA(_T("发射波形:"));
|
||||
GetDlgItem(IDC_STATIC_SAMPLING_INTERVAL)->SetWindowTextA(_T("采样间隔:"));
|
||||
GetDlgItem(IDC_STATIC_INITIAL_DEPTH)->SetWindowTextA(_T("初始深度*:"));
|
||||
GetDlgItem(IDC_STATIC_END_DEPTH)->SetWindowTextA(_T("结束深度*:"));
|
||||
GetDlgItem(IDC_STATIC_LOGGING_DIRECTION)->SetWindowTextA(_T("测井方向*:"));
|
||||
GetDlgItem(IDC_STATIC_LOGGING_INTERVAL)->SetWindowTextA(_T("测井间隔*:"));
|
||||
GetDlgItem(IDC_STATIC_INSTRUMENT_ZERO_LENGTH)->SetWindowTextA(_T("仪器零长*:"));
|
||||
GetDlgItem(IDC_STATIC_PERIOD)->SetWindowTextA(_T("周期*:"));
|
||||
GetDlgItem(IDOK)->SetWindowTextA(_T("确定"));
|
||||
GetDlgItem(IDCANCEL)->SetWindowTextA(_T("取消"));
|
||||
|
||||
m_comLoggingDirection.AddString(_T("向上"));
|
||||
m_comLoggingDirection.AddString(_T("向下"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_comLoggingDirection.AddString(_T("up"));
|
||||
m_comLoggingDirection.AddString(_T("down"));
|
||||
}
|
||||
m_comLoggingDirection.SetCurSel(0);
|
||||
// TODO: 在此添加额外的初始化
|
||||
m_mapTaskList = CLoggingDataOper::GetInstance()->QueryTaskListFromDB();
|
||||
if (m_mapTaskList.size() > 0)
|
||||
{
|
||||
map<CString, STLoggingTaskInfo>::iterator iter = m_mapTaskList.begin();
|
||||
for (; iter != m_mapTaskList.end(); iter++)
|
||||
{
|
||||
m_comTaskList.AddString(iter->second.szTaskName);
|
||||
}
|
||||
}
|
||||
m_comTaskList.SetCurSel(0);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void CDialogLoggingParameterSetting::OnCbnSelchangeComboTaskNameList()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
int iCurSel = m_comTaskList.GetCurSel();
|
||||
CString strTaskName;
|
||||
m_comTaskList.GetLBText(iCurSel, strTaskName);
|
||||
if (strTaskName.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CString strText;
|
||||
STLoggingTaskInfo stLoggingInfo = CLoggingDataOper::GetInstance()->QueryTaskInfoByName(strTaskName);
|
||||
GetDlgItem(IDC_EDIT_TEST_LOCATION)->SetWindowTextA(stLoggingInfo.szLocation);
|
||||
//工作模式
|
||||
if ((stLoggingInfo.byLogType & 0x01) == 0x01)
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CHECK_SP_LOG))->SetCheck(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CHECK_SP_LOG))->SetCheck(FALSE);
|
||||
}
|
||||
if ((stLoggingInfo.byLogType & 0x02) == 0x02)
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG))->SetCheck(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG))->SetCheck(FALSE);
|
||||
}
|
||||
if ((stLoggingInfo.byLogType & 0x04) == 0x04)
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG))->SetCheck(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG))->SetCheck(FALSE);
|
||||
}
|
||||
if ((stLoggingInfo.byLogType & 0x08) == 0x08)
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CHECK_GRADIENT_LOG))->SetCheck(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
((CButton*)GetDlgItem(IDC_CHECK_GRADIENT_LOG))->SetCheck(FALSE);
|
||||
}
|
||||
|
||||
strText.Empty();
|
||||
strText.Format(_T("%d"), stLoggingInfo.byTrace);
|
||||
GetDlgItem(IDC_EDIT_TRACE)->SetWindowTextA(strText);
|
||||
|
||||
m_comWaveform.SetCurSel(iCurSel);
|
||||
|
||||
strText.Empty();
|
||||
strText.Format(_T("%.2f"), stLoggingInfo.fSamplingInterval);
|
||||
GetDlgItem(IDC_EDIT_SAMPLING_INTERVAL)->SetWindowTextA(strText);
|
||||
|
||||
strText.Empty();
|
||||
strText.Format(_T("%.2f"), stLoggingInfo.fInitDepth);
|
||||
GetDlgItem(IDC_EDIT_INITIAL_DEPTH)->SetWindowTextA(strText);
|
||||
|
||||
strText.Empty();
|
||||
strText.Format(_T("%.2f"), stLoggingInfo.fEndDepth);
|
||||
GetDlgItem(IDC_EDIT_END_DEPTH)->SetWindowTextA(strText);
|
||||
|
||||
m_comLoggingDirection.SetCurSel(stLoggingInfo.byLogDirection);
|
||||
|
||||
strText.Empty();
|
||||
strText.Format(_T("%.2f"), stLoggingInfo.fLoggingDistance);
|
||||
GetDlgItem(IDC_EDIT_LOGGING_INTERVAL)->SetWindowTextA(strText);
|
||||
|
||||
strText.Empty();
|
||||
strText.Format(_T("%.2f"), stLoggingInfo.fInstrumentZeroLength);
|
||||
GetDlgItem(IDC_EDIT_INSTRUMENT_ZERO_LENGTH)->SetWindowTextA(strText);
|
||||
|
||||
strText.Empty();
|
||||
strText.Format(_T("%.2f"), stLoggingInfo.fPeriod);
|
||||
GetDlgItem(IDC_EDIT_PERIOD)->SetWindowTextA(strText);
|
||||
}
|
||||
|
||||
// CDialogLoggingParameterSetting 消息处理程序
|
||||
void CDialogLoggingParameterSetting::OnBnClickedOk()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CString strTaskName;
|
||||
int iCurSel = m_comTaskList.GetCurSel();
|
||||
m_comTaskList.GetLBText(iCurSel, strTaskName);
|
||||
if (strTaskName.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("任务名不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Task name cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strTestLocation;
|
||||
GetDlgItem(IDC_EDIT_TEST_LOCATION)->GetWindowTextA(strTestLocation);
|
||||
|
||||
BYTE byLogTypes = 0;
|
||||
int iTemp = -1;
|
||||
iTemp = ((CButton*)GetDlgItem(IDC_CHECK_SP_LOG))->GetCheck();
|
||||
if (iTemp > 0)
|
||||
{
|
||||
byLogTypes |= 1;
|
||||
}
|
||||
iTemp = ((CButton*)GetDlgItem(IDC_CHECK_LONG_POTENTIAL_LOG))->GetCheck();
|
||||
if (iTemp > 0)
|
||||
{
|
||||
byLogTypes |= 2;
|
||||
}
|
||||
iTemp = ((CButton*)GetDlgItem(IDC_CHECK_SHORT_POTENTIAL_LOG))->GetCheck();
|
||||
if (iTemp > 0)
|
||||
{
|
||||
byLogTypes |= 4;
|
||||
}
|
||||
iTemp = ((CButton*)GetDlgItem(IDC_CHECK_GRADIENT_LOG))->GetCheck();
|
||||
if (iTemp > 0)
|
||||
{
|
||||
byLogTypes |= 8;
|
||||
}
|
||||
|
||||
if (byLogTypes <= 0)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择测井类型"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select the logging type"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strTrace;
|
||||
GetDlgItem(IDC_EDIT_TRACE)->GetWindowTextA(strTrace);
|
||||
if (strTrace.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("迭代次数不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Number of iterations cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
int iWaveform = m_comWaveform.GetCurSel();
|
||||
if (iWaveform < 0)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择发射波形"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select the launch waveform"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strSamplingInterval;
|
||||
GetDlgItem(IDC_EDIT_SAMPLING_INTERVAL)->GetWindowTextA(strSamplingInterval);
|
||||
if (strSamplingInterval.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("采样间隔不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Sampling interval must not be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strInitialDepth;
|
||||
GetDlgItem(IDC_EDIT_INITIAL_DEPTH)->GetWindowTextA(strInitialDepth);
|
||||
if (strInitialDepth.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("初始深度不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Initial depth cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strEndDepth;
|
||||
GetDlgItem(IDC_EDIT_END_DEPTH)->GetWindowTextA(strEndDepth);
|
||||
if (strEndDepth.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("结束深度不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("End depth cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
int iLogDir = m_comLoggingDirection.GetCurSel();
|
||||
if (iLogDir < 0)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择测井方向"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select the logging direction"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strLoggingInterval;
|
||||
GetDlgItem(IDC_EDIT_LOGGING_INTERVAL)->GetWindowTextA(strLoggingInterval);
|
||||
if (strLoggingInterval.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("测井间隔不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Log interval must not be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strInstrumentZeroLength;
|
||||
GetDlgItem(IDC_EDIT_INSTRUMENT_ZERO_LENGTH)->GetWindowTextA(strInstrumentZeroLength);
|
||||
if (strInstrumentZeroLength.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("仪器零长不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Instrument zero length cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strPeriod;
|
||||
GetDlgItem(IDC_EDIT_PERIOD)->GetWindowTextA(strPeriod);
|
||||
if (strPeriod.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("周期不能为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Period cannot be empty"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
//将数据希尔
|
||||
BOOL bRes = CLoggingDataOper::GetInstance()->UpdateTaskInfoIntoDB(strTaskName, strTestLocation, byLogTypes, strTrace, iWaveform, strSamplingInterval, strInitialDepth, strEndDepth, iLogDir, strLoggingInterval, strInstrumentZeroLength, strPeriod);
|
||||
if (bRes)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("修改任务信息成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Update task information successful"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("修改任务信息失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Update task information failed"), LOGGING_MESSAGEBOX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
m_stLoggingParam.byLogTypes = byLogTypes;
|
||||
m_stLoggingParam.byLogDirection = iLogDir;
|
||||
m_stLoggingParam.fSamplingInterval = atof(strSamplingInterval);
|
||||
m_stLoggingParam.fDepth = atof(strEndDepth) - atof(strInitialDepth);
|
||||
m_stLoggingParam.fLoggingDistance = atof(strLoggingInterval);
|
||||
m_stLoggingParam.fPeriod = atof(strPeriod);
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
|
||||
void CDialogLoggingParameterSetting::OnBnClickedCancel()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
STLoggingParamSettingReq CDialogLoggingParameterSetting::GetLogParamSetting()
|
||||
{
|
||||
return m_stLoggingParam;
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
//logging\CDialogLoggingSelectComPortWnd.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "logging\CDialogLoggingSelectComPortWnd.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
extern int g_iUILanguage;
|
||||
extern CDevLinkRecord* aDevLinkTable[256];
|
||||
extern BOOL g_bScanFun;
|
||||
extern CRITICAL_SECTION g_ScanTabSection;
|
||||
extern BYTE BBCCalculate(const char *pData, int iSize, BYTE ucOrgRes);
|
||||
// CDialogLoggingSelectComPortWnd 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CDialogLoggingSelectComPortWnd, CDialog)
|
||||
|
||||
CDialogLoggingSelectComPortWnd::CDialogLoggingSelectComPortWnd(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialogLoggingSelectComPortWnd::IDD, pParent)
|
||||
{
|
||||
m_iSeriNo = 1;
|
||||
}
|
||||
|
||||
CDialogLoggingSelectComPortWnd::~CDialogLoggingSelectComPortWnd()
|
||||
{
|
||||
}
|
||||
|
||||
void CDialogLoggingSelectComPortWnd::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_COMBO_AVAILABLE_SERIAL_PORT, m_comComNameList);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialogLoggingSelectComPortWnd, CDialog)
|
||||
ON_BN_CLICKED(IDOK, &CDialogLoggingSelectComPortWnd::OnBnClickedOk)
|
||||
ON_BN_CLICKED(IDCANCEL, &CDialogLoggingSelectComPortWnd::OnBnClickedCancel)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// CDialogLoggingSelectComPortWnd 消息处理程序
|
||||
BOOL CDialogLoggingSelectComPortWnd::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowTextA(_T("选中通讯端口"));
|
||||
GetDlgItem(IDC_STATIC_AVAILABLE_SERIAL_PORT)->SetWindowTextA(_T("可用串口"));
|
||||
GetDlgItem(IDOK)->SetWindowTextA(_T("确定"));
|
||||
GetDlgItem(IDCANCEL)->SetWindowTextA(_T("取消"));
|
||||
}
|
||||
|
||||
CStringArray strComNameArray;
|
||||
CSComPort::FindComName(&strComNameArray);
|
||||
|
||||
char szSend[2048] = { 0 };
|
||||
char szRecv[2048] = { 0 };
|
||||
BYTE ucBuf[4096] = { 0 };
|
||||
STCtrlProtoHeader* pSend = NULL;
|
||||
STCtrlProtoHeader* pRecv = NULL;
|
||||
WORD wTotalLen = 0;
|
||||
BOOL bRes = FALSE;
|
||||
int iPollingTime = 0;
|
||||
int iReceive = 0;
|
||||
for (int i = 0; i < strComNameArray.GetSize(); i++)
|
||||
{
|
||||
//通过Login指令过滤掉,不可以的串口
|
||||
EnterCriticalSection(&g_ScanTabSection);
|
||||
m_SComPort.SetScanBreakSign(FALSE);
|
||||
if (TRUE == m_SComPort.OpenComm(strComNameArray.GetAt(i)))
|
||||
{
|
||||
m_SComPort.ClearCommReceiveBuff();
|
||||
m_SComPort.ClearCommSendBuff();
|
||||
|
||||
/*CString szOrder = _T("");
|
||||
szOrder.Empty();
|
||||
szOrder.Format(_T("\r\n"));
|
||||
m_SComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
||||
Sleep(500);
|
||||
|
||||
szOrder.ReleaseBuffer();
|
||||
szOrder.Empty();*/
|
||||
|
||||
memset(szSend, 0, 2048);
|
||||
memset(szRecv, 0, 2048);
|
||||
memset(ucBuf, 0, 4096);
|
||||
|
||||
pSend = (STCtrlProtoHeader*)ucBuf;
|
||||
pSend->wIDCode = htonl(CTRL_GD10_CODE);
|
||||
pSend->ucSrcAddr = GEOMATIVE_ADDRESS;
|
||||
pSend->ucSrcType = 2;
|
||||
pSend->ucDstAddr = UNDER_MACHINE_ADDRESS;
|
||||
pSend->ucDstType = 5;
|
||||
pSend->ucCMD = EN_LOGGING_CHECK_PORT_LOGIN;
|
||||
pSend->ucDataType = 1;
|
||||
pSend->dwSeriNO = m_iSeriNo++;
|
||||
pSend->Status_code = 0;
|
||||
pSend->ucPacketNum = 1;
|
||||
memset(pSend->ucReverse, 0, sizeof(pSend->ucReverse));
|
||||
wTotalLen = sizeof(STCtrlProtoHeader) + 1;
|
||||
pSend->wTotalLen = wTotalLen;
|
||||
*((BYTE*)(ucBuf + wTotalLen - 1)) = BBCCalculate((const char*)(ucBuf), wTotalLen - 1, 0);
|
||||
|
||||
memcpy(szSend, ucBuf, wTotalLen);
|
||||
|
||||
bRes = m_SComPort.SendDataDirectly(szSend, wTotalLen);
|
||||
iPollingTime = 0;
|
||||
//发送数据后,接受数据
|
||||
Sleep(200);
|
||||
while (bRes && (iPollingTime < RECV_DATA_FAILED_ATTEMPTS_TIMES))
|
||||
{
|
||||
Sleep(3);
|
||||
if (m_SComPort.ReceiveDataDirectly(szRecv, &iReceive) == TRUE)
|
||||
{
|
||||
pRecv = (STCtrlProtoHeader*)szRecv;
|
||||
if (pRecv != NULL)
|
||||
{
|
||||
if (pRecv->ucCMD == EN_LOGGING_CHECK_PORT_LOGIN && pRecv->ucDataType == 2)
|
||||
{
|
||||
m_comComNameList.AddString(strComNameArray.GetAt(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
iPollingTime++;
|
||||
}
|
||||
|
||||
m_SComPort.ClearCommSendBuff();
|
||||
m_SComPort.ClearCommReceiveBuff();
|
||||
}
|
||||
m_SComPort.CloseComm();
|
||||
|
||||
LeaveCriticalSection(&g_ScanTabSection);
|
||||
|
||||
}
|
||||
m_comComNameList.SetCurSel(0);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void CDialogLoggingSelectComPortWnd::OnBnClickedOk()
|
||||
{
|
||||
int iIndex = m_comComNameList.GetCurSel();
|
||||
m_comComNameList.GetLBText(iIndex, m_strComName);
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CDialogLoggingSelectComPortWnd::OnBnClickedCancel()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
CString CDialogLoggingSelectComPortWnd::GetSelectComm()
|
||||
{
|
||||
return m_strComName;
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
// D:\zm\GeomativeV2.5\cpp\logging\CDialogLoggingSymbolEditor.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "logging\CLoggingDataOper.h"
|
||||
#include "logging\CDialogLoggingSymbolEditor.h"
|
||||
#include "logging\CDialogLoggingEditSymbolBoard.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
extern CGeoMativeApp theApp;
|
||||
// CDialogLoggingSymbolEditor 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CDialogLoggingSymbolEditor, CDialog)
|
||||
|
||||
CDialogLoggingSymbolEditor::CDialogLoggingSymbolEditor(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialogLoggingSymbolEditor::IDD, pParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CDialogLoggingSymbolEditor::~CDialogLoggingSymbolEditor()
|
||||
{
|
||||
}
|
||||
|
||||
void CDialogLoggingSymbolEditor::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_LIST_LITHOLOGY_NAME, m_listLithologyName);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialogLoggingSymbolEditor, CDialog)
|
||||
ON_BN_CLICKED(IDC_BTN_UPDATE, &CDialogLoggingSymbolEditor::OnBnClickedBtnUpdate)
|
||||
ON_BN_CLICKED(IDC_BTN_ADD, &CDialogLoggingSymbolEditor::OnBnClickedBtnAdd)
|
||||
ON_BN_CLICKED(IDC_BTN_DELETE, &CDialogLoggingSymbolEditor::OnBnClickedBtnDelete)
|
||||
ON_BN_CLICKED(IDCANCEL, &CDialogLoggingSymbolEditor::OnBnClickedCancel)
|
||||
ON_NOTIFY(NM_CLICK, IDC_LIST_LITHOLOGY_NAME, &CDialogLoggingSymbolEditor::OnNMClickListLithologyName)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CDialogLoggingSymbolEditor 消息处理程序
|
||||
BOOL CDialogLoggingSymbolEditor::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
RECT rcList;
|
||||
m_listLithologyName.GetClientRect(&rcList);
|
||||
DWORD dwStyle = m_listLithologyName.GetExtendedStyle();
|
||||
dwStyle |= LVS_EX_FULLROWSELECT;
|
||||
m_listLithologyName.SetExtendedStyle(dwStyle);
|
||||
m_listLithologyName.InsertColumn(0, _T(""), LVCFMT_LEFT, rcList.right - rcList.left);
|
||||
m_listLithologyName.InsertColumn(1, _T(""), LVCFMT_LEFT, 0);//用于保存图片路径
|
||||
m_listLithologyName.InsertColumn(2, _T(""), LVCFMT_LEFT, 0);//用于保存岩性类型
|
||||
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowText(_T("字符编辑器"));
|
||||
SetDlgItemText(IDC_STATIC_EDITOR, _T("编辑"));
|
||||
SetDlgItemText(IDC_STATIC_LITHOLOGY_NAME, _T("岩性名称"));
|
||||
SetDlgItemText(IDC_BTN_UPDATE, _T("更新"));
|
||||
SetDlgItemText(IDC_BTN_ADD, _T("添加"));
|
||||
SetDlgItemText(IDC_BTN_DELETE, _T("删除"));
|
||||
SetDlgItemText(IDCANCEL, _T("关闭"));
|
||||
}
|
||||
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_LITHOLOGY_NAME))->SetLimitText(20);
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
QueryLithologyNameFromDB();
|
||||
|
||||
RECT rcPic,rcDrawBoard;
|
||||
GetDlgItem(IDC_STATIC_PIC_SYMBOL_EDITROR)->GetClientRect(&rcPic);
|
||||
rcDrawBoard = rcPic;
|
||||
CDialogLoggingEditSymbolBoard::GetInstance()->Create(IDD_DIALOG_LOGGING_EDIT_SYMBOL_BOARD, GetDlgItem(IDC_STATIC_PIC_SYMBOL_EDITROR));
|
||||
rcDrawBoard.left = rcDrawBoard.left + (rcPic.right - rcPic.left - GRID_SIZE*GRID_X_DIRECTION_SIZE) / 2;
|
||||
rcDrawBoard.right = rcDrawBoard.left + GRID_SIZE*GRID_X_DIRECTION_SIZE+1;
|
||||
rcDrawBoard.top = rcDrawBoard.top + (rcPic.bottom - rcPic.top - GRID_SIZE*GRID_Y_DIRECTION_SIZE) / 2;
|
||||
rcDrawBoard.bottom = rcDrawBoard.top + GRID_SIZE*GRID_Y_DIRECTION_SIZE+1;
|
||||
CDialogLoggingEditSymbolBoard::GetInstance()->MoveWindow(&rcDrawBoard);
|
||||
CDialogLoggingEditSymbolBoard::GetInstance()->ShowWindow(SW_SHOW);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void CDialogLoggingSymbolEditor::OnBnClickedBtnUpdate()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
int iSelItem = m_listLithologyName.GetSelectionMark();
|
||||
if (iSelItem != -1)
|
||||
{
|
||||
CString strLithologyName,strLithologyPic,strLithologyType;
|
||||
GetDlgItemText(IDC_EDIT_LITHOLOGY_NAME, strLithologyName);
|
||||
if (strLithologyName.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("岩性名称为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Lithology name is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
//通知符号编辑窗口保存图片,是否需要删除图片
|
||||
strLithologyPic = m_listLithologyName.GetItemText(iSelItem, 1);
|
||||
strLithologyType = m_listLithologyName.GetItemText(iSelItem, 2);
|
||||
if (CLoggingDataOper::GetInstance()->DeleteDBLithologyBitmap(strLithologyType))
|
||||
{
|
||||
strLithologyPic = CDialogLoggingEditSymbolBoard::GetInstance()->SaveLithologyBitmap(strLithologyType, strLithologyName);
|
||||
m_listLithologyName.SetItemText(iSelItem, 0, strLithologyName);
|
||||
m_listLithologyName.SetItemText(iSelItem, 1, strLithologyPic);
|
||||
m_listLithologyName.SetItemText(iSelItem, 2, strLithologyType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDialogLoggingSymbolEditor::OnBnClickedBtnAdd()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CString strLithologyName, strLithologyType;
|
||||
GetDlgItemText(IDC_EDIT_LITHOLOGY_NAME, strLithologyName);
|
||||
if (strLithologyName.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("岩性名称为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Lithology name is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
int iItemCount = m_listLithologyName.GetItemCount();
|
||||
m_listLithologyName.InsertItem(iItemCount, _T(""));
|
||||
m_listLithologyName.SetItemText(iItemCount, 0, strLithologyName);
|
||||
|
||||
//通知符号编辑窗口保存图片
|
||||
CGUCodeCreator guCodeCreator;
|
||||
strLithologyType = guCodeCreator.GenerateGUIDCode();
|
||||
CString strLithologyPic = CDialogLoggingEditSymbolBoard::GetInstance()->SaveLithologyBitmap(strLithologyType, strLithologyName);
|
||||
m_listLithologyName.SetItemText(iItemCount, 1, strLithologyPic);
|
||||
m_listLithologyName.SetItemText(iItemCount, 2, strLithologyType);
|
||||
}
|
||||
|
||||
|
||||
void CDialogLoggingSymbolEditor::OnBnClickedBtnDelete()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
int nItem = -1;
|
||||
CString strLithologyType,strLithologyPicPath;
|
||||
while (m_listLithologyName.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED) != -1)
|
||||
{
|
||||
nItem = m_listLithologyName.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
|
||||
|
||||
//通知符号编辑窗口删除岩性图片
|
||||
strLithologyPicPath = m_listLithologyName.GetItemText(nItem, 1);
|
||||
strLithologyType = m_listLithologyName.GetItemText(nItem, 2);
|
||||
CDialogLoggingEditSymbolBoard::GetInstance()->DeleteLithologyBitmap(strLithologyType, strLithologyPicPath);
|
||||
|
||||
m_listLithologyName.DeleteItem(nItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDialogLoggingSymbolEditor::OnBnClickedCancel()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
/*try
|
||||
{
|
||||
CString strSql = _T("");
|
||||
//清除数据库
|
||||
_CommandPtr pCmdIns = NULL;
|
||||
pCmdIns.CreateInstance(_uuidof(Command));
|
||||
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
||||
// strSql.Format(_T("delete from TLithologyName where LanguageID=%d"), g_iUILanguage);
|
||||
// pCmdIns->CommandText = strSql.AllocSysString();
|
||||
// pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
|
||||
//插入数据
|
||||
//_RecordsetPtr pRecTd = NULL;
|
||||
//pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
CString strLithologyName,strLithologyPic,strLithologyType;
|
||||
int iItemCount = m_listLithologyName.GetItemCount();
|
||||
for (int iIndex = 0; iIndex < iItemCount; iIndex++)
|
||||
{
|
||||
strLithologyName = m_listLithologyName.GetItemText(iIndex, 0);
|
||||
strLithologyPic = m_listLithologyName.GetItemText(iIndex, 1);
|
||||
strLithologyType = m_listLithologyName.GetItemText(iIndex, 2);
|
||||
strSql.Format(_T("insert into TLithologyName(LithologyType,LithologyName,LithologyPic,LanguageID) values('%s','%s','%s',%d)"), strLithologyType, strLithologyName, strLithologyPic, g_iUILanguage);
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
}
|
||||
catch (CException* e)
|
||||
{
|
||||
AfxMessageBox(e->ReportError());
|
||||
}*/
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
void CDialogLoggingSymbolEditor::OnNMClickListLithologyName(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CString strLithologyName = m_listLithologyName.GetItemText(pNMItemActivate->iItem, 0);
|
||||
SetDlgItemText(IDC_EDIT_LITHOLOGY_NAME, strLithologyName);
|
||||
|
||||
CString strLithologyPic = m_listLithologyName.GetItemText(pNMItemActivate->iItem, 1);
|
||||
CDialogLoggingEditSymbolBoard::GetInstance()->LoadLithologyBitmap(strLithologyPic);
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CDialogLoggingSymbolEditor::QueryLithologyNameFromDB()
|
||||
{
|
||||
m_listLithologyName.DeleteAllItems();
|
||||
|
||||
map<CString, STLoggingLithologyInfo> mapLithologyInfo = CLoggingDataOper::GetInstance()->QueryLithologyInfo();
|
||||
int iItemCount = mapLithologyInfo.size();
|
||||
if (iItemCount > 0)
|
||||
{
|
||||
map<CString, STLoggingLithologyInfo>::iterator iter = mapLithologyInfo.begin();
|
||||
for (int i = 0; iter != mapLithologyInfo.end(), i < iItemCount; iter++,i++)
|
||||
{
|
||||
m_listLithologyName.InsertItem(i, _T(""));
|
||||
m_listLithologyName.SetItemText(i, 0, iter->second.szLithologyName);
|
||||
m_listLithologyName.SetItemText(i, 1, iter->second.szLithologyPic);
|
||||
m_listLithologyName.SetItemText(i, 2, iter->second.szLithologyType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,841 @@
|
||||
// D:\zm\GeomativeV2.5logging\cpp\logging\CDialogLoggingTestMainWnd.cpp : 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "logging\CDialogLoggingTestMainWnd.h"
|
||||
#include "logging\CDialogLoggingWnd.h"
|
||||
#include "logging\CDialogLoggingCreateTaskWnd.h"
|
||||
#include "logging\CDialogLoggingSelectComPortWnd.h"
|
||||
#include "logging\CDialogLoggingParameterSetting.h"
|
||||
//#include "afxdialogex.h"
|
||||
|
||||
extern CRITICAL_SECTION g_ScanTabSection;
|
||||
extern BYTE BBCCalculate(const char *pData, int iSize, BYTE ucOrgRes);
|
||||
// CDialogLoggingTestMainWnd 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CDialogLoggingTestMainWnd, CDialog)
|
||||
extern void SplitterString(CStringArray &szArray, const CString& szSource, const CString& szSplitter);
|
||||
CDialogLoggingTestMainWnd::CDialogLoggingTestMainWnd(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialogLoggingTestMainWnd::IDD, pParent)
|
||||
{
|
||||
m_iSeriNo = 1;
|
||||
m_bIsOpenFile = FALSE;
|
||||
m_isDownloadParamSetting = FALSE;
|
||||
m_isRecvData = FALSE;
|
||||
}
|
||||
|
||||
CDialogLoggingTestMainWnd::~CDialogLoggingTestMainWnd()
|
||||
{
|
||||
m_bIsOpenFile = FALSE;
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialogLoggingTestMainWnd, CDialog)
|
||||
ON_WM_PAINT()
|
||||
ON_COMMAND(IDM_MENU_FILE_OPEN, OnMenuFileOpen)
|
||||
ON_COMMAND(IDM_MENU_FILE_CLOSE, OnMenuFileClose)
|
||||
ON_COMMAND(IDM_MENU_FILE_SAVE, OnMenuFileSave)
|
||||
ON_COMMAND(IDM_MENU_FILE_SAVE_AS, OnMenuFileSaveAs)
|
||||
ON_COMMAND(IDM_MENU_EXIT, OnMenuExit)
|
||||
ON_COMMAND(IDM_MENU_COM_SETTING, OnMenuComSetting)
|
||||
ON_COMMAND(IDM_MENU_CREATE_TASK, OnMenuCreateTask)
|
||||
ON_COMMAND(IDM_MENU_MEASURE_PARAM_SETTING, OnMenuMeasureParamSetting)
|
||||
ON_COMMAND(IDM_MENU_START_LOGGING, OnMenuStartLogging)
|
||||
ON_COMMAND(IDM_MENU_PAUSE_LOGGING, OnMenuPauseLogging)
|
||||
ON_COMMAND(IDM_MENU_CONTINUE_LOGGING, OnMenuContinueLogging)
|
||||
ON_COMMAND(IDM_MENU_END_LOGGING, OnMenuEndLogging)
|
||||
ON_WM_VSCROLL()
|
||||
ON_WM_DESTROY()
|
||||
ON_WM_MOUSEWHEEL()
|
||||
ON_MESSAGE(WM_MSG_LOGGING_MEASURING_POINT_DATA, &CDialogLoggingTestMainWnd::OnMsgLoggingMeasuringPointData)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CDialogLoggingTestMainWnd 消息处理程序
|
||||
BOOL CDialogLoggingTestMainWnd::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
m_Menu.LoadMenuA(IDR_MENU_LOGGING_TEST);
|
||||
SetMenu(&m_Menu);
|
||||
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowText(_T("Logging测试"));
|
||||
}
|
||||
|
||||
RECT rcWnd;
|
||||
rcWnd.left = rcWnd.top = 0;
|
||||
rcWnd.right = GetSystemMetrics(SM_CXSCREEN);
|
||||
rcWnd.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||
MoveWindow(&rcWnd, TRUE);
|
||||
GetClientRect(&m_rcClientWnd);
|
||||
GetDlgItem(IDC_STATIC_DRAW_BORADING)->MoveWindow(&m_rcClientWnd);
|
||||
CDialogLoggingWnd::GetInstance()->Create(IDD_DIALOG_LOGGING_WND, GetDlgItem(IDC_STATIC_DRAW_BORADING));
|
||||
CDialogLoggingWnd::GetInstance()->MoveWindow(&m_rcClientWnd);
|
||||
CDialogLoggingWnd::GetInstance()->SetColumnNameVisible(FALSE);
|
||||
CDialogLoggingWnd::GetInstance()->ShowWindow(TRUE);
|
||||
|
||||
//不需要滚动条
|
||||
SetScrollRange(SB_VERT, 0, 0, TRUE);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
// 不为绘图消息调用 CDialogEx::OnPaint()
|
||||
CRect rcWnd;
|
||||
GetClientRect(&rcWnd);
|
||||
dc.FillSolidRect(rcWnd, RGB(255, 255, 255));
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuFileOpen()
|
||||
{
|
||||
// TODO: Add your command handler code here
|
||||
if (m_bIsOpenFile)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("已经存在打开的文件"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("An open file already exists"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
float fWellDepth = 0;
|
||||
CFileDialog cfd(TRUE, _T(".xml"), _T("*.xml"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("xml Files(*.xml)|*.txt||"), NULL);
|
||||
if (IDOK == cfd.DoModal())
|
||||
{
|
||||
m_bIsOpenFile = TRUE;
|
||||
CString strFileName = cfd.GetPathName();
|
||||
if (strFileName.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("无效文件名"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Invalid file name"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
//初始化画布大小
|
||||
CMarkup makeUp;
|
||||
bool bRes = makeUp.Load(strFileName);
|
||||
if (!bRes)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("解析xml文件失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Failed to parse the XML file"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
float fWellInitDepth, fWellEndDepth;
|
||||
makeUp.FindElem(_T("measure"));
|
||||
|
||||
makeUp.FindChildElem(_T("initial_depth"));
|
||||
fWellInitDepth = atof(makeUp.GetChildData());
|
||||
makeUp.FindChildElem(_T("WellEndDepth"));
|
||||
fWellEndDepth = atof(makeUp.GetChildData());
|
||||
|
||||
//修改绘制矩形框的高度
|
||||
float fWellDepth = fWellEndDepth - fWellInitDepth;
|
||||
if (fWellDepth > 0)
|
||||
{
|
||||
RECT rcDraw;
|
||||
rcDraw = m_rcClientWnd;
|
||||
rcDraw.bottom = CDialogLoggingWnd::GetInstance()->GetStartDrawDataHeight() + fWellDepth*DEPTH_SCALE_DISTANCE*EACH_SCALE_PIXEL_POINT_VALUE*ONE_DECIMETER_TO_HEIGHT;
|
||||
GetDlgItem(IDC_STATIC_DRAW_BORADING)->MoveWindow(&rcDraw);
|
||||
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
|
||||
si.nPos = 0;
|
||||
si.nMin = 0;
|
||||
float fSub = (CDialogLoggingWnd::GetInstance()->GetStartDrawDataHeight() + fWellDepth*DEPTH_SCALE_DISTANCE*ONE_DECIMETER_TO_HEIGHT) / (m_rcClientWnd.bottom - m_rcClientWnd.top);
|
||||
si.nMax = (m_rcClientWnd.bottom - m_rcClientWnd.top)*fSub+DRAW_BOARDING_TO_BOTTOM_DISTANCE;
|
||||
si.nPage = m_rcClientWnd.bottom - m_rcClientWnd.top;
|
||||
SetScrollInfo(SB_VERT, &si, TRUE);
|
||||
RedrawWindow();
|
||||
|
||||
CDialogLoggingWnd::GetInstance()->OpenFile(cfd.GetFolderPath(), cfd.GetFileTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuFileClose()
|
||||
{
|
||||
m_bIsOpenFile = FALSE;
|
||||
CDialogLoggingWnd::GetInstance()->CloseFile();
|
||||
//不需要滚动条
|
||||
SetScrollRange(SB_VERT, 0, 0, TRUE);
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuFileSave()
|
||||
{
|
||||
//CRecentFileList recentFileList;
|
||||
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuFileSaveAs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuExit()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuComSetting()
|
||||
{
|
||||
CDialogLoggingSelectComPortWnd dlgComPort;
|
||||
if (IDOK == dlgComPort.DoModal())
|
||||
{
|
||||
m_strComName = dlgComPort.GetSelectComm();
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuCreateTask()
|
||||
{
|
||||
CDialogLoggingCreateTaskWnd dlgCreateTaskWnd;
|
||||
dlgCreateTaskWnd.DoModal();
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuMeasureParamSetting()
|
||||
{
|
||||
if (m_strComName.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择通讯串口"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select the communication serial port"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CDialogLoggingParameterSetting dlgParamSetting;
|
||||
if (IDOK == dlgParamSetting.DoModal())
|
||||
{
|
||||
//下发参数到下位机
|
||||
STLoggingParamSettingReq stLoggingParamReq = dlgParamSetting.GetLogParamSetting();
|
||||
m_comPort.SetScanBreakSign(FALSE);
|
||||
if (TRUE == m_comPort.OpenComm(m_strComName))
|
||||
{
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
m_comPort.ClearCommSendBuff();
|
||||
|
||||
char szSend[2048] = { 0 };
|
||||
char szRecv[2048] = { 0 };
|
||||
BYTE ucBuf[4096] = { 0 };
|
||||
STCtrlProtoHeader* pSend = NULL;
|
||||
STCtrlProtoHeader* pRecv = NULL;
|
||||
WORD wTotalLen = 0;
|
||||
BOOL bRes = FALSE;
|
||||
int iPollingTime = 0;
|
||||
int iReceive = 0;
|
||||
memset(szSend, 0, 2048);
|
||||
memset(szRecv, 0, 2048);
|
||||
memset(ucBuf, 0, 4096);
|
||||
pSend = (STCtrlProtoHeader*)ucBuf;
|
||||
pSend->wIDCode = htonl(CTRL_GD10_CODE);
|
||||
pSend->ucSrcAddr = GEOMATIVE_ADDRESS;
|
||||
pSend->ucSrcType = 2;
|
||||
pSend->ucDstAddr = UNDER_MACHINE_ADDRESS;
|
||||
|
||||
pSend->ucDstType = 5;
|
||||
pSend->ucCMD = EN_LOGGING_DOWNLOAD_LOG_PARAM;
|
||||
pSend->ucDataType = 1;
|
||||
pSend->dwSeriNO = m_iSeriNo++;
|
||||
pSend->Status_code = 0;
|
||||
pSend->ucPacketNum = 1;
|
||||
memset(pSend->ucReverse, 0, sizeof(pSend->ucReverse));
|
||||
memcpy(ucBuf + sizeof(STCtrlProtoHeader), &stLoggingParamReq, sizeof(STLoggingParamSettingReq));
|
||||
wTotalLen = sizeof(STCtrlProtoHeader) + sizeof(STLoggingParamSettingReq) + 1;
|
||||
|
||||
pSend->wTotalLen = wTotalLen;
|
||||
*((BYTE*)(ucBuf + wTotalLen - 1)) = BBCCalculate((const char*)(ucBuf), wTotalLen - 1, 0);
|
||||
|
||||
memcpy(szSend, ucBuf, wTotalLen);
|
||||
|
||||
bRes = m_comPort.SendDataDirectly(szSend, wTotalLen);
|
||||
iPollingTime = 0;
|
||||
//发送数据后,接收数据
|
||||
Sleep(200);
|
||||
while (bRes && (iPollingTime < RECV_DATA_FAILED_ATTEMPTS_TIMES))
|
||||
{
|
||||
Sleep(3);
|
||||
if (m_comPort.ReceiveDataDirectly(szRecv, &iReceive) == TRUE)
|
||||
{
|
||||
pRecv = (STCtrlProtoHeader*)szRecv;
|
||||
if (pRecv != NULL)
|
||||
{
|
||||
if (pRecv->ucCMD == EN_LOGGING_DOWNLOAD_LOG_PARAM && pRecv->ucDataType == 2)
|
||||
{
|
||||
STLoggingParamSettingRes* pstParamRes = (STLoggingParamSettingRes*)(szRecv + sizeof(STCtrlProtoHeader));
|
||||
if (pstParamRes != NULL && pstParamRes->byStatusCode == 0)
|
||||
{
|
||||
m_isDownloadParamSetting = TRUE;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("下发参数成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Delivered parameters successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isDownloadParamSetting = FALSE;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("下发参数失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Delivered parameters failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
iPollingTime++;
|
||||
}
|
||||
m_comPort.ClearCommSendBuff();
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
}
|
||||
m_comPort.CloseComm();
|
||||
LeaveCriticalSection(&g_ScanTabSection);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CDialogLoggingTestMainWnd::OnMsgLoggingMeasuringPointData(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ST_LOGGING_DATA_PACKET_REQ* pMeasuringDataRes = (ST_LOGGING_DATA_PACKET_REQ*)wParam;
|
||||
if (pMeasuringDataRes == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT CDialogLoggingTestMainWnd::RecvDataThread(LPVOID lParam)
|
||||
{
|
||||
CDialogLoggingTestMainWnd* pThis = (CDialogLoggingTestMainWnd*)lParam;
|
||||
if (pThis == NULL)
|
||||
return 1;
|
||||
|
||||
char szSend[2048] = { 0 };
|
||||
char szRecv[2048] = { 0 };
|
||||
int iReceive = 0;
|
||||
STCtrlProtoHeader* pRecv = NULL;
|
||||
while (pThis->m_isRecvData)
|
||||
{
|
||||
Sleep(200);
|
||||
if (pThis->m_comPort.ReceiveDataDirectly(szRecv, &iReceive) == TRUE)
|
||||
{
|
||||
pRecv = (STCtrlProtoHeader*)szRecv;
|
||||
if (pRecv != NULL)
|
||||
{
|
||||
if (pRecv->ucCMD == EN_LOGGING_MEASURING_POINT_DATA && pRecv->ucDataType == 2)
|
||||
{
|
||||
ST_LOGGING_DATA_PACKET_REQ* pstParamRes = (ST_LOGGING_DATA_PACKET_REQ*)(szRecv + sizeof(STCtrlProtoHeader));
|
||||
if (pstParamRes != NULL)
|
||||
{
|
||||
::SendMessage(pThis->GetSafeHwnd(), WM_MSG_LOGGING_MEASURING_POINT_DATA, (WPARAM)&pstParamRes, NULL);
|
||||
//通知界面绘制
|
||||
|
||||
|
||||
//写入数据库
|
||||
/*if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("接受测试数据成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("recv data successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));*/
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("接受测试数据失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("recv data failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuStartLogging()
|
||||
{
|
||||
//如果没有下发配置
|
||||
if (!m_isDownloadParamSetting)
|
||||
{
|
||||
OnMenuMeasureParamSetting();
|
||||
}
|
||||
|
||||
STLoggingStartTestReq stLoggingStartTest;
|
||||
stLoggingStartTest.uiTestID = 1; //默认开始测试从第一个开始
|
||||
m_comPort.SetScanBreakSign(FALSE);
|
||||
if (TRUE == m_comPort.OpenComm(m_strComName))
|
||||
{
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
m_comPort.ClearCommSendBuff();
|
||||
|
||||
char szSend[2048] = { 0 };
|
||||
char szRecv[2048] = { 0 };
|
||||
BYTE ucBuf[4096] = { 0 };
|
||||
STCtrlProtoHeader* pSend = NULL;
|
||||
STCtrlProtoHeader* pRecv = NULL;
|
||||
WORD wTotalLen = 0;
|
||||
BOOL bRes = FALSE;
|
||||
int iPollingTime = 0;
|
||||
int iReceive = 0;
|
||||
memset(szSend, 0, 2048);
|
||||
memset(szRecv, 0, 2048);
|
||||
memset(ucBuf, 0, 4096);
|
||||
|
||||
pSend = (STCtrlProtoHeader*)ucBuf;
|
||||
pSend->wIDCode = htonl(CTRL_GD10_CODE);
|
||||
pSend->ucSrcAddr = GEOMATIVE_ADDRESS;
|
||||
pSend->ucSrcType = 2;
|
||||
pSend->ucDstAddr = UNDER_MACHINE_ADDRESS;
|
||||
|
||||
pSend->ucDstType = 5;
|
||||
pSend->ucCMD = EN_LOGGING_START_TEST;
|
||||
pSend->ucDataType = 1;
|
||||
pSend->dwSeriNO = m_iSeriNo++;
|
||||
pSend->Status_code = 0;
|
||||
pSend->ucPacketNum = 1;
|
||||
memset(pSend->ucReverse, 0, sizeof(pSend->ucReverse));
|
||||
memcpy(ucBuf + sizeof(STCtrlProtoHeader), &stLoggingStartTest, sizeof(STLoggingStartTestReq));
|
||||
wTotalLen = sizeof(STCtrlProtoHeader) + sizeof(STLoggingStartTestReq) + 1;
|
||||
|
||||
pSend->wTotalLen = wTotalLen;
|
||||
*((BYTE*)(ucBuf + wTotalLen - 1)) = BBCCalculate((const char*)(ucBuf), wTotalLen - 1, 0);
|
||||
|
||||
memcpy(szSend, ucBuf, wTotalLen);
|
||||
|
||||
bRes = m_comPort.SendDataDirectly(szSend, wTotalLen);
|
||||
iPollingTime = 0;
|
||||
//发送数据后,
|
||||
Sleep(200);
|
||||
while (bRes && (iPollingTime < RECV_DATA_FAILED_ATTEMPTS_TIMES))
|
||||
{
|
||||
Sleep(3);
|
||||
if (m_comPort.ReceiveDataDirectly(szRecv, &iReceive) == TRUE)
|
||||
{
|
||||
pRecv = (STCtrlProtoHeader*)szRecv;
|
||||
if (pRecv != NULL)
|
||||
{
|
||||
if (pRecv->ucCMD == EN_LOGGING_START_TEST && pRecv->ucDataType == 2)
|
||||
{
|
||||
STLoggingStartTestRes* pRes = (STLoggingStartTestRes*)(szRecv + sizeof(STCtrlProtoHeader));
|
||||
if (pRes != NULL && pRes->byStatusCode == 0)
|
||||
{
|
||||
m_isRecvData = TRUE;
|
||||
HANDLE hThread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RecvDataThread, this, 0, 0);
|
||||
if (INVALID_HANDLE_VALUE == hThread)
|
||||
{
|
||||
CFileOperTools::GetInstance()->WriteComLog(_T("Create Thread failed to simulate script run method"));
|
||||
}
|
||||
CloseHandle(hThread);
|
||||
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("开始测井成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Start logging successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("开始测井失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Log start failure"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
iPollingTime++;
|
||||
}
|
||||
|
||||
m_comPort.ClearCommSendBuff();
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&g_ScanTabSection);
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuPauseLogging()
|
||||
{
|
||||
//如果没有下发配置
|
||||
if (!m_isDownloadParamSetting)
|
||||
{
|
||||
OnMenuMeasureParamSetting();
|
||||
}
|
||||
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
m_comPort.ClearCommSendBuff();
|
||||
|
||||
char szSend[2048] = { 0 };
|
||||
char szRecv[2048] = { 0 };
|
||||
BYTE ucBuf[4096] = { 0 };
|
||||
STCtrlProtoHeader* pSend = NULL;
|
||||
STCtrlProtoHeader* pRecv = NULL;
|
||||
WORD wTotalLen = 0;
|
||||
BOOL bRes = FALSE;
|
||||
int iPollingTime = 0;
|
||||
int iReceive = 0;
|
||||
memset(szSend, 0, 2048);
|
||||
memset(szRecv, 0, 2048);
|
||||
memset(ucBuf, 0, 4096);
|
||||
|
||||
pSend = (STCtrlProtoHeader*)ucBuf;
|
||||
pSend->wIDCode = htonl(CTRL_GD10_CODE);
|
||||
pSend->ucSrcAddr = GEOMATIVE_ADDRESS;
|
||||
pSend->ucSrcType = 2;
|
||||
pSend->ucDstAddr = UNDER_MACHINE_ADDRESS;
|
||||
|
||||
pSend->ucDstType = 5;
|
||||
pSend->ucCMD = EN_LOGGING_PAUSE_TEST;
|
||||
pSend->ucDataType = 1;
|
||||
pSend->dwSeriNO = m_iSeriNo++;
|
||||
pSend->Status_code = 0;
|
||||
pSend->ucPacketNum = 1;
|
||||
memset(pSend->ucReverse, 0, sizeof(pSend->ucReverse));
|
||||
wTotalLen = sizeof(STCtrlProtoHeader) + 1;
|
||||
pSend->wTotalLen = wTotalLen;
|
||||
*((BYTE*)(ucBuf + wTotalLen - 1)) = BBCCalculate((const char*)(ucBuf), wTotalLen - 1, 0);
|
||||
|
||||
memcpy(szSend, ucBuf, wTotalLen);
|
||||
|
||||
bRes = m_comPort.SendDataDirectly(szSend, wTotalLen);
|
||||
iPollingTime = 0;
|
||||
//发送数据后,
|
||||
Sleep(200);
|
||||
while (bRes && (iPollingTime < RECV_DATA_FAILED_ATTEMPTS_TIMES))
|
||||
{
|
||||
Sleep(3);
|
||||
if (m_comPort.ReceiveDataDirectly(szRecv, &iReceive) == TRUE)
|
||||
{
|
||||
pRecv = (STCtrlProtoHeader*)szRecv;
|
||||
if (pRecv != NULL)
|
||||
{
|
||||
if (pRecv->ucCMD == EN_LOGGING_PAUSE_TEST && pRecv->ucDataType == 2)
|
||||
{
|
||||
STLoggingStartTestRes* pRes = (STLoggingStartTestRes*)(szRecv + sizeof(STCtrlProtoHeader));
|
||||
if (pRes != NULL && pRes->byStatusCode == 0)
|
||||
{
|
||||
//不接受数据
|
||||
m_isRecvData = FALSE;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("暂停测井成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Pause logging successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("暂停测井失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Log pause failure"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
iPollingTime++;
|
||||
}
|
||||
|
||||
m_comPort.ClearCommSendBuff();
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
|
||||
LeaveCriticalSection(&g_ScanTabSection);
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuContinueLogging()
|
||||
{
|
||||
//如果没有下发配置
|
||||
if (!m_isDownloadParamSetting)
|
||||
{
|
||||
OnMenuMeasureParamSetting();
|
||||
}
|
||||
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
m_comPort.ClearCommSendBuff();
|
||||
|
||||
char szSend[2048] = { 0 };
|
||||
char szRecv[2048] = { 0 };
|
||||
BYTE ucBuf[4096] = { 0 };
|
||||
STCtrlProtoHeader* pSend = NULL;
|
||||
STCtrlProtoHeader* pRecv = NULL;
|
||||
WORD wTotalLen = 0;
|
||||
BOOL bRes = FALSE;
|
||||
int iPollingTime = 0;
|
||||
int iReceive = 0;
|
||||
memset(szSend, 0, 2048);
|
||||
memset(szRecv, 0, 2048);
|
||||
memset(ucBuf, 0, 4096);
|
||||
|
||||
pSend = (STCtrlProtoHeader*)ucBuf;
|
||||
pSend->wIDCode = htonl(CTRL_GD10_CODE);
|
||||
pSend->ucSrcAddr = GEOMATIVE_ADDRESS;
|
||||
pSend->ucSrcType = 2;
|
||||
pSend->ucDstAddr = UNDER_MACHINE_ADDRESS;
|
||||
|
||||
pSend->ucDstType = 5;
|
||||
pSend->ucCMD = EN_LOGGING_CONTINUE_TEST;
|
||||
pSend->ucDataType = 1;
|
||||
pSend->dwSeriNO = m_iSeriNo++;
|
||||
pSend->Status_code = 0;
|
||||
pSend->ucPacketNum = 1;
|
||||
memset(pSend->ucReverse, 0, sizeof(pSend->ucReverse));
|
||||
wTotalLen = sizeof(STCtrlProtoHeader) + 1;
|
||||
|
||||
pSend->wTotalLen = wTotalLen;
|
||||
*((BYTE*)(ucBuf + wTotalLen - 1)) = BBCCalculate((const char*)(ucBuf), wTotalLen - 1, 0);
|
||||
|
||||
memcpy(szSend, ucBuf, wTotalLen);
|
||||
|
||||
bRes = m_comPort.SendDataDirectly(szSend, wTotalLen);
|
||||
iPollingTime = 0;
|
||||
//发送数据后,
|
||||
Sleep(200);
|
||||
while (bRes && (iPollingTime < RECV_DATA_FAILED_ATTEMPTS_TIMES))
|
||||
{
|
||||
Sleep(3);
|
||||
if (m_comPort.ReceiveDataDirectly(szRecv, &iReceive) == TRUE)
|
||||
{
|
||||
pRecv = (STCtrlProtoHeader*)szRecv;
|
||||
if (pRecv != NULL)
|
||||
{
|
||||
if (pRecv->ucCMD == EN_LOGGING_CONTINUE_TEST && pRecv->ucDataType == 2)
|
||||
{
|
||||
STLoggingStartTestRes* pRes = (STLoggingStartTestRes*)(szRecv + sizeof(STCtrlProtoHeader));
|
||||
if (pRes != NULL && pRes->byStatusCode == 0)
|
||||
{
|
||||
//接受数据
|
||||
m_isRecvData = TRUE;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("继续测井成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Continue logging successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("开始测井失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Log continue failure"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
iPollingTime++;
|
||||
}
|
||||
|
||||
m_comPort.ClearCommSendBuff();
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
|
||||
LeaveCriticalSection(&g_ScanTabSection);
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnMenuEndLogging()
|
||||
{
|
||||
//如果没有下发配置
|
||||
if (!m_isDownloadParamSetting)
|
||||
{
|
||||
OnMenuMeasureParamSetting();
|
||||
}
|
||||
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
m_comPort.ClearCommSendBuff();
|
||||
|
||||
char szSend[2048] = { 0 };
|
||||
char szRecv[2048] = { 0 };
|
||||
BYTE ucBuf[4096] = { 0 };
|
||||
STCtrlProtoHeader* pSend = NULL;
|
||||
STCtrlProtoHeader* pRecv = NULL;
|
||||
WORD wTotalLen = 0;
|
||||
BOOL bRes = FALSE;
|
||||
int iPollingTime = 0;
|
||||
int iReceive = 0;
|
||||
memset(szSend, 0, 2048);
|
||||
memset(szRecv, 0, 2048);
|
||||
memset(ucBuf, 0, 4096);
|
||||
|
||||
pSend = (STCtrlProtoHeader*)ucBuf;
|
||||
pSend->wIDCode = htonl(CTRL_GD10_CODE);
|
||||
pSend->ucSrcAddr = GEOMATIVE_ADDRESS;
|
||||
pSend->ucSrcType = 2;
|
||||
pSend->ucDstAddr = UNDER_MACHINE_ADDRESS;
|
||||
|
||||
pSend->ucDstType = 5;
|
||||
pSend->ucCMD = EN_LOGGING_END_TEST;
|
||||
pSend->ucDataType = 1;
|
||||
pSend->dwSeriNO = m_iSeriNo++;
|
||||
pSend->Status_code = 0;
|
||||
pSend->ucPacketNum = 1;
|
||||
memset(pSend->ucReverse, 0, sizeof(pSend->ucReverse));
|
||||
wTotalLen = sizeof(STCtrlProtoHeader) + 1;
|
||||
|
||||
pSend->wTotalLen = wTotalLen;
|
||||
*((BYTE*)(ucBuf + wTotalLen - 1)) = BBCCalculate((const char*)(ucBuf), wTotalLen - 1, 0);
|
||||
|
||||
memcpy(szSend, ucBuf, wTotalLen);
|
||||
|
||||
bRes = m_comPort.SendDataDirectly(szSend, wTotalLen);
|
||||
iPollingTime = 0;
|
||||
//发送数据后,
|
||||
Sleep(200);
|
||||
while (bRes && (iPollingTime < RECV_DATA_FAILED_ATTEMPTS_TIMES))
|
||||
{
|
||||
Sleep(3);
|
||||
if (m_comPort.ReceiveDataDirectly(szRecv, &iReceive) == TRUE)
|
||||
{
|
||||
pRecv = (STCtrlProtoHeader*)szRecv;
|
||||
if (pRecv != NULL)
|
||||
{
|
||||
if (pRecv->ucCMD == EN_LOGGING_END_TEST && pRecv->ucDataType == 2)
|
||||
{
|
||||
STLoggingStartTestRes* pRes = (STLoggingStartTestRes*)(szRecv + sizeof(STCtrlProtoHeader));
|
||||
if (pRes != NULL && pRes->byStatusCode == 0)
|
||||
{
|
||||
//不接受数据
|
||||
m_isRecvData = FALSE;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("结束测井成功"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("End logging successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("结束测井失败"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Log end failure"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
iPollingTime++;
|
||||
}
|
||||
m_comPort.ClearCommSendBuff();
|
||||
m_comPort.ClearCommReceiveBuff();
|
||||
|
||||
m_comPort.CloseComm();
|
||||
LeaveCriticalSection(&g_ScanTabSection);
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
SCROLLINFO si = {sizeof(si)};
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(SB_VERT, &si);
|
||||
|
||||
int nPrevPos = si.nPos;
|
||||
switch (nSBCode)
|
||||
{
|
||||
case SB_TOP:
|
||||
si.nPos = si.nMin;
|
||||
break;
|
||||
case SB_BOTTOM:
|
||||
si.nPos = si.nMax;
|
||||
break;
|
||||
case SB_LINEUP:
|
||||
si.nPos -= 15;
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
si.nPos += 15;
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
si.nPos -= si.nPage;
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
si.nPos += si.nPage;
|
||||
break;
|
||||
case SB_THUMBTRACK:
|
||||
si.nPos = si.nTrackPos;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
si.fMask = SIF_POS;
|
||||
SetScrollInfo(SB_VERT, &si, TRUE);
|
||||
if (si.nPos != nPrevPos)
|
||||
{
|
||||
ScrollWindow(0, nPrevPos - si.nPos, NULL, NULL);
|
||||
//Invalidate(FALSE);
|
||||
UpdateWindow();
|
||||
}
|
||||
|
||||
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
|
||||
}
|
||||
|
||||
void CDialogLoggingTestMainWnd::OnDestroy()
|
||||
{
|
||||
CDialog::OnDestroy();
|
||||
OnMenuFileClose();
|
||||
m_comPort.CloseComm();
|
||||
m_isRecvData = FALSE;
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
}
|
||||
|
||||
BOOL CDialogLoggingTestMainWnd::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
SCROLLINFO si = { sizeof(si) };
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(SB_VERT, &si);
|
||||
float fScrollBarHeigh = (si.nPage*(si.nPage - 32) / si.nMax);
|
||||
int nPrevPos = si.nPos;
|
||||
if (zDelta > 0)//向上滚动
|
||||
{
|
||||
if (nPrevPos <= si.nMin)
|
||||
{
|
||||
OnVScroll(SB_TOP, pt.y, this->GetScrollBarCtrl(SB_VERT));
|
||||
}
|
||||
else
|
||||
{
|
||||
si.nPos -= 15;
|
||||
int iSub = si.nPos / 15;
|
||||
int iMod = si.nPos % 15;
|
||||
if (iMod > 0)
|
||||
{
|
||||
si.nPos = (iSub + 1) * 15;
|
||||
}
|
||||
if (si.nPos < 0)
|
||||
{
|
||||
nPrevPos = 15;
|
||||
si.nPos = 0;
|
||||
}
|
||||
OnVScroll(SB_LINEUP, si.nPos, this->GetScrollBarCtrl(SB_VERT));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else//向下滚动
|
||||
{
|
||||
if (nPrevPos >= (si.nMax -(m_rcClientWnd.bottom - m_rcClientWnd.top)))
|
||||
return FALSE;
|
||||
si.nPos += 15;
|
||||
}
|
||||
si.fMask = SIF_POS;
|
||||
SetScrollInfo(SB_VERT, &si, TRUE);
|
||||
if (si.nPos != nPrevPos && (si.nPos >= si.nMin) && (si.nPos <= si.nMax))
|
||||
{
|
||||
ScrollWindow(0, nPrevPos - si.nPos, NULL, NULL);
|
||||
UpdateWindow();
|
||||
}
|
||||
|
||||
return CDialog::OnMouseWheel(nFlags, zDelta, pt);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,616 @@
|
||||
// TaskDataOper.cpp: implementation of the CLoggingDataOper class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "StdAfx.h"
|
||||
#include "GeoMative.h"
|
||||
#include "logging\CLoggingDataOper.h"
|
||||
#include "GUCodeCreator.h"
|
||||
|
||||
extern CGeoMativeApp theApp;
|
||||
extern int g_iUILanguage;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CLoggingDataOper::CLoggingDataOper()
|
||||
{
|
||||
}
|
||||
|
||||
CLoggingDataOper::~CLoggingDataOper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CLoggingDataOper* CLoggingDataOper::GetInstance()
|
||||
{
|
||||
static CLoggingDataOper oper;
|
||||
return &oper;
|
||||
}
|
||||
|
||||
map<CString, STLoggingLithologyInfo> CLoggingDataOper::QueryLithologyInfo()
|
||||
{
|
||||
m_mapLithologyInfo.clear();
|
||||
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
int iLithologyType = -1;
|
||||
CString strText;
|
||||
CString strSql = _T("");
|
||||
STLoggingLithologyInfo stLithologyInfo;
|
||||
strSql.Format(_T("select ID,LithologyType,LithologyName,LithologyPicPath from TPictureInfo where LanguageID=%d"), g_iUILanguage);
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while (0 == pRecTd->adoEOF)
|
||||
{
|
||||
memset(&stLithologyInfo, 0, sizeof(stLithologyInfo));
|
||||
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("LithologyName")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("LithologyName"));
|
||||
strcpy(stLithologyInfo.szLithologyName, strText);
|
||||
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("LithologyType")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("LithologyType"));
|
||||
//stLithologyInfo.iLithologyType = pRecTd->GetCollect(_T("LithologyType")).intVal;
|
||||
strcpy(stLithologyInfo.szLithologyType, strText);
|
||||
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("LithologyPicPath")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("LithologyPicPath"));
|
||||
strcpy(stLithologyInfo.szLithologyPic, strText);
|
||||
m_mapLithologyInfo[stLithologyInfo.szLithologyType] = stLithologyInfo;
|
||||
|
||||
pRecTd->MoveNext();
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
return m_mapLithologyInfo;
|
||||
}
|
||||
|
||||
//根据岩性名称查找数据库相关信息
|
||||
STLoggingLithologyInfo CLoggingDataOper::QueryLithologyInfoByName(CString strLithologyName)
|
||||
{
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
int iLithologyType = -1;
|
||||
CString strText;
|
||||
CString strSql = _T("");
|
||||
STLoggingLithologyInfo stLithologyInfo;
|
||||
strSql.Format(_T("select ID,LithologyType,LithologyName,LithologyPicPath from TPictureInfo where LanguageID=%d and LithologyName='%s'"), g_iUILanguage, strLithologyName);
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if (pRecTd->GetRecordCount() > 0)
|
||||
{
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("LithologyName")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("LithologyName"));
|
||||
strcpy(stLithologyInfo.szLithologyName, strText);
|
||||
|
||||
//stLithologyInfo.iLithologyType = pRecTd->GetCollect(_T("LithologyType")).intVal;
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("LithologyType")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("LithologyType"));
|
||||
//stLithologyInfo.iLithologyType = pRecTd->GetCollect(_T("LithologyType")).intVal;
|
||||
strcpy(stLithologyInfo.szLithologyType, strText);
|
||||
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("LithologyPicPath")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("LithologyPicPath"));
|
||||
strcpy(stLithologyInfo.szLithologyPic, strText);
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
return stLithologyInfo;
|
||||
}
|
||||
|
||||
//数据库删除岩性图片
|
||||
BOOL CLoggingDataOper::DeleteDBLithologyBitmap(CString strLithologyType)
|
||||
{
|
||||
if (strLithologyType.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("图片类型为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Image type is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//是否存在
|
||||
CString strSql;
|
||||
UINT uiPicID = 0;
|
||||
strSql.Format(_T("select ID from TPictureInfo where LithologyType ='%s'"), strLithologyType);
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if (pRecTd->GetRecordCount() > 0)
|
||||
{
|
||||
uiPicID = (DWORD)pRecTd->GetCollect(_T("ID")).ulVal;
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
if (uiPicID <= 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_CommandPtr pCmdDel;
|
||||
pCmdDel.CreateInstance(_uuidof(Command));
|
||||
pCmdDel->ActiveConnection = theApp.m_pConnection;
|
||||
try
|
||||
{
|
||||
strSql.Format(_T("delete from TPictureInfo where ID = %u"), uiPicID);
|
||||
pCmdDel->CommandText = strSql.AllocSysString();
|
||||
pCmdDel->Execute(NULL, NULL, adCmdText);
|
||||
|
||||
strSql.Format(_T("delete from TPictureCode where PicID = %u"), uiPicID);
|
||||
pCmdDel->CommandText = strSql.AllocSysString();
|
||||
pCmdDel->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//数据库新增岩性图片
|
||||
BOOL CLoggingDataOper::InsertDBLithologyBitmap(CString strLithologyType, CString strLithologyName, CString strLithologyPicPath, map<int, map<int, bool>> mapPictureCode)
|
||||
{
|
||||
if (strLithologyType.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("图片类型为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Image type is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (strLithologyName.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("图片名为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Image name is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (strLithologyPicPath.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("图片路径为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Image path is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mapPictureCode.size() < 1)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("图片二维码为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Qr code in the picture is empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_CommandPtr pCmdIns = NULL;
|
||||
pCmdIns.CreateInstance(_uuidof(Command));
|
||||
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
||||
CString strSql = _T("");
|
||||
//插入图片信息
|
||||
try
|
||||
{
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("insert into TPictureInfo(LithologyType,TotalRow,TotalColumn,LithologyName,LithologyPicPath,LanguageID) values('%s',%d,%d,'%s','%s',%d)"), \
|
||||
strLithologyType, GRID_X_DIRECTION_SIZE, GRID_Y_DIRECTION_SIZE, strLithologyName,strLithologyPicPath, g_iUILanguage);
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
}
|
||||
|
||||
//是否存在
|
||||
UINT uiPicID = 0;
|
||||
strSql.Format(_T("select ID from TPictureInfo where LithologyType ='%s'"), strLithologyType);
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if (pRecTd->GetRecordCount() > 0)
|
||||
{
|
||||
uiPicID = (DWORD)pRecTd->GetCollect(_T("ID")).ulVal;
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
if (uiPicID == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//循环插入图片二维码ID
|
||||
try
|
||||
{
|
||||
map<int, map<int, bool>>::iterator iter = mapPictureCode.begin();
|
||||
map<int, bool>::iterator iterX;
|
||||
CString strColumnContent;
|
||||
for (; iter != mapPictureCode.end(); iter++)
|
||||
{
|
||||
strColumnContent.Empty();
|
||||
for (iterX = iter->second.begin(); iterX != iter->second.end(); iterX++)
|
||||
{
|
||||
if (iterX != iter->second.begin())
|
||||
{
|
||||
strColumnContent += _T(",");
|
||||
}
|
||||
if (iterX->second)
|
||||
{
|
||||
strColumnContent.AppendFormat(_T("%d"), iterX->first);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strColumnContent.IsEmpty())
|
||||
{
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("insert into TPictureCode(PicID,ColumnIndex,ColumnContent) values(%d,%d,'%s')"), uiPicID, iter->first, strColumnContent);
|
||||
OutputDebugString(strSql + _T("\n"));
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//加载数据库图片信息
|
||||
map<int, map<int, bool>> CLoggingDataOper::LoadLithologyBitmapFromDB(CString strLithologyName)
|
||||
{
|
||||
map<int, map<int, bool>> mapPictureCode;
|
||||
if (strLithologyName.IsEmpty())
|
||||
{
|
||||
AfxMessageBox(_T("无效文件名"));
|
||||
return mapPictureCode;
|
||||
}
|
||||
|
||||
int iPos = strLithologyName.ReverseFind('/');
|
||||
if (iPos != -1)
|
||||
{
|
||||
strLithologyName = strLithologyName.Mid(iPos + 1);
|
||||
}
|
||||
|
||||
iPos = strLithologyName.Find('.');
|
||||
strLithologyName = strLithologyName.Mid(0, iPos);
|
||||
|
||||
//是否存在
|
||||
UINT uiPicID = 0;
|
||||
CString strSql;
|
||||
strSql.Format(_T("select ID from TPictureInfo where LithologyType ='%s'"), strLithologyName);
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if (pRecTd->GetRecordCount() > 0)
|
||||
{
|
||||
uiPicID = (DWORD)pRecTd->GetCollect(_T("ID")).ulVal;
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
if (uiPicID == 0)
|
||||
{
|
||||
AfxMessageBox(_T("没有找到图片信息"));
|
||||
return mapPictureCode;
|
||||
}
|
||||
|
||||
int iColumnIndex = -1;
|
||||
int iIndexY = -1;
|
||||
CString strColumnContent;
|
||||
map<int, bool> mapColContent;
|
||||
iPos = -1;
|
||||
strSql.Format(_T("select ColumnIndex,ColumnContent from TPictureCode where PicID =%d"), uiPicID);
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while (0 == pRecTd->adoEOF)
|
||||
{
|
||||
iColumnIndex = -1;
|
||||
mapColContent.clear();
|
||||
iColumnIndex = (DWORD)pRecTd->GetCollect(_T("ColumnIndex")).intVal;
|
||||
|
||||
strColumnContent.Empty();
|
||||
strColumnContent = (VT_NULL == pRecTd->GetCollect(_T("ColumnContent")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("ColumnContent"));
|
||||
if (!strColumnContent.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
iPos = strColumnContent.Find(',');
|
||||
if (iPos != -1)
|
||||
{
|
||||
iIndexY = atoi(strColumnContent.Mid(0, iPos));
|
||||
strColumnContent = strColumnContent.Mid(iPos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
iIndexY = atoi(strColumnContent);
|
||||
}
|
||||
|
||||
if (iIndexY >= 0)
|
||||
{
|
||||
mapColContent[iIndexY] = 1;
|
||||
}
|
||||
} while (iPos != -1);
|
||||
|
||||
mapPictureCode[iColumnIndex] = mapColContent;
|
||||
}
|
||||
pRecTd->MoveNext();
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
return mapPictureCode;
|
||||
}
|
||||
|
||||
BOOL CLoggingDataOper::SaveTaskInfoIntoDB(CString strTaskName, CString strTestLocation, BYTE byLogTypes, CString strTrace, int iWaveform, CString strSamplingInterval, CString strInitialDepth, CString strEndDepth, int iLogDir, CString strLoggingInterval, CString strInstrumentZeroLength, CString strPeriod)
|
||||
{
|
||||
_CommandPtr pCmdIns = NULL;
|
||||
pCmdIns.CreateInstance(_uuidof(Command));
|
||||
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
||||
CString strSql = _T("");
|
||||
CGUCodeCreator creator;
|
||||
CString strTaskID = creator.GenerateGUIDCode();
|
||||
float fEndDepth = atof(strEndDepth);
|
||||
float fInitDepth = atof(strInitialDepth);
|
||||
float fLoggingDistance = atof(strLoggingInterval);
|
||||
//插入logging任务信息
|
||||
try
|
||||
{
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("insert into TLoggingTaskInfo(TaskID,TaskName,Location,LogType,Trace,Waveform,SamplingInterval,\
|
||||
InitDepth,EndDepth,LogDirection,LoggingInterval,InstrumentZeroLength,Period) \
|
||||
values('%s','%s','%s',%d,%d,%d,%f,\
|
||||
%f,%f,%d,%f,%f,%f)"), \
|
||||
strTaskID, strTaskName, strTestLocation, byLogTypes, atoi(strTrace), iWaveform, atof(strSamplingInterval),\
|
||||
fInitDepth, fEndDepth, iLogDir, fLoggingDistance, atof(strInstrumentZeroLength), atof(strPeriod));
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT uiTaskID = 0;
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("select ID from TLoggingTaskInfo where TaskID ='%s'"), strTaskID);
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if (pRecTd->GetRecordCount() > 0)
|
||||
{
|
||||
uiTaskID = (DWORD)pRecTd->GetCollect(_T("ID")).ulVal;
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
if (uiTaskID == 0)
|
||||
{
|
||||
AfxMessageBox(_T("没有找到任务"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//插入数据测点信息
|
||||
try
|
||||
{
|
||||
strSql.Empty();
|
||||
float fTestCount = ((fEndDepth - fInitDepth) / fLoggingDistance);
|
||||
int iTestCount = (int)((fEndDepth - fInitDepth) / fLoggingDistance);
|
||||
if (fTestCount - iTestCount > 0.000001)
|
||||
{
|
||||
iTestCount++;
|
||||
}
|
||||
strSql.Format(_T("fTestCount=%f, iTestCount=%d\n"), fTestCount, iTestCount);
|
||||
OutputDebugString(strSql);
|
||||
for (int i = 0; i < iTestCount; i++)
|
||||
{
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("insert into TLoggingTaskContent(TaskID,TestID) values(%d,%d)"), uiTaskID, i+1);
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CLoggingDataOper::UpdateTaskInfoIntoDB(CString strTaskName, CString strTestLocation, BYTE byLogTypes, CString strTrace, int iWaveform, CString strSamplingInterval, CString strInitialDepth, CString strEndDepth, int iLogDir, CString strLoggingInterval, CString strInstrumentZeroLength, CString strPeriod)
|
||||
{
|
||||
UINT uiTaskID = 0;
|
||||
CString strSql;
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("select ID from TLoggingTaskInfo where TaskName ='%s'"), strTaskName);
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if (pRecTd->GetRecordCount() > 0)
|
||||
{
|
||||
uiTaskID = (DWORD)pRecTd->GetCollect(_T("ID")).ulVal;
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
if (uiTaskID == 0)
|
||||
{
|
||||
AfxMessageBox(_T("没有找到任务"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_CommandPtr pCmdIns = NULL;
|
||||
pCmdIns.CreateInstance(_uuidof(Command));
|
||||
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
||||
float fEndDepth = atof(strEndDepth);
|
||||
float fInitDepth = atof(strInitialDepth);
|
||||
float fLoggingDistance = atof(strLoggingInterval);
|
||||
//插入logging任务信息
|
||||
try
|
||||
{
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("update TLoggingTaskInfo set TaskName='%s',Location='%s',LogType=%d,Trace=%d,Waveform=%d,SamplingInterval=%f,InitDepth=%f,EndDepth=%f,LogDirection=%d,LoggingInterval=%f,InstrumentZeroLength=%f,Period=%f where ID = %d"),\
|
||||
strTaskName, strTestLocation, byLogTypes, atoi(strTrace), iWaveform, atof(strSamplingInterval), fInitDepth, fEndDepth, iLogDir, fLoggingDistance, atof(strInstrumentZeroLength), atof(strPeriod), uiTaskID);
|
||||
pCmdIns->CommandText = strSql.AllocSysString();
|
||||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
map<CString, STLoggingTaskInfo> CLoggingDataOper::QueryTaskListFromDB()
|
||||
{
|
||||
map<CString, STLoggingTaskInfo> mapLoggingTaskInfo;
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
int iLithologyType = -1;
|
||||
CString strText;
|
||||
CString strSql = _T("");
|
||||
STLoggingTaskInfo stLoggingTaskInfo;
|
||||
strSql.Format(_T("select TaskID,TaskName,Location,LogType,Trace,Waveform,SamplingInterval,InitDepth,\
|
||||
EndDepth,LogDirection,LoggingInterval,InstrumentZeroLength,Period from TLoggingTaskInfo"));
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while (0 == pRecTd->adoEOF)
|
||||
{
|
||||
memset(&stLoggingTaskInfo, 0, sizeof(stLoggingTaskInfo));
|
||||
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("TaskName")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TaskName"));
|
||||
strcpy(stLoggingTaskInfo.szTaskName, strText);
|
||||
|
||||
stLoggingTaskInfo.byLogType = pRecTd->GetCollect(_T("LogType")).cVal;
|
||||
stLoggingTaskInfo.fSamplingInterval = pRecTd->GetCollect(_T("SamplingInterval")).fltVal;
|
||||
stLoggingTaskInfo.fInitDepth = pRecTd->GetCollect(_T("InitDepth")).fltVal;
|
||||
stLoggingTaskInfo.fEndDepth = pRecTd->GetCollect(_T("EndDepth")).fltVal;
|
||||
stLoggingTaskInfo.byLogDirection = pRecTd->GetCollect(_T("LogDirection")).cVal;
|
||||
stLoggingTaskInfo.fLoggingDistance = pRecTd->GetCollect(_T("LoggingInterval")).fltVal;
|
||||
stLoggingTaskInfo.fPeriod = pRecTd->GetCollect(_T("Period")).fltVal;
|
||||
mapLoggingTaskInfo[stLoggingTaskInfo.szTaskName] = stLoggingTaskInfo;
|
||||
|
||||
pRecTd->MoveNext();
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
return mapLoggingTaskInfo;
|
||||
}
|
||||
|
||||
STLoggingTaskInfo CLoggingDataOper::QueryTaskInfoByName(CString strTaskName)
|
||||
{
|
||||
_RecordsetPtr pRecTd = NULL;
|
||||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||||
int iLithologyType = -1;
|
||||
CString strText;
|
||||
CString strSql = _T("");
|
||||
STLoggingTaskInfo stLoggingTaskInfo;
|
||||
strSql.Format(_T("select TaskID,TaskName,Location,LogType,Trace,Waveform,SamplingInterval,InitDepth,\
|
||||
EndDepth,LogDirection,LoggingInterval,InstrumentZeroLength,Period from TLoggingTaskInfo where TaskName='%s'"), strTaskName);
|
||||
try
|
||||
{
|
||||
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if (pRecTd->GetRecordCount() > 0)
|
||||
{
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("TaskName")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TaskName"));
|
||||
strcpy(stLoggingTaskInfo.szTaskName, strText);
|
||||
|
||||
strText.Empty();
|
||||
strText = (VT_NULL == pRecTd->GetCollect(_T("Location")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Location"));
|
||||
strcpy(stLoggingTaskInfo.szLocation, strText);
|
||||
|
||||
stLoggingTaskInfo.byLogType = pRecTd->GetCollect(_T("LogType")).cVal;
|
||||
stLoggingTaskInfo.byTrace = pRecTd->GetCollect(_T("Trace")).cVal;
|
||||
stLoggingTaskInfo.byWaveform = pRecTd->GetCollect(_T("Waveform")).cVal;
|
||||
stLoggingTaskInfo.fSamplingInterval = pRecTd->GetCollect(_T("SamplingInterval")).fltVal;
|
||||
stLoggingTaskInfo.fInitDepth = pRecTd->GetCollect(_T("InitDepth")).fltVal;
|
||||
stLoggingTaskInfo.fEndDepth = pRecTd->GetCollect(_T("EndDepth")).fltVal;
|
||||
stLoggingTaskInfo.byLogDirection = pRecTd->GetCollect(_T("LogDirection")).cVal;
|
||||
stLoggingTaskInfo.fLoggingDistance = pRecTd->GetCollect(_T("LoggingInterval")).fltVal;
|
||||
stLoggingTaskInfo.fInstrumentZeroLength = pRecTd->GetCollect(_T("InstrumentZeroLength")).fltVal;
|
||||
stLoggingTaskInfo.fPeriod = pRecTd->GetCollect(_T("Period")).fltVal;
|
||||
}
|
||||
pRecTd->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
AfxMessageBox(e.Description());
|
||||
pRecTd->Close();
|
||||
}
|
||||
|
||||
return stLoggingTaskInfo;
|
||||
}
|
||||
Reference in New Issue
Block a user