//上次 sql 操作影响的记录行数 int DbMysql::affected_rows() { if(!is_connect()){ return -1; } return (int)mysql_affected_rows(conn_); }
UINT _BackFreshing(LPVOID pParam) { T38AI8AO* dlg=(T38AI8AO*)(pParam); Sleep(10*1000); while(1) { if(bPauseMultiRead) continue; if (!is_connect()) { continue; } Sleep(10*1000); bPauseMultiRead=TRUE; for(int i=0;i<3;i++) //Modify by Fance , tstat 6 has more register than 512; { register_critical_section.Lock(); Read_Multi(g_tstat_id,&multi_register_value[i*64],i*64,64); register_critical_section.Unlock(); } bPauseMultiRead=FALSE; memcpy_s(product_register_value,sizeof(product_register_value),multi_register_value,sizeof(multi_register_value)); dlg->InitialDialog(); } return 1; }
void T38AI8AO::Fresh(){ if (is_connect()) { for (int i=0;i<3;i++) { Read_Multi(g_tstat_id,&product_register_value[i*100],i*100,100); } InitialRegister(); InitialDialog(); if(hFirstThread != NULL) TerminateThread(hFirstThread, 0); hFirstThread=NULL; if (!hFirstThread) { hFirstThread = CreateThread(NULL,NULL,_BackFreshing_8IAO,this,NULL,0); } //AfxBeginThread(_BackFreshing,this); } else { SetPaneString(1,_T("Disconnection")); AfxMessageBox(_T("Please Connect your device")); } }
bool CReg_ControlDlg::OnConnect(int comport) { open_com(comport);//open************************************* CString strInfo; if(!is_connect()) { strInfo.Format(_T("COM %d : Not available "), comport); MessageBox(strInfo); return false; } else { strInfo.Format(_T("COM %d Connected: Yes"), comport); MessageBox(strInfo); return true; } }
CString CRegisterViewerDlg::Get_ProductModel(){ CString ModelName=_T(""); if (!is_connect()) { AfxMessageBox(_T("Please Connect to your device,firstly!")); } else { m_modelno=read_one(g_tstat_id,7,20); if (m_modelno>0) { ModelName=GetProductName(m_modelno); } else { AfxMessageBox(_T("Can't read your device")); } } return ModelName; }
void T38AI8AO::Fresh(){ float progress; if (is_connect()) { CDialog_Progess* pDlg = new CDialog_Progess(this,1,100); pDlg->Create(IDD_DIALOG10_Progress, this); pDlg->ShowProgress(0,0); pDlg->ShowWindow(SW_SHOW); RECT RECT_SET1; GetClientRect(&RECT_SET1); pDlg->MoveWindow(RECT_SET1.left+400,RECT_SET1.bottom-19,RECT_SET1.right/2+20,20); for (int i=0;i<3;i++) { if (pDlg!=NULL) { progress=float((i+1)*(100/3)); pDlg->ShowProgress(int(progress),(int)progress); } Read_Multi(g_tstat_id,&product_register_value[i*100],i*100,100); } pDlg->ShowWindow(SW_HIDE); if(pDlg!=NULL) {delete pDlg; pDlg=NULL;} InitialRegister(); InitialDialog(); AfxBeginThread(_BackFreshing,this); } else { SetPaneString(1,_T("Disconnection")); AfxMessageBox(_T("Please Connect your device")); } }
DWORD WINAPI _BackFreshing_8IAO(LPVOID pParam) { T38AI8AO* dlg=(T38AI8AO*)(pParam); Sleep(10*1000); while(1) { if (!is_connect()) { continue; } Sleep(3*1000); for(int i=0;i<3;i++) //Modify by Fance , tstat 6 has more register than 512; { if(g_bPauseMultiRead) { return 0; } Read_Multi(g_tstat_id,&multi_register_value[i*100],i*100,100); } memcpy_s(product_register_value,sizeof(product_register_value),multi_register_value,sizeof(multi_register_value)); dlg->InitialDialog(); } return 1; }
int main() { int i,j,size,temp; FILE *in,*out; in = fopen("milk2.in", "r"); out = fopen ("milk2.out", "w"); fscanf(in, "%d", &size); int start[size]; int end[size]; for (i=0;i<size;i++) { fscanf(in, "%d %d", &start[i],&end[i]); } fclose(in); for (i = (size - 1); i > 0; i--) { for (j = 1; j <= i; j++) { if (start[j-1] > start[j]) { temp = start[j-1]; start[j-1] = start[j]; start[j] = temp; temp = end[j-1]; end[j-1] = end[j]; end[j] = temp; } } } int idle_time=0; int longest_idle_time=0; int milk_time=0; int longest_milk_time=0; int connect_start=0; int connect_end=0; i=0; while (i<size) { int find=0; int tmp_i=i; for (j=i+1;j<size;j++) { if (is_connect(start[i],end[i],start[j],end[j])) { find++; tmp_i=j; if (end[j]>=end[connect_end]) { connect_end=j; } } else if (is_connect(start[i+1],end[i+1],start[connect_start],end[connect_end])) { find++; tmp_i=i+1; } else { break; } } if (find == 0) { milk_time=end[connect_end]-start[connect_start]; if (milk_time > longest_milk_time) { longest_milk_time=milk_time; } if (tmp_i+1<size) { idle_time=start[tmp_i+1]-end[connect_end]; if (idle_time > longest_idle_time) { longest_idle_time=idle_time; } } i=tmp_i+1; connect_start=i; connect_end=i; } else { i=tmp_i; } } fprintf(out,"%d %d\n",longest_milk_time,longest_idle_time); fclose(out); return 0; }
int main() { int i,j,size,temp; FILE *in,*out; in = fopen("milk2.in.sort.part", "r"); out = fopen ("milk2.out", "w"); fscanf(in, "%d", &size); int start[size]; int end[size]; for (i=0;i<size;i++) { fscanf(in, "%d %d", &start[i],&end[i]); } fclose(in); for (i = (size - 1); i > 0; i--) { for (j = 1; j <= i; j++) { if (start[j-1] > start[j]) { temp = start[j-1]; start[j-1] = start[j]; start[j] = temp; temp = end[j-1]; end[j-1] = end[j]; end[j] = temp; } } } int idle_time=0; int longest_idle_time=0; int milk_time=0; int longest_milk_time=0; int connect_start=0; int connect_end=0; i=0; while (i<size) { int find=0; int tmp_i=i; printf("%d %d ",start[i],end[i]); j=i+1; while (j<size) { if (is_connect(start[j],end[j],start[i],end[i])==2) { //printf("%d %d ",start[j],end[j]); find++; tmp_i=j; } else if (is_connect(start[j],end[j],start[i],end[i])==1) { connect_end=j; find++; tmp_i=j; } else { break; } j++; } printf("\n--------------------\n"); if (find == 0) { if (is_connect(start[tmp_i],end[tmp_i],start[connect_start],end[connect_end])==3) { continue; } //printf("\n###############################\n"); printf("connect point: %d: %d(%d) %d(%d)",tmp_i,connect_start,start[connect_start],connect_end,end[connect_end]); milk_time=end[connect_end]-start[connect_start]; printf("-> %d, ",milk_time); if (milk_time > longest_milk_time) { //printf("\n###############################\n"); //printf("longest connect point: %d: %d(%d) %d(%d)",tmp_i,connect_start,start[connect_start],connect_end,end[connect_end]); //printf("-> %d, ",milk_time); //printf("\n###############################\n"); longest_milk_time=milk_time; } if (connect_end+1<size && tmp_i+1<size) { idle_time=start[tmp_i+1]-end[connect_end]; printf("%d\n",idle_time); if (idle_time > longest_idle_time) { //printf("%d\n",idle_time); longest_idle_time=idle_time; //printf("###############################\n"); } } //printf("###############################\n"); i=tmp_i+1; connect_start=i; connect_end=i; } } fprintf(out,"%d %d\n",longest_milk_time,longest_idle_time); fclose(out); return 0; }
int main() { int i,j,size,temp; FILE *in,*out; in = fopen("milk2.in", "r"); out = fopen ("milk2.out", "w"); fscanf(in, "%d", &size); int start[size]; int end[size]; for (i=0;i<size;i++) { fscanf(in, "%d %d", &start[i],&end[i]); } fclose(in); for (i = (size - 1); i > 0; i--) { for (j = 1; j <= i; j++) { if (start[j-1] > start[j]) { temp = start[j-1]; start[j-1] = start[j]; start[j] = temp; temp = end[j-1]; end[j-1] = end[j]; end[j] = temp; } } } int idle_time=0; int longest_idle_time=0; int milk_time=0; int longest_milk_time=0; int connect_start=0; int connect_end=0; i=0; while (i<size) { int find=0; int tmp_i=i; for (j=i+1;j<size;j++) { if (is_connect(start[i],end[i],start[j],end[j])) { printf("who connect: (%d %d) ",i,j); printf("([%d,%d],[%d,%d])",start[i],end[i],start[j],end[j]); find++; tmp_i=j; if (i>connect_end && j>connect_end) { if (end[i]>end[j]) { connect_end=i; } else { connect_end=j; } } } else { break; } } printf("\n-------------------\n"); i=tmp_i; if (find > 0) { continue; } else { printf("connect point: %d: %d %d\n",i,connect_start,connect_end); milk_time=end[connect_end]-start[connect_start]; printf("time: %d: %d ",i,milk_time); if (milk_time > longest_milk_time) { longest_milk_time=milk_time; } if (connect_end+1<size && i+1<size) { idle_time=start[i+1]-end[connect_end]; printf("%d\n",idle_time); if (idle_time > longest_idle_time) { longest_idle_time=idle_time; } } i++; connect_start=i; connect_end=i; } } fprintf(out,"%d %d\n",longest_milk_time,longest_idle_time); fclose(out); return 0; }
virtual ~inquiry_abstruct(){if(is_connect())disconnect();}
const inquiry_abstruct& operator=(inquiry_abstruct&& My_) { hmLib_assert(!is_connect(),connected_exception,"inquiry_abstruct have already connected"); std::swap(ConnectFlag, My_.ConnectFlag); return *this; }
void disconnect(void){ hmLib_assert(is_connect(),unconnected_exception,"inquiry_abstruct have no connection"); *ConnectFlag=false; }
connection create_connection(void){ hmLib_assert(!is_connect(),connected_exception,"inquiry_abstruct have already connected"); //参照してる人がまだいれば、新たに作成 if(!ConnectFlag || !ConnectFlag.unique())ConnectFlag.reset(new bool(true)); return connection(ConnectFlag); }