Пример #1
0
LRESULT CALLBACK
StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    RECT rt;
    PAINTSTRUCT ps;
    HDC hdc;
    PNHStatusWindow data;

    data = (PNHStatusWindow) GetWindowLong(hWnd, GWL_USERDATA);
    switch (message) {
    case WM_MSNH_COMMAND: {
        switch (wParam) {
        case MSNH_MSG_PUTSTR:
        case MSNH_MSG_CLEAR_WINDOW:
            ZeroMemory(data->window_text, sizeof(data->window_text));
            FormatStatusString(data->window_text, data->nhstat_format);
            break;

        case MSNH_MSG_CURSOR: {
            PMSNHMsgCursor msg_data = (PMSNHMsgCursor) lParam;
            if (msg_data->y == 0) {
                InvalidateRect(hWnd, NULL, TRUE);
            }
        } break;
        }
    } break;

    case WM_PAINT: {
        HGDIOBJ oldFont;
        TCHAR wbuf[MAXWINDOWTEXT];
        COLORREF OldBg, OldFg;

        hdc = BeginPaint(hWnd, &ps);
        GetClientRect(hWnd, &rt);

        oldFont = SelectObject(
            hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));
        OldBg = SetBkColor(hdc, mswin_get_color(NHW_STATUS, MSWIN_COLOR_BG));
        OldFg =
            SetTextColor(hdc, mswin_get_color(NHW_STATUS, MSWIN_COLOR_FG));

        DrawText(hdc, NH_A2W(data->window_text, wbuf, MAXWINDOWTEXT),
                 strlen(data->window_text), &rt, DT_LEFT | DT_NOPREFIX);

        SetTextColor(hdc, OldFg);
        SetBkColor(hdc, OldBg);
        SelectObject(hdc, oldFont);
        EndPaint(hWnd, &ps);
    } break;

    case WM_DESTROY:
        free(data);
        SetWindowLong(hWnd, GWL_USERDATA, (LONG) 0);
        break;

    case WM_SETFOCUS:
        SetFocus(GetNHApp()->hMainWnd);
        break;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Пример #2
0
int main()
{
	unsigned int totalSent = 0, totalReceived = 0, totalNonMatching = 0;
	C1394Camera theCamera;
	theCamera.CheckLink();
	theCamera.SelectCamera(0);
	theCamera.InitCamera(1);

	theCamera.SIOConfigPort(300,8,1,0);
	theCamera.SIOEnable(1,1);
	unsigned char ibuf[64],obuf[64];
	for(int ii = 0; ii < 26; ++ii)
	{
		obuf[ii] = 'a' + ii;
		obuf[ii+26] = 'A' + ii;
		if(ii < 10)
		{
			obuf[ii+52] = '0' + ii;
		}
	}

	obuf[62]='+';
	obuf[63]='-';

	for(int rounds=0; rounds<2; rounds++)
	{
		for(int ii = 0; ii<64; ++ii)
		{
			int ret = theCamera.SIOWriteBytes(obuf,ii+1);
			printf("Wrote %d of %d bytes\n",ret,ii+1);
			totalSent += ret;
			bool mustReset = false;
			for(int jj=0; jj <ii+1; )
			{
				Sleep(10);
				ret = theCamera.SIOReadBytes(ibuf+jj,64-jj);
				totalReceived += ret;
				StatusByte statusByte;
				theCamera.GetSIOStatusByte((unsigned char *)&statusByte);
				//printf(" -> Read back %d bytes (status = %s):\n",ret,FormatStatusString(statusByte));
				for(int kk = 0; kk < ret; ++kk)
				{
					if(ibuf[jj+kk] != obuf[jj+kk])
					{
						printf("   -> Match Fail: (%02x != %02x) : %s\n",(unsigned int)ibuf[jj+kk],(unsigned int)obuf[jj+kk],FormatStatusString(statusByte));
						++totalNonMatching;
						mustReset = true;
					}
				}
				jj += ret;
			}
			if(mustReset)
			{
				theCamera.SIOEnable(1,1);
			}

		}
	}

	printf("Loopback Tests Complete: Sent %d, Received %d, Errors = %d  (%.1f%%)\n",
		totalSent,totalReceived,totalNonMatching,100.0 * (double)(totalNonMatching) / (double)(totalReceived));

	unsigned long ulConfigRegister;
	theCamera.GetSIOConfig(&ulConfigRegister);
	printf(" - Config register = %08x -\n",ulConfigRegister);
	return 0;
}