📄 c_proc.cpp
字号:
long tim;
struct tm *n_time;
time_t time_cnt;
time(&time_cnt); // 尰嵼偺帪娫庢摼(Sec)
n_time = localtime(&time_cnt); // 尰抧帪崗偵曄姺
SeqDat.ReqPhs = 0; // 梫媮 & phase
SeqDat.SrcPoi = 0; // 僨乕僞撉傒崬傒億僀儞僩
for (poi=0;poi<50;poi++){ //
sprintf(SeqDat.SrcDat[poi].DatKind, "10"); // 僨乕僞幆暿巕 10: 嫮恔僨乕僞
sprintf(SeqDat.SrcDat[poi].Host_ID, "$KOKUSAI"); // 俫俷俽俿丂俬俢
sprintf(SeqDat.SrcDat[poi].Y_M_Day, "%02d%02d%04d",
n_time->tm_mday, (n_time->tm_mon+1), (n_time->tm_year+1900)
);
sprintf(SeqDat.SrcDat[poi].H_M_Sec, "%02d%02d%02d00",
n_time->tm_hour, n_time->tm_min, n_time->tm_sec
);
sprintf(SeqDat.SrcDat[poi].Stt_dat, "00000000"); // 忬懺僗僥乕僞僗
sprintf(SeqDat.SrcDat[poi].Cor_Day, SeqDat.SrcDat[poi].Y_M_Day); // 嵟廔峔惉擔帪
sprintf(SeqDat.SrcDat[poi].CorTime, "0000"); // 嵟廔峔惉帪崗
sprintf(SeqDat.SrcDat[poi].TestDay, SeqDat.SrcDat[poi].Y_M_Day); // 嵟廔帺屓恌抐擔
sprintf(SeqDat.SrcDat[poi].TestHur, "000000"); // 嵟廔帺屓恌抐帪崗
sprintf(SeqDat.SrcDat[poi].Dat_Len, "00000000"); // 楢懕僨乕僞挿
sprintf(SeqDat.SrcDat[poi].Mem_Cap, "2000"); // 儊儌儕乕巆検(KB)
sprintf(SeqDat.SrcDat[poi].G_FName, "WF_DMY01.W01"); // 攇宍僼傽僀儖柤
// 2001-11-27(MK@CQ)
#if ATSUGI
sprintf(SeqDat.SrcDat[poi].SysRsv1, "");
sprintf(SeqDat.SrcDat[poi].SysRsv2, "");
sprintf(SeqDat.SrcDat[poi].SysRsv3, "");
sprintf(SeqDat.SrcDat[poi].SysRsv4, "");
sprintf(SeqDat.SrcDat[poi].SysRsv5, "");
sprintf(SeqDat.SrcDat[poi].SysRsv6, "");
#endif
SeqDat.IntTim[poi] = -1;
}
sp = poi = 0;
while (SrcDatTbl[sp][0] != '@'){
sscanf(SrcDatTbl[sp ++], "%ld", &tim);
SeqDat.IntTim[poi] = (long)(tim * CLOCKS_PER_SEC);
sprintf(SeqDat.SrcDat[poi].Term_ID, SrcDatTbl[sp ++]); // 抂枛俬俢
sprintf(SeqDat.SrcDat[poi].Kei_Sin, SrcDatTbl[sp ++]); // 寁應恔搙
sprintf(SeqDat.SrcDat[poi].ShindoK, SrcDatTbl[sp ++]); // 恔搙奒
sprintf(SeqDat.SrcDat[poi].Max_Acc, SrcDatTbl[sp ++]); // 嵟戝崌惉壛懍搙
sprintf(SeqDat.SrcDat[poi].Acc_Xxx, SrcDatTbl[sp ++]); // 倃幉嵟戝壛懍搙
sprintf(SeqDat.SrcDat[poi].Acc_Yyy, SrcDatTbl[sp ++]); // 倄幉嵟戝壛懍搙
sprintf(SeqDat.SrcDat[poi].Acc_Zzz, SrcDatTbl[sp ++]); // 倅幉嵟戝壛懍搙
// 2001-11-27(MK@CQ)
#if ATSUGI
sprintf(SeqDat.SrcDat[poi].Freq_Tx, SrcDatTbl[sp ++]); // X幉戩墇廃婜
sprintf(SeqDat.SrcDat[poi].Freq_Ty, SrcDatTbl[sp ++]); // Y幉戩墇廃婜
sprintf(SeqDat.SrcDat[poi].Freq_Tz, SrcDatTbl[sp ++]); // Z幉戩墇廃婜
sprintf(SeqDat.SrcDat[poi].FreqAcX, SrcDatTbl[sp ++]); // X嵟戝壛懍搙廃婜
sprintf(SeqDat.SrcDat[poi].FreqAcY, SrcDatTbl[sp ++]); // Y嵟戝壛懍搙廃婜
sprintf(SeqDat.SrcDat[poi].FreqAcZ, SrcDatTbl[sp ++]); // Z嵟戝壛懍搙廃婜
sprintf(SeqDat.SrcDat[poi].MxMinut, SrcDatTbl[sp ++]); // 嵟戝壛懍搙娤應暘
#endif
poi ++;
}
SeqDat.DatCnt = poi; // 僨乕僞悢
}
#endif
/*=====================================
m:23-Dec-1998
@p << 僔僗僥儉曄悢弶婜壔 >>
=====================================*/
void SysWrkInit()
{
int a, ch;
for (ch=0;ch<MAX_CH;ch++){
Rcw[ch].WrtPoi = Rcw[ch].RedPoi = 0;
Rcw[ch].RcvCnt = Rcw[ch].RcvLen = 0;
Rcw[ch].TryCnt = Rcw[ch].PckCnt = 0;
// 23-Jan:HY
Rcw[ch].TimEnb = 0;
if (TcpUse == 1 && ch == 0){ // TCP/IP 巊梡 (0:none / 1:use)
Rcw[ch].ComPhs = -4000; // TCP init
}
else{
Rcw[ch].ComPhs = -500; // 儌僨儉僱僑僔僄乕僔儑儞
}
Rcw[ch].Enable = 1;
RcvSttDat[ch].Stt_Sys = 0;
// 23-Jan:HY
Scw[ch].WrtPoi = Scw[ch].RedPoi = 0;
Scw[ch].ReqCmd = Scw[ch].TryCnt = 0;
Scw[ch].PckCnt = Scw[ch].TimEnb = 0;
Scw[ch].ComPhs = Scw[ch].Enable = 0;
Scw[ch].AddPar[0] = NULL;
Rcw[ch].RcvKnd = 0;
Rcw[ch].RcvCmp = 0;
// memfill((char *) &RcvSttDat[ch], sizeof(S_Stt_Dat), NULL);
Rcw[ch].DelEnb = 1;
Rcw[ch].DelPhs = 0;
for (a=0;a<RSB_MAX;a++){
Rcw[ch].Buffer[a] = 0x55;
}
}
Sqw.SmpWrp = 0;
Sqw.SmpRdp = 0;
Dtb_SmpPoi = 0;
ChCnt.ChkBit = 0; // 妋擣僠儍僱儖價僢僩
ChCnt.Ch_Cnt = 0; // 庴怣僠儍僱儖悢
memfill((char *) Dtb_Max, sizeof(Dtb_Max), NULL);
// 05-Mar-1999
DspDev.Phs = 0; // 昞帵婍惂屼僼僃乕僘
HpcCtr.Phs = 0;
#if DEMO_SEQ
SeqWrkInit();
#endif
}
/*=====================================
m:24-Jan-1999
@p << 昞帵愗傝懼偊丄僗僞僢僋 >>
=====================================*/
void DspReqStack(int num)
{
if (Disp.StkPoi < 100){
Disp.StkBuf[Disp.StkPoi ++] = num;
if (num == DSP_MAP){
Disp.Enable = 0; // 愗傝懼偊桳岟
}
}
}
// 埲壓 ver 1.30
/*---------------------------------------------*/
// 1.擔杮岅柤
// BMP File Write
// 2.Parameter愢柧
// LPTSTR szFile BMP File Name
// HANDLE hDIB Bitmap Handle
// 3.奣梫
// 4.婡擻愢柧
// 5.栠傝抣
// 6.旛峫
/*---------------------------------------------*/
BOOL WriteDIB(LPTSTR szFile, HANDLE hDIB)
{
BITMAPFILEHEADER hdr;
LPBITMAPINFOHEADER lpbi;
if (!hDIB)
return FALSE;
CFile file;
if (!file.Open(szFile, CFile::modeWrite|CFile::modeCreate))
return FALSE;
lpbi = (LPBITMAPINFOHEADER)hDIB;
int nColors = 1 << lpbi->biBitCount;
// Fill in the fields of the file header
hdr.bfType = ((WORD) ('M' << 8) | 'B'); // is always "BM"
hdr.bfSize = GlobalSize (hDIB) + sizeof( hdr );
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
hdr.bfOffBits = (DWORD)(sizeof(hdr) + lpbi->biSize + nColors * sizeof(RGBQUAD));
// Write the file header
file.Write(&hdr, sizeof(hdr));
// Write the DIB header and the bits
file.Write(lpbi, GlobalSize(hDIB));
return TRUE;
}
/*---------------------------------------------*/
// 1.擔杮岅柤
// Creates a DIB from a DDB
// 2.Parameter愢柧
// CBitmap& bitmap Device dependent bitmap
// DWORD dwCompression Type of compression - see BITMAPINFOHEADER
// CPalette* pPal Logical palette
// 3.奣梫
// 4.婡擻愢柧
// 5.栠傝抣
// 6.旛峫
/*---------------------------------------------*/
HANDLE DDBToDIB(CBitmap& bitmap, DWORD dwCompression, CPalette* pPal)
{
LPBITMAPINFOHEADER lpbi;
BITMAPINFOHEADER bi;
BITMAP bm;
DWORD dwLen;
HANDLE hDIB, handle;
HDC hDC;
HPALETTE hPal;
ASSERT(bitmap.GetSafeHandle());
// The function has no arg for bitfields
if (dwCompression == BI_BITFIELDS)
return NULL;
// If a palette has not been supplied use defaul palette
hPal = (HPALETTE) pPal->GetSafeHandle();
if (hPal == NULL)
hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);
// Get bitmap information
bitmap.GetObject(sizeof(bm), (LPSTR)&bm);
// Initialize the bitmapinfoheader
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bm.bmWidth;
bi.biHeight = bm.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = bm.bmPlanes * bm.bmBitsPixel; //bm.bmPlanes * bm.bmBitsPixel;
//bi.biBitCount = 8; //bm.bmPlanes * bm.bmBitsPixel;
//bi.biBitCount = 24; //bm.bmPlanes * bm.bmBitsPixel;
bi.biCompression = dwCompression;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
// Compute the size of the infoheader and the color table
int nColors = (1 << bi.biBitCount);
////if (nColors > 256)
//if (bi.biBitCount > 8)
// nColors = nColors;
dwLen = bi.biSize + nColors * sizeof(RGBQUAD);
// We need a device context to get the DIB from
hDC = GetDC(NULL);
hPal = SelectPalette(hDC,hPal,FALSE);
RealizePalette(hDC);
// Allocate enough memory to hold bitmapinfoheader and color table
hDIB = GlobalAlloc(GMEM_FIXED,dwLen);
if (!hDIB) {
SelectPalette(hDC,hPal,FALSE);
ReleaseDC(NULL,hDC);
return NULL;
}
lpbi = (LPBITMAPINFOHEADER)hDIB;
*lpbi = bi;
// Call GetDIBits with a NULL lpBits param, so the device driver
// will calculate the biSizeImage field
GetDIBits(hDC, (HBITMAP)bitmap.GetSafeHandle(), 0L, (DWORD)bi.biHeight, (LPBYTE)NULL, (LPBITMAPINFO)lpbi, (DWORD)DIB_RGB_COLORS);
bi = *lpbi;
// If the driver did not fill in the biSizeImage field, then compute it
// Each scan line of the image is aligned on a DWORD (32bit) boundary
if (bi.biSizeImage == 0) {
bi.biSizeImage = ((((bi.biWidth * bi.biBitCount) + 31) & ~31) / 8) * bi.biHeight;
// If a compression scheme is used the result may infact be larger
// Increase the size to account for this.
if (dwCompression != BI_RGB)
bi.biSizeImage = (bi.biSizeImage * 3) / 2;
}
// Realloc the buffer so that it can hold all the bits
dwLen += bi.biSizeImage;
if (handle = GlobalReAlloc(hDIB, dwLen, GMEM_MOVEABLE))
hDIB = handle;
else {
GlobalFree(hDIB);
// Reselect the original palette
SelectPalette(hDC,hPal,FALSE);
ReleaseDC(NULL,hDC);
return NULL;
}
// Get the bitmap bits
lpbi = (LPBITMAPINFOHEADER)hDIB;
// FINALLY get the DIB
BOOL bGotBits = GetDIBits(hDC, (HBITMAP)bitmap.GetSafeHandle(),
0L, // Start scan line
(DWORD)bi.biHeight, // # of scan lines
(LPBYTE)lpbi // address for bitmap bits
+ (bi.biSize + nColors * sizeof(RGBQUAD)),
(LPBITMAPINFO)lpbi, // address of bitmapinfo
(DWORD)DIB_RGB_COLORS); // Use RGB for color table
if (!bGotBits) {
GlobalFree(hDIB);
SelectPalette(hDC,hPal,FALSE);
ReleaseDC(NULL,hDC);
return NULL;
}
SelectPalette(hDC, hPal, FALSE);
ReleaseDC(NULL, hDC);
return hDIB;
}
/*---------------------------------------------*/
// 1.擔杮岅柤
// Window 昞帵撪梕 -> BMP Save
// 2.Parameter愢柧
// LPTSTR szFile Save File Name
// CWnd *pWnd Window Pointer
// int nFileType 0:Only
// 3.奣梫
// 4.婡擻愢柧
// 5.栠傝抣
// 6.旛峫
/*---------------------------------------------*/
BOOL SaveWindowAsFile(LPTSTR szFile, CWnd *pWnd, int nFileType)
{
CString strFileName, strError = "";
CBitmap bitmap;
CWindowDC dc(pWnd);
CDC memDC;
CRect rect;
strFileName = (CString)szFile;
memDC.CreateCompatibleDC(&dc);
pWnd->GetWindowRect(rect);
bitmap.CreateCompatibleBitmap(&dc, rect.Width(),rect.Height());
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
memDC.BitBlt(0, 0, rect.Width(),rect.Height(), &dc, 0, 0, SRCCOPY);
// Create logical palette if device support a palette
CPalette pal;
if (dc.GetDeviceCaps(RASTERCAPS) & RC_PALETTE) {
UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 256);
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
pLP->palVersion = 0x300;
pLP->palNumEntries = GetSystemPaletteEntries(dc, 0, 255, pLP->palPalEntry);
// Create the palette
pal.CreatePalette(pLP);
delete[] pLP;
}
memDC.SelectObject(pOldBitmap);
// Convert the bitmap to a DIB
HANDLE hDIB = DDBToDIB(bitmap, BI_RGB, &pal);
if (hDIB == NULL)
return FALSE;
// Write it to file
//if (nFileType == BMP_FILE)
WriteDIB(szFile, hDIB);
//else
// JpegFromDib(hDIB, 100, strFileName, &strError);
// Free the memory allocated by DDBToDIB for the DIB
GlobalFree(hDIB);
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -