예제 #1
0
int
main()
{
    /* We no longer translate space to %20, that
    turns out not to help all that much. */
    mytest("aaa","aaa",1);
    mytest(" bc"," bc",2);
    mytest(";bc","%3bbc",3);
    mytest(" bc\n"," bc%0a",4);
    mytest(";bc\n","%3bbc%0a",5);
    mytest(" bc\r"," bc%0d",6);
    mytest(";bc\r","%3bbc%0d",7);
    mytest(" \x01"," %01",8);
    mytest(";\x01","%3b%01",9);
    mytestfrom("abc","abc",10);
    mytestfrom("a%20bc","a bc",11);
    mytestfrom("a%%20bc","a%20bc",12);
    mytestfrom("a%%%20bc","a% bc",13);
    mytestfrom("a%%%%20bc","a%%20bc",14);
    mytestfrom("a%20","a ",15);
    /* The following is mistaken input. */
    mytestfrom("a%2","a2",16);
    mytestfrom("a%","a%",17);
    mytest("%bc","%25bc",18);

    if (errcnt) {
        printf("uri errcount ",errcnt);
    }
    return errcnt? 1:0;
}
예제 #2
0
void combinatorics_test() {
    suite("SubsetBacktrackSearch");
    mytest(subset_backtrack_search);

    suite("PermutationBacktrackSearch");
    mytest(permutation_backtrack_search);
//
    //suite("Generate symbols");
    //mytest(generate_symbols);
}
예제 #3
0
static void verify_col_data(const char *table, const char *col,
const char *exp_data)
{
 static char query[MAX_TEST_QUERY_LENGTH];
 MYSQL_RES *result;
 MYSQL_ROW row;
 int       rc, field= 1;

 if (table && col)
 {
   strxmov(query, "SELECT ", col, " FROM ", table, " LIMIT 1", NullS);
   if (!opt_silent)
   fprintf(stdout, "\n %s", query);
   rc= mysql_query(mysql, query);
   myquery(rc);

   field= 0;
 }

 result= mysql_use_result(mysql);
 mytest(result);

 if (!(row= mysql_fetch_row(result)) || !row[field])
 {
   fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***");
   exit(1);
 }
 if (strcmp(row[field], exp_data))
 {
   fprintf(stdout, "\n obtained: `%s` (expected: `%s`)",
   row[field], exp_data);
   DIE_UNLESS(FALSE);
 }
 mysql_free_result(result);
}
예제 #4
0
파일: 20180226-1.c 프로젝트: suseecho/gcc
int main (void)
{
  mp_int i = { 2, 0, -1 };
  if (mytest (&i, 0) != 1)
    abort ();
  return 0;
}
void btnTest_Click (HWND hwnd)
{
  FillParameters(hwnd, pParams);
  wchar_t *testResultMsg= mytest(hwnd, pParams);
  MessageBoxW(hwnd, testResultMsg, L"Test Result", MB_OK);
  x_free(testResultMsg);
}
예제 #6
0
 void rMatrix_test() {
     suite("RMatrix");
     mytest(push_row);
     mytest(swap_rows);
     mytest(comparison);
     mytest(comparison_with_error);
     mytest(create_clone);
     mytest(copy_to);
     mytest(get_row);
 }
예제 #7
0
void CmdTest(int action)
{

  if(action==CMD_SHORT_HELP) return;
  if(action==CMD_LONG_HELP) {
    printf("testasm\n\n"
	   "This command tests the C to assembler interface\n"
	   );

    return;
  }
  printf("ret val = %d\n", mytest( 77  ) );
}
예제 #8
0
TEST(Optim_Downhill, regression_basic){
    cv::Ptr<cv::optim::DownhillSolver> solver=cv::optim::createDownhillSolver();
#if 1
    {
        cv::Ptr<cv::optim::Solver::Function> ptr_F(new SphereF());
        cv::Mat x=(cv::Mat_<double>(1,2)<<1.0,1.0),
            step=(cv::Mat_<double>(2,1)<<-0.5,-0.5),
            etalon_x=(cv::Mat_<double>(1,2)<<-0.0,0.0);
        double etalon_res=0.0;
        mytest(solver,ptr_F,x,step,etalon_x,etalon_res);
    }
#endif
#if 1
    {
        cv::Ptr<cv::optim::Solver::Function> ptr_F(new RosenbrockF());
        cv::Mat x=(cv::Mat_<double>(2,1)<<0.0,0.0),
            step=(cv::Mat_<double>(2,1)<<0.5,+0.5),
            etalon_x=(cv::Mat_<double>(2,1)<<1.0,1.0);
        double etalon_res=0.0;
        mytest(solver,ptr_F,x,step,etalon_x,etalon_res);
    }
#endif
}
예제 #9
0
void tcMainWindow::CreateMenusAndToolbar()
{
	QAction *action;
	QMenu *menu;
	QToolBar *toolbar;

	toolbar = addToolBar(tr("ToolBar"));

	menu = menuBar()->addMenu(tr("&Data"));
	action = new QAction(QIcon(""), tr("Modify Market..."), this);
	connect(action, SIGNAL(triggered()), this, SLOT(DoModifyMarket()));
	menu->addAction(action);
	menu->addSeparator();
	action = new QAction(QIcon(""), tr("Input Stock Data..."), this);
	connect(action, SIGNAL(triggered()), this, SLOT(DoInputStockData()));
	menu->addAction(action);
	toolbar->addAction(action);
	action = new QAction(QIcon(""), tr("Edit Favourite Stock..."), this);
	connect(action, SIGNAL(triggered()), this, SLOT(DoEditFavouriteStock()));
	menu->addAction(action);
	toolbar->addAction(action);
	action = new QAction(QIcon(""), tr("Import Stock Data..."), this);
	connect(action, SIGNAL(triggered()), this, SLOT(DoImportStockData()));
	menu->addAction(action);
	toolbar->addAction(action);
	menu->addSeparator();
	action = new QAction(QIcon(""), tr("Exit"), this);
	connect(action, SIGNAL(triggered()), this, SLOT(DoExit()));
	menu->addAction(action);

	menu = menuBar()->addMenu(tr("&View"));
	action = new QAction(QIcon(""), tr("Stock List"), this);
	connect(action, SIGNAL(triggered()), this, SLOT(DoViewStockList()));
	menu->addAction(action);
	action = new QAction(QIcon(""), tr("Weekly View"), this);
	connect(action, SIGNAL(triggered()), this, SLOT(DoViewWeeklyView()));
	menu->addAction(action);

	menu = menuBar()->addMenu(tr("&Help"));
	action = new QAction(QIcon(""), tr("About..."), this);
	connect(action, SIGNAL(triggered()), this, SLOT(DoAbout()));
	menu->addAction(action);

#ifdef _DEBUG
	menu = menuBar()->addMenu("Test");
	action = new QAction(QIcon(""), "test", this);
	connect(action, SIGNAL(triggered()), this, SLOT(mytest()));
	menu->addAction(action);
#endif
}
예제 #10
0
int
main()
{
    char b[20];

#define mytest(x) {str_ulong(b, (x)); puts(b); }
    mytest(0);
    mytest(1);
    mytest(9);
    mytest(10);
    mytest(50);
    mytest(ULONG_MAX);
    _exit(0);
}
예제 #11
0
void my_process_warnings(MYSQL *conn, unsigned expected_warning_count)
{
 MYSQL_RES *result;
 int rc;

 if (!opt_silent)
 fprintf(stdout, "\n total warnings: %u (expected: %u)\n",
 mysql_warning_count(conn), expected_warning_count);

 DIE_UNLESS(mysql_warning_count(mysql) == expected_warning_count);

 rc= mysql_query(conn, "SHOW WARNINGS");
 DIE_UNLESS(rc == 0);

 result= mysql_store_result(conn);
 mytest(result);

 rc= my_process_result_set(result);
 mysql_free_result(result);
}
예제 #12
0
파일: test_002.c 프로젝트: cloudflare/ljmm
int
main(int argc, char **argv) {
    ljmm_let_OS_take_care_1G_2G(0);

    pid_t pid = fork();
    if (pid < 0) {
        return 1;
    }

    if (pid) {
        /* parent process */
        int child_status;
        waitpid(pid, &child_status, 0);
        if (!WIFEXITED(child_status) || WEXITSTATUS(child_status) != 0) {
            fprintf(stderr, "child process does not exit normally\n");
            exit(1);
        }
    }

    exit(mytest() ? 0 : 1);
}
예제 #13
0
 void hashMapArray_test() {
     suite("HashMapArray");
     mytest(push_value);
     mytest(push_or_update_value);
 }
예제 #14
0
void cArrayList_test() {
    suite("CArrayList");
    mytest(push);
    mytest(copy_constructor);
}
예제 #15
0
 void intBitSet_test() {
     suite("IntBitSet");
     mytest(bit_set);
 }
LRESULT CBacnetOutput::Fresh_Output_List(WPARAM wParam,LPARAM lParam)
{
     
	int Fresh_Item;
	int isFreshOne = (int)lParam;

	int digital_special_output_count = 0;
	int analog_special_output_count = 0;
	if(bacnet_device_type == BIG_MINIPANEL)
	{
		digital_special_output_count = BIG_MINIPANEL_OUT_D;
		analog_special_output_count = BIG_MINIPANEL_OUT_A;
	}
	else if(bacnet_device_type == SMALL_MINIPANEL)
	{
		digital_special_output_count = SMALL_MINIPANEL_OUT_D;
		analog_special_output_count = SMALL_MINIPANEL_OUT_A;
	}
	else if(bacnet_device_type == TINY_MINIPANEL)
	{
		digital_special_output_count = TINY_MINIPANEL_OUT_D;
		analog_special_output_count = TINY_MINIPANEL_OUT_A;
	}
	else if(bacnet_device_type == T38AI8AO6DO)
	{
		digital_special_output_count = T38AI8AO6DO_OUT_D;
		analog_special_output_count = T38AI8AO6DO_OUT_A;
	}
	else if(bacnet_device_type == PID_T322AI)
	{
		digital_special_output_count = T322AI_OUT_D;
		analog_special_output_count = T322AI_OUT_A;
	}
	//if(pFrame->m_product.at(selected_product_index).product_class_id == T38AI8AO6DO)
	if((bacnet_device_type == T38AI8AO6DO) ||
		(bacnet_device_type == PID_T322AI))
	{
		OUTPUT_LIMITE_ITEM_COUNT = digital_special_output_count + analog_special_output_count;
	}
	else
	{
		OUTPUT_LIMITE_ITEM_COUNT = BAC_OUTPUT_ITEM_COUNT;
	}

	bool temp_need_show_external = false;
	for (int z= 0 ;z < (int)m_Output_data.size();z++)
	{
		if(z>= OUTPUT_LIMITE_ITEM_COUNT)
			break;
		if((m_Output_data.at(z).sub_id !=0) &&
			(m_Output_data.at(z).sub_product !=0))
		{
			temp_need_show_external = true;
			break;
		}

	}
	if(show_output_external != temp_need_show_external)
	{
		show_output_external = temp_need_show_external;
		if(temp_need_show_external)
		{
			CRect temp_rect;
			temp_rect = Output_rect;
			temp_rect.right = 1150;
			temp_rect.top = temp_rect.top + 24;
			m_output_list.MoveWindow(temp_rect);
			m_output_list.SetColumnWidth(OUTPUT_EXTERNAL,60);
			m_output_list.SetColumnWidth(OUTPUT_PRODUCT,80);
			m_output_list.SetColumnWidth(OUTPUT_EXT_NUMBER,80);
		}
		else
		{
			CRect temp_rect;
			temp_rect = Output_rect;
			temp_rect.right = 950;
			temp_rect.top = temp_rect.top + 24;
			m_output_list.MoveWindow(temp_rect);

			m_output_list.SetColumnWidth(OUTPUT_EXTERNAL,0);
			m_output_list.SetColumnWidth(OUTPUT_PRODUCT,0);
			m_output_list.SetColumnWidth(OUTPUT_EXT_NUMBER,0);
		}
	}


	if(isFreshOne == REFRESH_ON_ITEM)
	{
		Fresh_Item = (int)wParam;
	}
	else
	{
		if(m_output_list.IsDataNewer((char *)&m_Output_data.at(0),sizeof(Str_out_point) * BAC_OUTPUT_ITEM_COUNT))
		{
			//避免list 刷新时闪烁;在没有数据变动的情况下不刷新List;
			m_output_list.SetListData((char *)&m_Output_data.at(0),sizeof(Str_out_point) * BAC_OUTPUT_ITEM_COUNT);
		}
		else
		{
			return 0;
		}
	}


	CString temp1;
	//int Fresh_Item;
	//int isFreshOne = (int)lParam;
	//if(isFreshOne == REFRESH_ON_ITEM)
	//{
	//	Fresh_Item = (int)wParam;
	//}
	for (int i=0;i<(int)m_Output_data.size();i++)
	{
		if(isFreshOne)
		{
			i = Fresh_Item;
		}

		if(i>=output_item_limit_count)
			break;

		if(i>= OUTPUT_LIMITE_ITEM_COUNT)
		{
			for (int a=0;a<OUTPUT_COL_NUMBER; a++)
			{
				m_output_list.SetItemText(i,a,_T(""));
			}
			continue;
		}
		CString temp_item,temp_value,temp_cal,temp_filter,temp_status,temp_lable;
		CString temp_des;
		CString temp_units;

		MultiByteToWideChar( CP_ACP, 0, (char *)m_Output_data.at(i).description, (int)strlen((char *)m_Output_data.at(i).description)+1, 
			temp_des.GetBuffer(MAX_PATH), MAX_PATH );
		temp_des.ReleaseBuffer();
		temp_item.Format(_T("OUT%d"),i+1);
		m_output_list.SetItemText(i,OUTPUT_NUM,temp_item);
		m_output_list.SetItemText(i,OUTPUT_FULL_LABLE,temp_des);

		m_output_list.SetCellEnabled(i,OUTPUT_HW_SWITCH,0);


		//int digital_special_output_count = 0;
		//int analog_special_output_count = 0;

		m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T(""));
		//这样加实在是情非得已,老毛非得加一堆条件,还要smart;
		if((bacnet_device_type == BIG_MINIPANEL) || ((bacnet_device_type == SMALL_MINIPANEL)) || (bacnet_device_type == TINY_MINIPANEL) || 
			(bacnet_device_type == T38AI8AO6DO) || (bacnet_device_type == PID_T322AI) )
		{
			//if(bacnet_device_type == BIG_MINIPANEL)
			//{
			//	digital_special_output_count = BIG_MINIPANEL_OUT_D;
			//	analog_special_output_count = BIG_MINIPANEL_OUT_A;
			//}
			//else if(bacnet_device_type == SMALL_MINIPANEL)
			//{
			//	digital_special_output_count = SMALL_MINIPANEL_OUT_D;
			//	analog_special_output_count = SMALL_MINIPANEL_OUT_A;
			//}
			//else if(bacnet_device_type == TINY_MINIPANEL)
			//{
			//	digital_special_output_count = TINY_MINIPANEL_OUT_D;
			//	analog_special_output_count = TINY_MINIPANEL_OUT_A;
			//}
			//else if(bacnet_device_type == T38AI8AO6DO)
			//{
			//	digital_special_output_count = T38AI8AO6DO_OUT_D;
			//	analog_special_output_count = T38AI8AO6DO_OUT_A;
			//}

			if(i < (digital_special_output_count +analog_special_output_count) )
			{
				if(m_Output_data.at(i).hw_switch_status == HW_SW_OFF)
				{
					m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("MAN-OFF"));		
					m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,0);

					m_output_list.SetItemTextColor(i,-1,RGB(255,0,0),0);
				}
				else if(m_Output_data.at(i).hw_switch_status == HW_SW_HAND)
				{
					m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("MAN-ON"));
					m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,0);

					m_output_list.SetItemTextColor(i,-1,RGB(255,0,0),0);
				}
				else
				{
					m_output_list.SetItemTextColor(i,-1,RGB(0,0,0),0);

					//if((i%2)==0)	//恢复前景和 背景 颜色;
					//	m_output_list.SetItemBkColor(i,-1,LIST_ITEM_DEFAULT_BKCOLOR,0);
					//else
					//	m_output_list.SetItemBkColor(i,-1,LIST_ITEM_DEFAULT_BKCOLOR_GRAY,0);

					m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("AUTO"));
					m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,1);
					if(m_Output_data.at(i).auto_manual==0)	//In output table if it is auto ,the value can't be edit by user
					{
						m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Auto"));
						//m_output_list.SetCellEnabled(i,OUTPUT_VALUE,0);
					}
					else
					{
						m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Manual"));
						//m_output_list.SetCellEnabled(i,OUTPUT_VALUE,1);
					}
				}
			}
			else
			{
				m_output_list.SetItemTextColor(i,-1,RGB(0,0,0),0);
				m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("AUTO"));
				m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,1);
				if(m_Output_data.at(i).auto_manual==0)	//In output table if it is auto ,the value can't be edit by user
				{
					m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Auto"));
					//m_output_list.SetCellEnabled(i,OUTPUT_VALUE,0);
				}
				else
				{
					m_Output_data.at(i).auto_manual = 1;
					m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Manual"));
					//m_output_list.SetCellEnabled(i,OUTPUT_VALUE,1);
				}
			}
		}
		else
		{
			m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,1);
			if(m_Output_data.at(i).auto_manual==0)	//In output table if it is auto ,the value can't be edit by user
			{
				m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Auto"));
				//m_output_list.SetCellEnabled(i,OUTPUT_VALUE,0);
			}
			else
			{
				m_Output_data.at(i).auto_manual = 1;
				m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Manual"));
				//m_output_list.SetCellEnabled(i,OUTPUT_VALUE,1);
			}
		}




			m_output_list.SetCellEnabled(i,OUTPUT_UNITE,0);
		if(m_Output_data.at(i).digital_analog == BAC_UNITS_ANALOG)
		{
			//m_output_list.SetCellEnabled(i,OUTPUT_0_PERSENT,1);
			//m_output_list.SetCellEnabled(i,OUTPUT_100_PERSENT,1);

			if(m_Output_data.at(i).range == 0)
				m_output_list.SetItemText(i,OUTPUT_RANGE,_T("Unused"));
			else if(m_Output_data.at(i).range < (sizeof(OutPut_List_Analog_Range)/sizeof(OutPut_List_Analog_Range[0])))
				m_output_list.SetItemText(i,OUTPUT_RANGE,OutPut_List_Analog_Range[m_Output_data.at(i).range]);
			else
				m_output_list.SetItemText(i,OUTPUT_RANGE,_T("Out of range"));

			if(m_Output_data.at(i).range < (sizeof(OutPut_List_Analog_Units)/sizeof(OutPut_List_Analog_Units[0])))
				m_output_list.SetItemText(i,OUTPUT_UNITE,OutPut_List_Analog_Units[m_Output_data.at(i).range]);
			else
				m_output_list.SetItemText(i,OUTPUT_UNITE,_T("Unused"));

			CString temp_low,temp_high;
			temp_low.Format(_T("%d"),0);
			temp_high.Format(_T("%d"),0);


			CString temp_value;
			temp_value.Format(_T("%.2f"),((float)m_Output_data.at(i).value) / 1000);
			m_output_list.SetItemText(i,OUTPUT_VALUE,temp_value);
#if 0
			CString cstemp_value;
			float temp_float_value;
			temp_float_value = ((float)m_Output_data.at(i).value) / 1000;
			cstemp_value.Format(_T("%.2f"),temp_float_value);
			m_output_list.SetItemText(i,OUTPUT_VALUE,cstemp_value);
#endif
			//m_output_list.SetItemText(i,OUTPUT_0_PERSENT,temp_low);
			//m_output_list.SetItemText(i,OUTPUT_100_PERSENT,temp_high);
		}
		else if(m_Output_data.at(i).digital_analog == BAC_UNITS_DIGITAL)
		{
			//m_output_list.SetCellEnabled(i,OUTPUT_0_PERSENT,0);
			//m_output_list.SetCellEnabled(i,OUTPUT_100_PERSENT,0);
			//m_output_list.SetItemText(i,OUTPUT_0_PERSENT,_T(""));
			//m_output_list.SetItemText(i,OUTPUT_100_PERSENT,_T(""));
			/*m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[m_Output_data.at(i).range]);*/
			m_output_list.SetItemText(i,OUTPUT_UNITE,_T(""));

			if(m_Output_data.at(i).range == 0)
			{
				CString temp_value2;
				temp_value2.Format(_T("%.2f"),((float)m_Output_data.at(i).value) / 1000);
				m_output_list.SetItemText(i,OUTPUT_VALUE,temp_value2);

				m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[0]);
			}
			else if(m_Output_data.at(i).range<=22)
				m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[m_Output_data.at(i).range]);
			else if((m_Output_data.at(i).range >= 23) && (m_Output_data.at(i).range <= 30))
			{
				if(receive_customer_unit)
					m_output_list.SetItemText(i,OUTPUT_RANGE,temp_unit_no_index[m_Output_data.at(i).range - 23]);
				else
					m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[0]);
			}
			else
				m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[0]);
#if 0
			if(m_Output_data.at(i).range>=12)
				m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[m_Output_data.at(i).range -11]);
			else
				m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[m_Output_data.at(i).range]);
#endif
			if((m_Output_data.at(i).range>30) || (m_Output_data.at(i).range == 0))
			{
				//m_output_list.SetItemText(i,OUTPUT_UNITE,Digital_Units_Array[0]);
			}
			else
			{
				
				CStringArray temparray;

				if((m_Output_data.at(i).range < 23) &&(m_Output_data.at(i).range !=0))
					temp1 = Digital_Units_Array[m_Output_data.at(i).range];
				else if((m_Output_data.at(i).range >=23) && (m_Output_data.at(i).range <= 30))
				{
					if(receive_customer_unit)
						temp1 = temp_unit_no_index[m_Output_data.at(i).range - 23];
				}
				else
				{
					temp1.Empty();
					m_output_list.SetItemText(i,OUTPUT_VALUE,_T(""));
				}

				SplitCStringA(temparray,temp1,_T("/"));
				if((temparray.GetSize()==2))
				{
					if(m_Output_data.at(i).control == 0)
						m_output_list.SetItemText(i,OUTPUT_VALUE,temparray.GetAt(0));
					else
						m_output_list.SetItemText(i,OUTPUT_VALUE,temparray.GetAt(1));
				}
			}
		}


			CString main_sub_panel;

#pragma region External info
		if((m_Output_data.at(i).sub_id !=0) &&
			//(m_Input_data.at(input_list_line).sub_number !=0) &&
			(m_Output_data.at(i).sub_product !=0))
		{
			unsigned char temp_pid = m_Output_data.at(i).sub_product;
			if((temp_pid == PM_T3PT10) ||
				(temp_pid == PM_T3IOA) ||
				(temp_pid == PM_T332AI) ||
				(temp_pid == PM_T38AI16O) ||
				(temp_pid == PM_T38I13O) ||
				(temp_pid == PM_T34AO) ||
				(temp_pid == PM_T322AI) ||
				(temp_pid == PM_T38AI8AO6DO) ||
				(temp_pid == PM_T36CT))
			{
				CString temp_name;
				temp_name = GetProductName(m_Output_data.at(i).sub_product);
				CString show_info;
				CString temp_id;
				CString temp_number;

				bitset<8> mytest((unsigned char)m_Output_data.at(i).sub_number);
				bool highest_bit;
				highest_bit = mytest.test(7);

				unsigned char temp_sub_number = 0;
				mytest = mytest.set(7,0);
				temp_sub_number = (unsigned char)mytest.to_ulong();


				if(highest_bit)
					temp_number.Format(_T("AO%d"),temp_sub_number + 1);
				else
					temp_number.Format(_T("DO%d"),temp_sub_number + 1);




				
				m_output_list.SetItemText(i,OUTPUT_EXTERNAL,_T("External"));
				m_output_list.SetItemTextColor(i,OUTPUT_EXTERNAL,RGB(0,0,255),FALSE);
				m_output_list.SetItemText(i,OUTPUT_PRODUCT,temp_name);
				m_output_list.SetItemText(i,OUTPUT_EXT_NUMBER,temp_number);

				main_sub_panel.Format(_T("%d-%d"),(unsigned char)Station_NUM,(unsigned char)m_Output_data.at(i).sub_id);
				m_output_list.SetItemText(i,OUTPUT_PANEL,main_sub_panel);
				//temp_id.Format(_T(" Sub ID: %u        "),(unsigned char)m_Input_data.at(input_list_line).sub_id);
				//temp_number.Format(_T("Input%d"),(unsigned char)m_Input_data.at(input_list_line).sub_number + 1);
				//show_info = _T("Module:") + temp_name +_T("        ") + temp_id + temp_number;
				//m_input_item_info.SetWindowTextW(show_info);

			}	
			else
			{
				main_sub_panel.Format(_T("%d"),(unsigned char)Station_NUM);
				m_output_list.SetItemText(i,OUTPUT_PANEL,main_sub_panel);
			}

		}
		else
		{
			main_sub_panel.Format(_T("%d"),(unsigned char)Station_NUM);
			m_output_list.SetItemText(i,OUTPUT_PANEL,main_sub_panel);
		}

#pragma endregion External info




		if(m_Output_data.at(i).decom==0)
			temp_status.Format(Output_Decom_Array[0]);
		else if(m_Output_data.at(i).decom==1)
			temp_status.Format(Output_Decom_Array[1]);
		else
			temp_status.Empty();
		m_output_list.SetItemText(i,OUTPUT_DECOM,temp_status);

		CString temp_pwm_period;
		temp_pwm_period.Format(_T("%u"),(unsigned char)m_Output_data.at(i).pwm_period);
		m_output_list.SetItemText(i,OUTPUT_PWM_PERIOD,temp_pwm_period);

		CString temp_des2;
		MultiByteToWideChar( CP_ACP, 0, (char *)m_Output_data.at(i).label, (int)strlen((char *)m_Output_data.at(i).label)+1, 
			temp_des2.GetBuffer(MAX_PATH), MAX_PATH );
		temp_des2.ReleaseBuffer();
		m_output_list.SetItemText(i,OUTPUT_LABLE,temp_des2);
		if(isFreshOne)
		{
			break;
		}
	}
	copy_data_to_ptrpanel(TYPE_OUTPUT);
	Invalidate();
	return 0;
}
예제 #17
0
파일: main.cpp 프로젝트: jinshiyi11/TestCpp
/**
* 这是使用 android_native_app_glue
* 的本地应用程序的主要入口点。它在其自己的线程中运行,具有自己的
* 事件循环用于接收输入事件并执行其他操作。
*/
void android_main(struct android_app* state) {
    TestEasyMap::main();

	struct engine engine;

	memset(&engine, 0, sizeof(engine));
	state->userData = &engine;
	state->onAppCmd = engine_handle_cmd;
	state->onInputEvent = engine_handle_input;
	engine.app = state;

    mytest();

	//准备监控加速器
	engine.sensorManager = ASensorManager_getInstance();
	engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
		ASENSOR_TYPE_ACCELEROMETER);
	engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager,
		state->looper, LOOPER_ID_USER, NULL, NULL);

	if (state->savedState != NULL) {
		//我们从之前保存的状态开始;从它还原。
		engine.state = *(struct saved_state*)state->savedState;
	}

	engine.animating = 1;

	//循环等待事情以进行处理。

	while (1) {
		//读取所有挂起的事件。
		int ident;
		int events;
		struct android_poll_source* source;

		//如果没有动态效果,我们将一直阻止等待事件。
		//如果有动态效果,我们进行循环,直到读取所有事件,然后继续
		//绘制动画的下一帧。
		while ((ident = ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events,
			(void**)&source)) >= 0) {

			//处理此事件。
			if (source != NULL) {
				source->process(state, source);
			}

			//如果传感器有数据,立即处理。
			if (ident == LOOPER_ID_USER) {
				if (engine.accelerometerSensor != NULL) {
					ASensorEvent event;
					while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
						&event, 1) > 0) {
						LOGI("accelerometer: x=%f y=%f z=%f",
							event.acceleration.x, event.acceleration.y,
							event.acceleration.z);
					}
				}
			}

			//检查,我们是否存在。
			if (state->destroyRequested != 0) {
				engine_term_display(&engine);
				return;
			}
		}

		if (engine.animating) {
			//事件完成;绘制下一动画帧。
			engine.state.angle += .01f;
			if (engine.state.angle > 1) {
				engine.state.angle = 0;
			}

			//绘图被降低到屏幕更新速率,
			//因此,没有必要在此处计时。
			engine_draw_frame(&engine);
		}
	}
}