// Chroma22293.cpp : 定义 DLL 的导出函数。
//

#include "stdafx.h"
#include "framework.h"
#ifndef _PYD_
#include "Chroma22293.h"
#else
#include "Python.h"
#endif

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#define READ_LEN 8912
// 唯一的应用程序对象

//////////////////////////////////////////////////////////////////////////
// 全局变量;
std::string g_strData;
CSynSerial g_SynSerial;


#ifndef _PYD_
CWinApp theApp;

using namespace std;

int main()
{
    int nRetCode = 0;

    HMODULE hModule = ::GetModuleHandle(nullptr);

    if (hModule != nullptr)
    {
        // 初始化 MFC 并在失败时显示错误
        if (!AfxWinInit(hModule, nullptr, ::GetCommandLine(), 0))
        {
            // TODO: 在此处为应用程序的行为编写代码。
            wprintf(L"错误: MFC 初始化失败\n");
            nRetCode = 1;
        }
        else
        {
            // TODO: 在此处为应用程序的行为编写代码。
			if ( OpenDevice(3,115200,8,0,1))
			{
				if (GetBufStatus())
					printf("成功BUF\n");

				GetDeviceSoft();
				GetDeviceName();

				if (SetPattern(11))
					printf("SetPattern成功\n");

				if (SetTiming(11))
					printf("SetTiming成功\n");

				if (SetTimingPattern(11, 11))
					printf("SetTimingPattern成功\n");

				if (SetBlueOFF())
					printf("SetBlueOFF成功\n");

				if (SetBlueON())
					printf("SetBuleON成功\n");

				if (SetGreenOFF())
					printf("SetGreenOFF成功\n");

				if (SetGreenON())
					printf("SetGreenON成功\n");

				if (SetRedOFF())
					printf("SetRedOFF成功\n");

				if (SetRedON())
					printf("SetRedON成功\n");

				if (SetKeyBoardLock())
					printf("SetKeyBoardLock成功\n");

				if (SetKeyBoardUnLock())
					printf("SetKeyBoardUnLock成功\n");
			}

			CloseDevice();
        }
    }
    else
    {
        // TODO: 更改错误代码以符合需要
        wprintf(L"错误: GetModuleHandle 失败\n");
        nRetCode = 1;
    }

	system("pause");

    return nRetCode;
}

//////////////////////////////////////////////////////////////////////////
// C接口;
DoException g_funExp = NULL;

CHROMA22293_API BOOL OpenDevice(BYTE byCommPort, DWORD dwBaudRate, BYTE bySize, BYTE byParity, BYTE byStopBits)
{
	if (g_SynSerial.IsOpen())
	{
		g_SynSerial.CloseSerialPort();
	}

	return g_SynSerial.OpenSerialPort(byCommPort, dwBaudRate, bySize, byParity, byStopBits, 0, 0);
}

CHROMA22293_API void CloseDevice()
{
	g_SynSerial.CloseSerialPort();
}

CHROMA22293_API BOOL GetBufStatus()
{
	std::string data = "dummy;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size() )
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = {0};
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if ( dwData == 0)
	{
		return FALSE;
	}

	printf("dumy=>%s\n",byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API LPCTSTR GetDeviceSoft()
{
	std::string data = "report ver;\r";
	if (!g_SynSerial.IsOpen())
		return _T("");

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return _T("");
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return _T("");
	}

	g_strData = (char*)byData;
	printf("report ver=>%s\n", byData);

	return g_strData.c_str();
}

CHROMA22293_API LPCTSTR GetDeviceName()
{
	std::string data = "report model;\r";
	if (!g_SynSerial.IsOpen())
		return _T("");

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return _T("");
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return _T("");
	}

	g_strData = (char*)byData;
	printf("report ver=>%s\n", byData);

	return g_strData.c_str();
}

CHROMA22293_API BOOL SetPattern(int param)
{
	char data[128] = {0};
	_stprintf_s(data, _T("run ptn %ld;\r"), param);
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data, sizeof(data));
	if (dwData != sizeof(data))
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("run ptn %d;=>%s\n", param, byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetTiming(int param)
{
	char data[128] = { 0 };
	_stprintf_s(data, _T("run tim %ld;\r"), param);
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data, sizeof(data));
	if (dwData != sizeof(data))
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("run ptn %d;=>%s\n", param, byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetTimingPattern(int param1, int param2)
{
	char data[128] = { 0 };
	_stprintf_s(data, _T("run tim %ld;run tim %ld;\r"), param1, param2);
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data, strlen(data));
	if (dwData != strlen(data))
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("run ptn %d;run tim %d=>%s\n", param1, param2, byData);

	return !_mbsicmp((const byte*)"ok;\r\nok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetBlueOFF()
{
	std::string data = "b off;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("b off=>%s\n", byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetBlueON()
{
	std::string data = "b on;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("b on=>%s\n", byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetGreenOFF()
{
	std::string data = "g off;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("g off=>%s\n", byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetGreenON()
{
	std::string data = "g on;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("g on=>%s\n", byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetRedOFF()
{
	std::string data = "r off;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("r off=>%s\n", byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetRedON()
{
	std::string data = "r on;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("r on=>%s\n", byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetKeyBoardLock()
{
	std::string data = "kb lock on;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("kb lock on=>%s\n", byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API BOOL SetKeyBoardUnLock()
{
	std::string data = "kb lock off;\r";
	if (!g_SynSerial.IsOpen())
		return FALSE;

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return FALSE;
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return FALSE;
	}

	printf("kb lock off=>%s\n", byData);

	return !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData);
}

CHROMA22293_API void SetExceptionCallBack(DoException funExp)
{
	g_funExp = funExp;
}

#else
static PyObject* OpenDevice(PyObject* self, PyObject* args)
{
	// 应用程序路径;
	unsigned int port, baudrate, datasize, parity, stopbite;
	if (!PyArg_ParseTuple(args, "IIIII", &port, &baudrate, &datasize, &parity, &stopbite))
		return NULL;

	if (g_SynSerial.IsOpen())
	{
		g_SynSerial.CloseSerialPort();
	}

	// 返回进程Id;
	return Py_BuildValue("b", g_SynSerial.OpenSerialPort(port, baudrate, datasize, parity, stopbite, 0, 0));
}

static PyObject* CloseDevice(PyObject* self, PyObject* args)
{
	g_SynSerial.CloseSerialPort();
	return Py_BuildValue("");	// 返回None;
}

static PyObject* GetBufStatus(PyObject* self, PyObject* args)
{
	std::string data = "dummy;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* GetDeviceSoft(PyObject* self, PyObject* args)
{
	std::string data = "report ver;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("s", _T(""));

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("s", _T(""));
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("s", _T(""));
	}

	g_strData = (char*)byData;

	return Py_BuildValue("s", g_strData.c_str());
}

static PyObject* GetDeviceName(PyObject* self, PyObject* args)
{
	std::string data = "report model;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("s", _T(""));

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("s", _T(""));
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("s", _T(""));
	}

	g_strData = (char*)byData;

	return Py_BuildValue("s", g_strData.c_str());
}

static PyObject* SetPattern(PyObject* self, PyObject* args)
{
	unsigned int param;
	if (!PyArg_ParseTuple(args, "I", &param))
		return NULL;

	char data[128] = { 0 };
	_stprintf_s(data, _T("run ptn %ld;\r"), param);
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data, sizeof(data));
	if (dwData != sizeof(data))
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetTiming(PyObject* self, PyObject* args)
{
	unsigned int param;
	if (!PyArg_ParseTuple(args, "I", &param))
		return NULL;

	char data[128] = { 0 };
	_stprintf_s(data, _T("run tim %ld;\r"), param);
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data, sizeof(data));
	if (dwData != sizeof(data))
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetTimingPattern(PyObject* self, PyObject* args)
{
	unsigned int param1, param2;
	if (!PyArg_ParseTuple(args, "II", &param1, &param2))
		return NULL;

	char data[128] = { 0 };
	_stprintf_s(data, _T("run tim %ld;run tim %ld;\r"), param1, param2);
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data, strlen(data));
	if (dwData != strlen(data))
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\nok;\r\n", (const byte*)byData));
}

static PyObject* SetBlueOFF(PyObject* self, PyObject* args)
{
	std::string data = "b off;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetBlueON(PyObject* self, PyObject* args)
{
	std::string data = "b on;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetGreenOFF(PyObject* self, PyObject* args)
{
	std::string data = "g off;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetGreenON(PyObject* self, PyObject* args)
{
	std::string data = "g on;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetRedOFF(PyObject* self, PyObject* args)
{
	std::string data = "r off;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetRedON(PyObject* self, PyObject* args)
{
	std::string data = "r on;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetKeyBoardLock(PyObject* self, PyObject* args)
{
	std::string data = "kb lock on;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

static PyObject* SetKeyBoardUnLock(PyObject* self, PyObject* args)
{
	std::string data = "kb lock off;\r";
	if (!g_SynSerial.IsOpen())
		return Py_BuildValue("b", 0);

	// 写串口数据;
	DWORD dwData = g_SynSerial.WriteComm((byte*)data.data(), data.size());
	if (dwData != data.size())
	{
		return Py_BuildValue("b", 0);
	}

	// 读取串口数据;
	byte byData[READ_LEN] = { 0 };
	dwData = g_SynSerial.ReadComm(byData, READ_LEN);
	if (dwData == 0)
	{
		return Py_BuildValue("b", 0);
	}

	return Py_BuildValue("b", !_mbsicmp((const byte*)"ok;\r\n", (const byte*)byData));
}

// 描述方法,暴露给python的函数;
static PyMethodDef Chroma22293_Methods[] = {
	{"OpenDevice",OpenDevice,METH_VARARGS,"打开设备"},
	{"CloseDevice", CloseDevice, METH_VARARGS, "关闭设备"},
	{"GetBufStatus", GetBufStatus, METH_VARARGS, "BUF测试"},
	{"GetDeviceSoft", GetDeviceSoft, METH_VARARGS, "设备版本"},
	{"GetDeviceName", GetDeviceName, METH_VARARGS, "设备信息"},
	{"SetPattern", SetPattern, METH_VARARGS, "设置Ptn"},
	{"SetTiming", SetTiming, METH_VARARGS, "设置Tim"},
	{"SetTimingPattern", SetTimingPattern, METH_VARARGS, "设置Ptn和Tim"},
	{"SetBlueOFF", SetBlueOFF, METH_VARARGS, "关蓝"},
	{"SetBlueON", SetBlueON, METH_VARARGS, "开蓝"},
	{"SetGreenOFF", SetGreenOFF, METH_VARARGS, "关绿"},
	{"SetGreenON", SetGreenON, METH_VARARGS, "开绿"},
	{"SetRedOFF", SetRedOFF, METH_VARARGS, "关红"},
	{"SetRedON", SetRedON, METH_VARARGS, "开红"},
	{"SetKeyBoardLock", SetKeyBoardLock, METH_VARARGS, "锁键盘"},
	{"SetKeyBoardUnLock", SetKeyBoardUnLock, METH_VARARGS, "解锁键盘"},
	//{"SetCallBack", SetCallBack, METH_VARARGS, "设置回调"},// Pyd暂时未了解如何实现回调;
	{NULL,NULL}
};

// 初始模块;//格式：init<模块名称>
PyMODINIT_FUNC initChroma22293()
{
	// 初始化pyd函数列表;
	PyObject* m, * d;
	m = Py_InitModule("Chroma22293", Chroma22293_Methods);
	d = PyModule_GetDict(m);
}
#endif