//------------------------------------------------------------------------------ static int SYSRAM_Flush( struct file* pFile, fl_owner_t Id) { MUINT32 Index = 0; MUINT32 Sec = 0,USec = 0; MUINT64 Time64 = 0; SYSRAM_PROC_STRUCT* pProc; // SYSRAM_GetTime(&Time64, &Sec, &USec); // LOG_MSG("Cur:Name(%s),pid(%d),tgid(%d),Time(%ld.%06ld)", current->comm, current->pid, current->tgid, Sec, USec); // if(pFile->private_data != NULL) { pProc = (SYSRAM_PROC_STRUCT *)pFile->private_data; // if( pProc->Pid != 0 || pProc->Tgid != 0 || pProc->Table != 0) { // LOG_WRN("Proc:Name(%s),pid(%d),tgid(%d),Table(0x%08lX),Time(%ld.%06ld)", pProc->ProcName, pProc->Pid, pProc->Tgid, pProc->Table, pProc->TimeS, pProc->TimeUS); // if( pProc->Tgid == 0 && pProc->Table != 0) { LOG_ERR("No Tgid info"); /* LOG_ERR("Cur:Name(%s),pid(%d),tgid(%d),Time(%ld.%06ld)", current->comm, current->pid, current->tgid, Sec, USec); LOG_ERR("Proc:Name(%s),pid(%d),tgid(%d),Table(0x%08lX),Time(%ld.%06ld)", pProc->ProcName, pProc->Pid, pProc->Tgid, pProc->Table, pProc->TimeS, pProc->TimeUS); */ } else if( (pProc->Tgid == current->tgid) || ((pProc->Tgid != current->tgid) && (strcmp(current->comm, "binder") == 0))) { if(pProc->Table) { LOG_WRN("Force to release"); /* LOG_WRN("Cur:Name(%s),pid(%d),tgid(%d),Time(%ld.%06ld)", current->comm, current->pid, current->tgid, Sec, USec); */ SYSRAM_DumpLayout(); // for(Index = 0 ; Index < SYSRAM_USER_AMOUNT; Index++) { if(pProc->Table & (1 << Index)) { SYSRAM_IOC_Free((SYSRAM_USER_ENUM)Index); } } // pProc->Table= 0; } } } } else { LOG_WRN("private_data is NULL"); /* LOG_WRN("Cur:Name(%s),pid(%d),tgid(%d),Time(%ld.%06ld)", current->comm, current->pid, current->tgid, Sec, USec); */ } // return 0; }
void ConditionalHistogramCanvas::PopulateCanvas() { LOG_MSG("Entering ConditionalHistogramCanvas::PopulateCanvas"); BOOST_FOREACH( GdaShape* shp, selectable_shps ) { delete shp; } selectable_shps.clear(); int t = var_info[HIST_VAR].time; double x_min = 0; double x_max = left_pad_const + right_pad_const + interval_width_const * cur_intervals + + interval_gap_const * (cur_intervals-1); // orig_x_pos is the center of each histogram bar std::vector<double> orig_x_pos(cur_intervals); for (int i=0; i<cur_intervals; i++) { orig_x_pos[i] = left_pad_const + interval_width_const/2.0 + i * (interval_width_const + interval_gap_const); } shps_orig_xmin = x_min; shps_orig_xmax = x_max; shps_orig_ymin = 0; shps_orig_ymax = (scale_y_over_time ? overall_max_num_obs_in_ival : max_num_obs_in_ival[t]); if (show_axes) { axis_scale_y = AxisScale(0, shps_orig_ymax, 3); shps_orig_ymax = axis_scale_y.scale_max; y_axis = new GdaAxis("Frequency", axis_scale_y, wxRealPoint(0,0), wxRealPoint(0, shps_orig_ymax), -9, 0); axis_scale_x = AxisScale(0, max_ival_val[t]); //shps_orig_xmax = axis_scale_x.scale_max; axis_scale_x.data_min = min_ival_val[t]; axis_scale_x.data_max = max_ival_val[t]; axis_scale_x.scale_min = axis_scale_x.data_min; axis_scale_x.scale_max = axis_scale_x.data_max; double range = axis_scale_x.scale_max - axis_scale_x.scale_min; LOG(axis_scale_x.data_max); axis_scale_x.scale_range = range; axis_scale_x.p = floor(log10(range)); axis_scale_x.ticks = cur_intervals+1; axis_scale_x.tics.resize(axis_scale_x.ticks); axis_scale_x.tics_str.resize(axis_scale_x.ticks); axis_scale_x.tics_str_show.resize(axis_scale_x.tics_str.size()); for (int i=0; i<axis_scale_x.ticks; i++) { axis_scale_x.tics[i] = axis_scale_x.data_min + range*((double) i)/((double) axis_scale_x.ticks-1); wxString flt = wxString::Format("%.2g", axis_scale_x.tics[i]); axis_scale_x.tics_str[i] = flt.ToStdString(); axis_scale_x.tics_str_show[i] = false; } int tick_freq = ceil(((double) cur_intervals)/5.0); for (int i=0; i<axis_scale_x.ticks; i++) { if (i % tick_freq == 0) { axis_scale_x.tics_str_show[i] = true; } } axis_scale_x.tic_inc = axis_scale_x.tics[1]-axis_scale_x.tics[0]; x_axis = new GdaAxis(GetNameWithTime(2), axis_scale_x, wxRealPoint(0,0), wxRealPoint(shps_orig_xmax, 0), 0, 9); } selectable_shps.resize(vert_num_cats * horiz_num_cats * cur_intervals); int i=0; for (int r=0; r<vert_num_cats; r++) { for (int c=0; c<horiz_num_cats; c++) { for (int ival=0; ival<cur_intervals; ival++) { double x0 = orig_x_pos[ival] - interval_width_const/2.0; double x1 = orig_x_pos[ival] + interval_width_const/2.0; double y0 = 0; double y1 = cell_data[t][r][c].ival_obs_cnt[ival]; selectable_shps[i] = new GdaRectangle(wxRealPoint(x0, 0), wxRealPoint(x1, y1)); int sz = GdaConst::qualitative_colors.size(); selectable_shps[i]-> setPen(GdaConst::qualitative_colors[ival%sz]); selectable_shps[i]-> setBrush(GdaConst::qualitative_colors[ival%sz]); i++; } } } virtual_screen_marg_top = 25; virtual_screen_marg_bottom = 70; virtual_screen_marg_left = 70; virtual_screen_marg_right = 25; if (show_axes) { virtual_screen_marg_bottom += 25; virtual_screen_marg_left += 25; } ResizeSelectableShps(); LOG_MSG("Exiting ConditionalHistogramCanvas::PopulateCanvas"); }
ConditionalHistogramFrame::~ConditionalHistogramFrame() { LOG_MSG("In ConditionalHistogramFrame::~ConditionalHistogramFrame"); DeregisterAsActive(); }
//---------------------------------------------------------------------------- MBOOL ResMgrHalImp::Init(void) { MBOOL Result = MTRUE; RES_MGR_DRV_LOCK_STRUCT LockInfo; // Mutex::Autolock lock(mLock); // LOG_MSG("mInitCount(%d)",mInitCount); // if(mInitCount > 0) { android_atomic_inc(&mInitCount); goto EXIT; } // if(mpDrv == NULL) { mpDrv = ResMgrDrv::CreateInstance(); } // if(mpDrv != NULL) { if(mpDrv->Init()) { LockInfo.ResMask = RES_MGR_DRV_RES_ISP; LockInfo.PermanentMask = LockInfo.ResMask; LockInfo.Timeout = RES_MGR_HAL_LOCK_TIMEOUT; if(mpDrv->LockRes(&LockInfo)) { LOG_MSG("lock ISP OK"); } else { LOG_ERR("lock ISP fail"); Result = MFALSE; } } else { LOG_ERR("mpDrv init fai"); Result = MFALSE; } } else { LOG_ERR("mpDrv is NULL"); Result = MFALSE; } // if(MdpDrvInit() < 0) { LOG_ERR("MdpDrvInit() fail"); MdpDrvRelease(); Result = MFALSE; } // mModeInfo.Mode = RES_MGR_HAL_MODE_NONE; mModeInfo.ModeSub = RES_MGR_HAL_MODE_SUB_NONE; mModeInfo.Dev = RES_MGR_HAL_DEV_NONE; // android_atomic_inc(&mInitCount); // EXIT: return Result; }
/** Implementation of TimeStateObserver interface */ void ConditionalHistogramFrame::update(TimeState* o) { LOG_MSG("In ConditionalHistogramFrame::update(TimeState* o)"); template_canvas->TimeChange(); UpdateTitle(); }
int SsbSipH264DecodeExe(void *openHandle, long lengthBufFill) { _MFCLIB_H264_DEC *pCTX; MFC_ARGS mfc_args; BOOL r; //////////////////////////////// // Input Parameter Checking // //////////////////////////////// if (openHandle == NULL) { LOG_MSG(LOG_ERROR, "SsbSipH264DecodeExe", "openHandle is NULL\n"); return SSBSIP_H264_DEC_RET_ERR_INVALID_HANDLE; } if ((lengthBufFill < 0) || (lengthBufFill > 0x100000)) { LOG_MSG(LOG_ERROR, "SsbSipH264DecodeExe", "lengthBufFill is invalid. (lengthBufFill=%d)\n", lengthBufFill); return SSBSIP_H264_DEC_RET_ERR_INVALID_PARAM; } pCTX = (_MFCLIB_H264_DEC *) openHandle; if (!pCTX->fInit) { ///////////////////////////////////////////////// ///// (DeviceIoControl) ///// ///// IOCTL_MFC_H264_DEC_EXE ///// ///////////////////////////////////////////////// mfc_args.dec_init.in_strmSize = lengthBufFill; r = DeviceIoControl(pCTX->hOpen, IOCTL_MFC_H264_DEC_INIT, &mfc_args, sizeof(MFC_ARGS), NULL, 0, NULL, NULL); if ((r == FALSE) || (mfc_args.get_buf_addr.ret_code != 0)) { return SSBSIP_H264_DEC_RET_ERR_CONFIG_FAIL; } // Output argument (width , height) pCTX->width = mfc_args.dec_init.out_width; pCTX->height = mfc_args.dec_init.out_height; pCTX->fInit = 1; return SSBSIP_H264_DEC_RET_OK; } ///////////////////////////////////////////////// ///// (DeviceIoControl) ///// ///// IOCTL_MFC_H264_DEC_EXE ///// ///////////////////////////////////////////////// mfc_args.dec_exe.in_strmSize = lengthBufFill; r = DeviceIoControl(pCTX->hOpen, IOCTL_MFC_H264_DEC_EXE, &mfc_args, sizeof(MFC_ARGS), NULL, 0, NULL, NULL); if ((r == FALSE) || (mfc_args.dec_exe.ret_code != 0)) { return SSBSIP_H264_DEC_RET_ERR_DECODE_FAIL; } return SSBSIP_H264_DEC_RET_OK; }
//---------------------------------------------------------------------------- MBOOL ResMgrHalImp::SetMode(RES_MGR_HAL_MODE_STRUCT* pModeInfo) { MBOOL Result = MTRUE; struct MdpPathStnrParameter StnrParam; // Mutex::Autolock lock(mLock); // LOG_MSG("Mode(%d), ModeSub(%d), Dev(%d)",pModeInfo->Mode,pModeInfo->ModeSub,pModeInfo->Dev); // if(mInitCount <= 0) { LOG_ERR("Please init first!"); Result = MFALSE; goto EXIT; } // if( mModeInfo.Mode == pModeInfo->Mode && mModeInfo.ModeSub == pModeInfo->ModeSub && mModeInfo.Dev == pModeInfo->Dev) { LOG_MSG("Current Mode(%d), ModeSub(%d), Dev(%d) are already set.",mModeInfo.Mode,mModeInfo.ModeSub,mModeInfo.Dev); goto EXIT; } //ResMgrDrv if( pModeInfo->Dev == RES_MGR_HAL_DEV_CAM || pModeInfo->Dev == RES_MGR_HAL_DEV_VT) { if(mModeInfo.Mode != pModeInfo->Mode) { if(!mpDrv->SetBWC((RES_MGR_DRV_MODE_ENUM)(pModeInfo->Mode))) { Result = MFALSE; goto EXIT; } // switch(pModeInfo->Mode) { case RES_MGR_HAL_MODE_NONE: { Result = mpDrv->SetSysramSwitchbank(MTRUE); if(!Result) { goto EXIT; } // Result = mpDrv->CloseTvout(MFALSE); if(!Result) { goto EXIT; } // Result = mpDrv->CloseHdmi(MFALSE); if(!Result) { goto EXIT; } // Result = LockMdpBrz(MFALSE); if(!Result) { goto EXIT; } break; } case RES_MGR_HAL_MODE_PREVIEW_OFF: case RES_MGR_HAL_MODE_PREVIEW_ON: case RES_MGR_HAL_MODE_CAPTURE_OFF: case RES_MGR_HAL_MODE_CAPTURE_ON: case RES_MGR_HAL_MODE_VIDEO_REC_OFF: case RES_MGR_HAL_MODE_VIDEO_REC_ON: { Result = mpDrv->SetSysramSwitchbank(MFALSE); if(!Result) { goto EXIT; } // Result = mpDrv->CloseTvout(MTRUE); if(!Result) { goto EXIT; } // Result = mpDrv->CloseHdmi(MTRUE); if(!Result) { goto EXIT; } // Result = LockMdpBrz(MTRUE); if(!Result) { goto EXIT; } break; } default: { LOG_ERR("Unknown Mode(%d)",pModeInfo->Mode); Result = MFALSE; goto EXIT; } } } // if(mModeInfo.ModeSub != pModeInfo->ModeSub) { switch(pModeInfo->ModeSub) { case RES_MGR_HAL_MODE_SUB_NONE: { Result = LockMdpCrz(MFALSE); if(!Result) { goto EXIT; } break; } case RES_MGR_HAL_MODE_SUB_ISP2MEM: { switch(pModeInfo->Mode) { case RES_MGR_HAL_MODE_CAPTURE_ON: { Result = LockMdpCrz(MTRUE); if(!Result) { goto EXIT; } break; } case RES_MGR_HAL_MODE_NONE: case RES_MGR_HAL_MODE_PREVIEW_OFF: case RES_MGR_HAL_MODE_PREVIEW_ON: case RES_MGR_HAL_MODE_CAPTURE_OFF: case RES_MGR_HAL_MODE_VIDEO_REC_OFF: case RES_MGR_HAL_MODE_VIDEO_REC_ON: { Result = LockMdpCrz(MFALSE); if(!Result) { goto EXIT; } break; } default: { LOG_ERR("Unknown Mode(%d)",pModeInfo->Mode); break; } } break; } default: { LOG_ERR("Unknown ModeSub(%d)",pModeInfo->ModeSub); Result = MFALSE; goto EXIT; } } } } else if(pModeInfo->Dev == RES_MGR_HAL_DEV_ATV) { if(mModeInfo.Mode != pModeInfo->Mode) { //Lock BRZ switch(pModeInfo->Mode) { case RES_MGR_HAL_MODE_NONE: { Result = LockMdpBrz(MFALSE); if(!Result) { goto EXIT; } // Result = mpDrv->CloseHdmi(MFALSE); if(!Result) { goto EXIT; } break; } case RES_MGR_HAL_MODE_PREVIEW_OFF: case RES_MGR_HAL_MODE_PREVIEW_ON: case RES_MGR_HAL_MODE_CAPTURE_OFF: case RES_MGR_HAL_MODE_CAPTURE_ON: case RES_MGR_HAL_MODE_VIDEO_REC_OFF: case RES_MGR_HAL_MODE_VIDEO_REC_ON: { Result = LockMdpBrz(MTRUE); if(!Result) { goto EXIT; } // Result = mpDrv->CloseHdmi(MTRUE); if(!Result) { goto EXIT; } break; } default: { LOG_ERR("Unknown Mode(%d)",pModeInfo->Mode); Result = MFALSE; goto EXIT; } } } } // mModeInfo.Mode = pModeInfo->Mode; mModeInfo.ModeSub = pModeInfo->ModeSub; mModeInfo.Dev = pModeInfo->Dev; EXIT: LOG_MSG("Result(%d)",Result); return Result; }
void CorrelParamsFrame::OnApplyBtn(wxCommandEvent& ev) { int vc_sel = var_choice->GetSelection(); if (vc_sel < 0) return; LOG_MSG("In CorrelParamsFrame::OnApplyBtn"); { long new_bins = bins_spn_ctrl->GetValue(); if (new_bins < CorrelParams::min_bins_cnst) { new_bins = CorrelParams::min_bins_cnst; } if (new_bins > CorrelParams::max_bins_cnst) { new_bins = CorrelParams::max_bins_cnst; } correl_params.bins = new_bins; } { wxString s = dist_choice->GetStringSelection(); if (s == "Euclidean Distance") { correl_params.dist_metric = WeightsMetaInfo::DM_euclidean; } else if (s == "Arc Distance (mi)") { correl_params.dist_metric = WeightsMetaInfo::DM_arc; correl_params.dist_units = WeightsMetaInfo::DU_mile; } else if (s == "Arc Distance (km)") { correl_params.dist_metric = WeightsMetaInfo::DM_arc; correl_params.dist_units = WeightsMetaInfo::DU_km; } } bool use_thresh = thresh_cbx->GetValue(); double thresh_val = 0; if (use_thresh) { thresh_val = GetThreshMax(); wxString val = thresh_tctrl->GetValue(); val.Trim(false); val.Trim(true); double t; bool is_valid = val.ToDouble(&t); if (is_valid) { thresh_val = t; } else { use_thresh = false; } } if (all_pairs_rad->GetValue() == true) { correl_params.method = CorrelParams::ALL_PAIRS; if (use_thresh) { correl_params.method = CorrelParams::ALL_PAIRS_THRESH; correl_params.threshold = thresh_val; } } else { correl_params.method = CorrelParams::RAND_SAMP; if (use_thresh) { correl_params.method = CorrelParams::RAND_SAMP_THRESH; correl_params.threshold = thresh_val; } wxString s = max_iter_tctrl->GetValue(); long v; long revert_val = correl_params.max_iterations; bool apply_revert = true; if (s.ToLong(&v)) { if (v > CorrelParams::max_iter_cnst) { revert_val = CorrelParams::max_iter_cnst; correl_params.max_iterations = CorrelParams::max_iter_cnst; } else { correl_params.max_iterations = v; apply_revert = false; } } if (apply_revert) { wxString sf; sf << revert_val; max_iter_tctrl->ChangeValue(sf); } } bool valid_variable = true; { // update var_man with new selection wxString var_nm = var_choice->GetString(vc_sel); TableInterface* table_int = project->GetTableInt(); int col_id = table_int->FindColId(var_nm); wxString var_man_nm0 = var_man.GetName(0); if (vc_sel >= 0 && col_id >= 0) { if (var_man.GetVarsCount() > 0 && var_man_nm0 != "" && var_man_nm0 != var_nm) { var_man.RemoveVar(0); } if (var_man.GetVarsCount() == 0) { int time = project->GetTimeState()->GetCurrTime(); std::vector<double> min_vals; std::vector<double> max_vals; table_int->GetMinMaxVals(col_id, min_vals, max_vals); for (int i=0; i<min_vals.size(); i++) { if (min_vals[0] ==0 && max_vals[0] == 0) { valid_variable = false; break; } } var_man.AppendVar(var_nm, min_vals, max_vals, time); } double mean = 0; double var = 0; vector<double> vals; table_int->GetColData(col_id, 0, vals); CorrelogramAlgs::GetSampMeanAndVar(vals, mean, var); if (var <= 0) { wxString msg = "Please check your variable, e.g. make sure it is not a constant."; wxString title = "Variable Value Error"; wxMessageDialog dlg (this, msg, title, wxOK | wxICON_ERROR); dlg.ShowModal(); valid_variable = false; } } } int var_man_cnt = var_man.GetVarsCount(); LOG(var_man_cnt); if (var_man_cnt) LOG(var_man.GetName(0)); notifyObservers(); }
CorrelParamsFrame::CorrelParamsFrame(const CorrelParams& correl_params, GdaVarTools::Manager& var_man, Project* project_) : wxFrame((wxWindow*) 0, wxID_ANY, "Correlogram Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE), CorrelParamsObservable(correl_params, var_man), project(project_), var_txt(0), var_choice(0), dist_txt(0), dist_choice(0), bins_txt(0), bins_spn_ctrl(0), thresh_cbx(0), thresh_tctrl(0), thresh_slider(0), all_pairs_rad(0), est_pairs_txt(0), est_pairs_num_txt(0), rand_samp_rad(0), max_iter_txt(0), max_iter_tctrl(0), help_btn(0), apply_btn(0) { LOG_MSG("Entering CorrelParamsFrame::CorrelParamsFrame"); wxPanel* panel = new wxPanel(this); panel->SetBackgroundColour(*wxWHITE); SetBackgroundColour(*wxWHITE); { var_txt = new wxStaticText(panel, XRCID("ID_VAR_TXT"), "Variable:"); var_choice = new wxChoice(panel, XRCID("ID_VAR_CHOICE"), wxDefaultPosition,wxSize(160,-1)); wxString var_nm = ""; if (var_man.GetVarsCount() > 0) var_nm = var_man.GetName(0); UpdateVarChoiceFromTable(var_nm); Connect(XRCID("ID_VAR_CHOICE"), wxEVT_CHOICE, wxCommandEventHandler(CorrelParamsFrame::OnVarChoiceSelected)); } wxBoxSizer* var_h_szr = new wxBoxSizer(wxHORIZONTAL); var_h_szr->Add(var_txt, 0, wxALIGN_CENTER_VERTICAL); var_h_szr->AddSpacer(5); var_h_szr->Add(var_choice, 0, wxALIGN_CENTER_VERTICAL); dist_txt = new wxStaticText(panel, XRCID("ID_DIST_TXT"), "Distance:"); dist_choice = new wxChoice(panel, XRCID("ID_DIST_CHOICE"), wxDefaultPosition, wxSize(160,-1)); dist_choice->Append("Euclidean Distance"); dist_choice->Append("Arc Distance (mi)"); dist_choice->Append("Arc Distance (km)"); if (correl_params.dist_metric == WeightsMetaInfo::DM_arc) { if (correl_params.dist_units == WeightsMetaInfo::DU_km) { dist_choice->SetSelection(2); } else { dist_choice->SetSelection(1); } } else { dist_choice->SetSelection(0); } Connect(XRCID("ID_DIST_CHOICE"), wxEVT_CHOICE, wxCommandEventHandler(CorrelParamsFrame::OnDistanceChoiceSelected)); wxBoxSizer* dist_h_szr = new wxBoxSizer(wxHORIZONTAL); dist_h_szr->Add(dist_txt, 0, wxALIGN_CENTER_VERTICAL); dist_h_szr->AddSpacer(5); dist_h_szr->Add(dist_choice, 0, wxALIGN_CENTER_VERTICAL); { bins_txt = new wxStaticText(panel, XRCID("ID_BINS_TXT"), "Number Bins:"); wxString vs; vs << correl_params.bins; bins_spn_ctrl = new wxSpinCtrl(panel, XRCID("ID_BINS_SPN_CTRL"), vs, wxDefaultPosition, wxSize(75,-1), wxSP_ARROW_KEYS | wxTE_PROCESS_ENTER, CorrelParams::min_bins_cnst, CorrelParams::max_bins_cnst, correl_params.bins); Connect(XRCID("ID_BINS_SPN_CTRL"), wxEVT_SPINCTRL, wxSpinEventHandler(CorrelParamsFrame::OnBinsSpinEvent)); Connect(XRCID("ID_BINS_SPN_CTRL"), wxEVT_TEXT_ENTER, wxCommandEventHandler(CorrelParamsFrame::OnBinsTextCtrl)); } wxBoxSizer* bins_h_szr = new wxBoxSizer(wxHORIZONTAL); bins_h_szr->Add(bins_txt, 0, wxALIGN_CENTER_VERTICAL); bins_h_szr->AddSpacer(5); bins_h_szr->Add(bins_spn_ctrl, 0, wxALIGN_CENTER_VERTICAL); thresh_cbx = new wxCheckBox(panel, XRCID("ID_THRESH_CBX"), "Max Distance:"); thresh_cbx->SetValue(false); thresh_tctrl = new wxTextCtrl(panel, XRCID("ID_THRESH_TCTRL"), "", wxDefaultPosition, wxSize(100,-1), wxTE_PROCESS_ENTER); thresh_tctrl->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); thresh_tctrl->Enable(false); //UpdateThreshTctrlVal(); Connect(XRCID("ID_THRESH_CBX"), wxEVT_CHECKBOX, wxCommandEventHandler(CorrelParamsFrame::OnThreshCheckBox)); Connect(XRCID("ID_THRESH_TCTRL"), wxEVT_TEXT_ENTER, wxCommandEventHandler(CorrelParamsFrame::OnThreshTextCtrl)); wxBoxSizer* thresh_h_szr = new wxBoxSizer(wxHORIZONTAL); thresh_h_szr->Add(thresh_cbx, 0, wxALIGN_CENTER_VERTICAL); thresh_h_szr->AddSpacer(5); thresh_h_szr->Add(thresh_tctrl, 0, wxALIGN_CENTER_VERTICAL); thresh_slider = new wxSlider(panel, XRCID("ID_THRESH_SLDR"), sldr_tcks/2, 0, sldr_tcks, wxDefaultPosition, wxSize(180,-1)); Connect(XRCID("ID_THRESH_SLDR"), wxEVT_SLIDER, wxCommandEventHandler(CorrelParamsFrame::OnThreshSlider)); thresh_slider->Enable(false); wxBoxSizer* thresh_sld_h_szr = new wxBoxSizer(wxHORIZONTAL); thresh_sld_h_szr->Add(thresh_slider, 0, wxALIGN_CENTER_VERTICAL); wxBoxSizer* thresh_v_szr = new wxBoxSizer(wxVERTICAL); thresh_v_szr->Add(thresh_h_szr, 0, wxBOTTOM, 5); thresh_v_szr->Add(thresh_sld_h_szr, 0, wxALIGN_CENTER_HORIZONTAL); all_pairs_rad = new wxRadioButton(panel, XRCID("ID_ALL_PAIRS_RAD"), "All Pairs", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_VERTICAL | wxRB_GROUP); all_pairs_rad->SetValue(correl_params.method == CorrelParams::ALL_PAIRS); Connect(XRCID("ID_ALL_PAIRS_RAD"), wxEVT_RADIOBUTTON, wxCommandEventHandler(CorrelParamsFrame::OnAllPairsRadioSelected)); est_pairs_txt = new wxStaticText(panel, XRCID("ID_EST_PAIRS_TXT"), "Estimated Pairs:"); est_pairs_num_txt = new wxStaticText(panel, XRCID("ID_EST_PAIRS_NUM_TXT"), "4,000,000"); wxBoxSizer* est_pairs_h_szr = new wxBoxSizer(wxHORIZONTAL); est_pairs_h_szr->Add(est_pairs_txt, 0, wxALIGN_CENTER_VERTICAL); est_pairs_h_szr->AddSpacer(5); est_pairs_h_szr->Add(est_pairs_num_txt, 0, wxALIGN_CENTER_VERTICAL); wxBoxSizer* all_pairs_v_szr = new wxBoxSizer(wxVERTICAL); all_pairs_v_szr->Add(all_pairs_rad); all_pairs_v_szr->AddSpacer(2); all_pairs_v_szr->Add(est_pairs_h_szr, 0, wxLEFT, 18); rand_samp_rad = new wxRadioButton(panel, XRCID("ID_RAND_SAMP_RAD"), "Random Sample", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_VERTICAL); rand_samp_rad->SetValue(correl_params.method != CorrelParams::ALL_PAIRS); Connect(XRCID("ID_RAND_SAMP_RAD"), wxEVT_RADIOBUTTON, wxCommandEventHandler(CorrelParamsFrame::OnRandSampRadioSelected)); max_iter_txt = new wxStaticText(panel, XRCID("ID_MAX_ITER_TXT"), "Sample Size:"); { wxString vs; vs << correl_params.max_iterations; max_iter_tctrl = new wxTextCtrl(panel, XRCID("ID_MAX_ITER_TCTRL"), vs, wxDefaultPosition, wxSize(100,-1), wxTE_PROCESS_ENTER); max_iter_tctrl->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); Connect(XRCID("ID_MAX_ITER_TCTRL"), wxEVT_TEXT_ENTER, wxCommandEventHandler(CorrelParamsFrame::OnMaxIterTextCtrl)); } wxBoxSizer* max_iter_h_szr = new wxBoxSizer(wxHORIZONTAL); max_iter_h_szr->Add(max_iter_txt, 0, wxALIGN_CENTER_VERTICAL); max_iter_h_szr->AddSpacer(8); max_iter_h_szr->Add(max_iter_tctrl, 0, wxALIGN_CENTER_VERTICAL); wxBoxSizer* rand_samp_v_szr = new wxBoxSizer(wxVERTICAL); rand_samp_v_szr->Add(rand_samp_rad); rand_samp_v_szr->AddSpacer(2); rand_samp_v_szr->Add(max_iter_h_szr, 0, wxLEFT, 18); help_btn = new wxButton(panel, XRCID("ID_HELP_BTN"), "Help", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); apply_btn = new wxButton(panel, XRCID("ID_APPLY_BTN"), "Apply", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); Connect(XRCID("ID_HELP_BTN"), wxEVT_BUTTON, wxCommandEventHandler(CorrelParamsFrame::OnHelpBtn)); Connect(XRCID("ID_APPLY_BTN"), wxEVT_BUTTON, wxCommandEventHandler(CorrelParamsFrame::OnApplyBtn)); wxBoxSizer* btns_h_szr = new wxBoxSizer(wxHORIZONTAL); btns_h_szr->Add(help_btn, 0, wxALIGN_CENTER_VERTICAL); btns_h_szr->AddSpacer(15); btns_h_szr->Add(apply_btn, 0, wxALIGN_CENTER_VERTICAL); UpdateEstPairs(); // Arrange above widgets in panel using sizers. // Top level panel sizer will be panel_h_szr // Below that will be panel_v_szr // panel_v_szr will directly receive widgets wxBoxSizer* panel_v_szr = new wxBoxSizer(wxVERTICAL); panel_v_szr->Add(var_h_szr, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); panel_v_szr->AddSpacer(2); panel_v_szr->Add(dist_h_szr, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); panel_v_szr->AddSpacer(3); panel_v_szr->Add(bins_h_szr, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); panel_v_szr->AddSpacer(3); panel_v_szr->Add(thresh_v_szr, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); panel_v_szr->Add(all_pairs_v_szr, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); panel_v_szr->AddSpacer(5); panel_v_szr->Add(rand_samp_v_szr, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); panel_v_szr->AddSpacer(10); panel_v_szr->Add(btns_h_szr, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxBoxSizer* panel_h_szr = new wxBoxSizer(wxHORIZONTAL); panel_h_szr->Add(panel_v_szr, 1, wxEXPAND); panel->SetSizer(panel_h_szr); // Top Sizer for Frame wxBoxSizer* top_h_sizer = new wxBoxSizer(wxHORIZONTAL); top_h_sizer->Add(panel, 1, wxEXPAND|wxALL, 8); SetSizerAndFit(top_h_sizer); wxCommandEvent ev; if (project->GetNumRecords() > 5000) OnRandSampRadioSelected(ev); else OnAllPairsRadioSelected(ev); Show(true); LOG_MSG("Exiting CorrelParamsFrame::CorrelParamsFrame"); }
CorrelParamsFrame::~CorrelParamsFrame() { LOG_MSG("In CorrelParamsFrame::~CorrelParamsFrame"); notifyObserversOfClosing(); }
void CorrelParamsFrame::OnHelpBtn(wxCommandEvent& ev) { LOG_MSG("In CorrelParamsFrame::OnHelpBtn"); WebViewHelpWin* win = new WebViewHelpWin(project, GetHelpPageHtml(), NULL, wxID_ANY, "Correlogram Parameters Help", wxDefaultPosition, wxSize(500,500)); }
static void write_p64(Bitu port,Bitu val,Bitu iolen) { if (keyb.reset) return; switch (val) { case 0x20: /* read command byte */ /* TODO: If biosps2=true and aux=false, mask AUX port bits as if AUX isn't there */ KEYBOARD_Add8042Response( (keyb.cb_xlat << 6) | ((!keyb.auxactive) << 5) | ((!keyb.active) << 4) | (keyb.cb_sys << 2) | (keyb.cb_irq12 << 1) | (keyb.cb_irq1?1:0)); break; case 0x60: keyb.command=CMD_SETCOMMAND; break; case 0x90: case 0x91: case 0x92: case 0x93: case 0x94: case 0x95: case 0x96: case 0x97: case 0x98: case 0x99: case 0x9a: case 0x9b: case 0x9c: case 0x9d: case 0x9e: case 0x9f: /* TODO: If bit 0 == 0, trigger system reset */ break; case 0xa7: /* disable aux */ /* TODO: If biosps2=true and aux=false do not respond */ if (keyb.enable_aux) { //keyb.auxactive=false; //LOG(LOG_KEYBOARD,LOG_NORMAL)("AUX De-Activated"); } break; case 0xa8: /* enable aux */ /* TODO: If biosps2=true and aux=false do not respond */ if (keyb.enable_aux) { keyb.auxactive=true; if (keyb.used && !keyb.scheduled && !keyb.p60changed) { keyb.scheduled=true; PIC_AddEvent(KEYBOARD_TransferBuffer,KEYDELAY); } LOG(LOG_KEYBOARD,LOG_NORMAL)("AUX Activated"); } break; case 0xa9: /* mouse interface test */ /* TODO: If biosps2=true and aux=false do not respond */ KEYBOARD_Add8042Response(0x00); /* OK */ break; case 0xaa: /* Self test */ keyb.active=false; /* on real h/w it also seems to disable the keyboard */ KEYBOARD_Add8042Response(0xaa); /* OK */ break; case 0xab: /* interface test */ keyb.active=false; /* on real h/w it also seems to disable the keyboard */ KEYBOARD_Add8042Response(0x00); /* no error */ break; case 0xae: /* Activate keyboard */ keyb.active=true; if (keyb.used && !keyb.scheduled && !keyb.p60changed) { keyb.scheduled=true; PIC_AddEvent(KEYBOARD_TransferBuffer,KEYDELAY); } LOG(LOG_KEYBOARD,LOG_NORMAL)("Activated"); break; case 0xad: /* Deactivate keyboard */ keyb.active=false; LOG(LOG_KEYBOARD,LOG_NORMAL)("De-Activated"); break; case 0xc0: /* read input buffer */ KEYBOARD_Add8042Response(0x40); break; case 0xd0: /* Outport on buffer */ KEYBOARD_SetPort60((MEM_A20_Enabled() ? 0x02 : 0) | 0x01/*some programs read the output port then write it back*/); break; case 0xd1: /* Write to outport */ keyb.command=CMD_SETOUTPORT; break; case 0xd2: /* write output register */ keyb.command=CMD_WRITEOUTPUT; break; case 0xd3: /* write AUX output */ if (keyb.enable_aux) keyb.command=CMD_WRITEAUXOUT; else if (aux_warning++ == 0) LOG(LOG_KEYBOARD,LOG_ERROR)("Program is writing 8042 AUX. If you intend to use PS/2 mouse emulation you may consider adding aux=1 to your dosbox.conf"); break; case 0xd4: /* send byte to AUX */ if (keyb.enable_aux) keyb.command=CMD_WRITEAUX; else if (aux_warning++ == 0) LOG(LOG_KEYBOARD,LOG_ERROR)("Program is writing 8042 AUX. If you intend to use PS/2 mouse emulation you may consider adding aux=1 to your dosbox.conf"); break; case 0xe0: /* read test port */ KEYBOARD_Add8042Response(0x00); break; case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7: case 0xf8: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xfd: case 0xfe: case 0xff: /* pulse output register */ if (!(val & 1)) { if (allow_keyb_reset) { LOG_MSG("Restart by keyboard controller requested\n"); On_Software_CPU_Reset(); } else { LOG_MSG("WARNING: Keyboard output port written (pulsed) with bit 1 clear. Is the guest OS or application attempting to reset the system?\n"); } } break; default: LOG(LOG_KEYBOARD,LOG_ERROR)("Port 64 write with val %d",(int)val); break; } }
static void write_p60(Bitu port,Bitu val,Bitu iolen) { switch (keyb.command) { case CMD_NONE: /* None */ if (keyb.reset) return; /* No active command this would normally get sent to the keyboard then */ KEYBOARD_ClrBuffer(); switch (val) { case 0xed: /* Set Leds */ keyb.command=CMD_SETLEDS; KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ break; case 0xee: /* Echo */ KEYBOARD_AddBuffer(0xee); /* JC: The correct response is 0xEE, not 0xFA */ break; case 0xf0: /* set scancode set */ keyb.command=CMD_SETSCANSET; KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ break; case 0xf2: /* Identify keyboard */ KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ KEYBOARD_AddBuffer(0xab); /* ID */ KEYBOARD_AddBuffer(0x83); break; case 0xf3: /* Typematic rate programming */ keyb.command=CMD_SETTYPERATE; KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ break; case 0xf4: /* Enable keyboard,clear buffer, start scanning */ LOG(LOG_KEYBOARD,LOG_NORMAL)("Clear buffer, enable scanning"); KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ keyb.scanning=true; break; case 0xf5: /* Reset keyboard and disable scanning */ LOG(LOG_KEYBOARD,LOG_NORMAL)("Reset, disable scanning"); keyb.scanning=false; KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ break; case 0xf6: /* Reset keyboard and enable scanning */ LOG(LOG_KEYBOARD,LOG_NORMAL)("Reset, enable scanning"); keyb.scanning=true; /* JC: Original DOSBox code was wrong, this command enables scanning */ KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ break; case 0xff: /* keyboard resets take a long time (about 250ms), most keyboards flash the LEDs during reset */ KEYBOARD_Reset(); KEYBOARD_Add8042Response(0xFA); /* ACK */ KEYBOARD_Add8042Response(0xAA); /* SELF TEST OK (TODO: Need delay!) */ keyb.reset=true; KEYBOARD_SetLEDs(7); /* most keyboard I test with tend to flash the LEDs during reset */ PIC_AddEvent(KEYBOARD_ResetDelay,RESETDELAY); break; default: /* Just always acknowledge strange commands */ LOG(LOG_KEYBOARD,LOG_ERROR)("60:Unhandled command %X",(int)val); KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ } return; case CMD_SETSCANSET: keyb.command=CMD_NONE; if (val == 0) { /* just asking */ if (keyb.cb_xlat) { switch (keyb.scanset) { case 1: KEYBOARD_AddBuffer(0x43); break; case 2: KEYBOARD_AddBuffer(0x41); break; case 3: KEYBOARD_AddBuffer(0x3F); break; } } else { KEYBOARD_AddBuffer(keyb.scanset); } KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ } else { KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ KEYBOARD_AddBuffer(0xfa); /* Acknowledge again */ if (val > 3) val = 3; keyb.scanset = val; } break; case CMD_WRITEAUX: keyb.command=CMD_NONE; KEYBOARD_AUX_Write(val); break; case CMD_WRITEOUTPUT: keyb.command=CMD_NONE; KEYBOARD_ClrBuffer(); KEYBOARD_AddBuffer(val); /* and now you return the byte as if it were typed in */ break; case CMD_WRITEAUXOUT: KEYBOARD_AddBuffer(AUX|val); /* stuff into AUX output */ break; case CMD_SETOUTPORT: if (!(val & 1)) { if (allow_keyb_reset) { LOG_MSG("Restart by keyboard controller requested\n"); On_Software_CPU_Reset(); } else { LOG_MSG("WARNING: Keyboard output port written with bit 1 clear. Is the guest OS or application attempting to reset the system?\n"); } } MEM_A20_Enable((val & 2)>0); keyb.command = CMD_NONE; break; case CMD_SETTYPERATE: if (keyb.reset) return; { static const int delay[] = { 250, 500, 750, 1000 }; static const int repeat[] = { 33,37,42,46,50,54,58,63,67,75,83,92,100, 109,118,125,133,149,167,182,200,217,233, 250,270,303,333,370,400,435,476,500 }; keyb.repeat.pause = delay[(val >> 5) & 3]; keyb.repeat.rate = repeat[val & 0x1f]; keyb.command = CMD_NONE; KEYBOARD_ClrBuffer(); KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ } break; case CMD_SETLEDS: if (keyb.reset) return; keyb.command=CMD_NONE; KEYBOARD_ClrBuffer(); KEYBOARD_AddBuffer(0xfa); /* Acknowledge */ KEYBOARD_SetLEDs(val&7); break; case CMD_SETCOMMAND: /* 8042 command, not keyboard */ /* TODO: If biosps2=true and aux=false, disallow the guest OS from changing AUX port parameters including IRQ */ keyb.command=CMD_NONE; keyb.cb_xlat = (val >> 6) & 1; keyb.auxactive = !((val >> 5) & 1); keyb.active = !((val >> 4) & 1); keyb.cb_sys = (val >> 2) & 1; keyb.cb_irq12 = (val >> 1) & 1; keyb.cb_irq1 = (val >> 0) & 1; if (keyb.used && !keyb.scheduled && !keyb.p60changed && keyb.active) { keyb.scheduled=true; PIC_AddEvent(KEYBOARD_TransferBuffer,KEYDELAY); } break; } }
void Update_CDC_TRansfert(void) { unsigned int dep, length, add_dest; uint8_t *dest; if ((SCD.Status_CDC & 0x08) == 0) return; switch (CDC.RS0 & 0x0700) { case 0x0200: // MAIN CPU case 0x0300: // SUB CPU // Data ready in host port CDC.RS0 |= 0x4000; return; break; case 0x0400: // PCM RAM dest = (unsigned char *) Ram_PCM; dep = ((CDC.DMA_Adr & 0x03FF) << 2) + PCM_Chip.Bank; add_dest = 2; break; case 0x0500: // PRG RAM dest = &Ram_Prg.u8[0]; dep = (CDC.DMA_Adr & 0xFFFF) << 3; add_dest = 2; LOG_MSG(lc89510, LOG_MSG_LEVEL_DEBUG1, "DMA transfert PRG RAM : adr = %.8X", dep); break; case 0x0700: // WORD RAM if (Ram_Word_State >= 2) { dest = &Ram_Word_1M.u8[0]; add_dest = 2; if (Ram_Word_State & 1) dep = ((CDC.DMA_Adr & 0x3FFF) << 3); else dep = ((CDC.DMA_Adr & 0x3FFF) << 3) + 0x20000; } else { dest = &Ram_Word_2M.u8[0]; dep = ((CDC.DMA_Adr & 0x7FFF) << 3); add_dest = 2; } break; default: return; } if (CDC.DBC.N <= (CDC_DMA_SPEED * 2)) { length = (CDC.DBC.N + 1) >> 1; SCD.Status_CDC &= ~0x08; // Last transfert CDC.RS0 |= 0x8000; // End data transfert CDC.RS0 &= ~0x4000; // no more data ready CDC.IFSTAT |= 0x08; // No more data transfert in progress // DTEIEN = Data Trasnfert End Interrupt Enable ? if (CDC.IFCTRL & 0x40) { CDC.IFSTAT &= ~0x40; if (Int_Mask_S68K & 0x20) sub68k_interrupt (5, -1); LOG_MSG(lc89510, LOG_MSG_LEVEL_DEBUG1, "CDC - DTE interrupt"); } }
/** * vdraw_ddraw_init(): Initialize the DirectDraw video subsystem. * @return 0 on success; non-zero on error. */ int vdraw_ddraw_init(void) { DDSURFACEDESC2 ddsd; vdraw_ddraw_end(); mdp_render_t *rendMode = get_mdp_render_t(); const int scale = rendMode->scale; // Determine the window size using the scaling factor. if (scale <= 0) return -1; const int w = 320 * scale; const int h = 240 * scale; if (vdraw_get_fullscreen()) { Res_X = w; Res_Y = h; } // Return value. int rval; // Initialize DirectDraw. // TODO: Initialize DirectDraw on the monitor with most of Gens/GS onscreen. LPDIRECTDRAW lpDD_Init; rval = DirectDrawCreate(NULL, &lpDD_Init, NULL); if (FAILED(rval)) { LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "DirectDrawCreate() failed: 0x%08X", rval); return -2; } rval = lpDD_Init->QueryInterface(IID_IDirectDraw7, (LPVOID*)&lpDD); if (FAILED(rval)) { if (lpDD_Init) lpDD_Init->Release(); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDD_Init->QueryInterface(IID_IDirectDraw4) failed: 0x%08X", rval); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "This can usually be fixed by upgrading DirectX."); return -3; } // Free the DirectDraw initialization object. lpDD_Init->Release(); // Set the cooperative level. vdraw_ddraw_set_cooperative_level(); // TODO: 15-bit color override. ("Force 555" or "Force 565" in the config file.) memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); // TODO: Figure out what FS_No_Res_Change is for. // TODO: Figure out if this is correct. if (vdraw_get_fullscreen() /* && !FS_No_Res_Change*/) { // Use the color depth setting. // NOTE: "15-bit" color requires 16-bit to be specified. rval = lpDD->SetDisplayMode(Res_X, Res_Y, (bppOut == 15 ? 16 : bppOut), 0, 0); if (FAILED(rval)) { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDD->SetDisplayMode() failed: 0x%08X", rval); // If render mode is set to Normal, try using Double instead. if (rendMode_FS == RenderMgr::begin() && rendMode_FS != RenderMgr::end()) { LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "Renderer is set to Normal; attempting to use Double instead."); rendMode_FS++; vdraw_set_renderer(rendMode_FS); vdraw_text_write("Normal rendering failed. Using Double.", 1500); Sync_Gens_Window_GraphicsMenu(); } return -4; } } #if 0 // Check the current color depth. unsigned char newBpp; lpDD->GetDisplayMode(&ddsd); switch (ddsd.ddpfPixelFormat.dwGBitMask) { case 0x03E0: // 15-bit color. newBpp = 15; break; case 0x07E0: // 16-bit color. newBpp = 16; break; case 0x00FF00: default: // 32-bit color. newBpp = 32; break; } if (newBpp != bppOut) vdraw_set_bpp(newBpp, false); #endif // Clear ddsd. memset(&ddsd, 0x00, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); if (vdraw_get_fullscreen() && Video.VSync_FS) { ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.dwBackBufferCount = 2; } else { ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; } // Create the primary surface. rval = lpDD->CreateSurface(&ddsd, &lpDDS_Primary, NULL); if (FAILED(rval)) { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDD->CreateSurface(&lpDDS_Primary) failed: 0x%08X", rval); return -5; } if (vdraw_get_fullscreen()) { if (Video.VSync_FS) { ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; rval = lpDDS_Primary->GetAttachedSurface(&ddsd.ddsCaps, &lpDDS_Flip); if (FAILED(rval)) { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDDS_Primary->GetAttachSurface() failed: 0x%08X", rval); return -6; } lpDDS_Blit = lpDDS_Flip; } else { lpDDS_Blit = lpDDS_Primary; } } else { rval = lpDD->CreateClipper(0, &lpDDC_Clipper, NULL); if (FAILED(rval)) { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDD->CreateClipper() failed: 0x%08X", rval); return -7; } rval = lpDDC_Clipper->SetHWnd(0, gens_window); if (FAILED(rval)) { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDDC_Clipper->SetHWnd() failed: 0x%08X", rval); return -8; } rval = lpDDS_Primary->SetClipper(lpDDC_Clipper); if (FAILED(rval)) { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDDC_Primary->SetClipper() failed: 0x%08X", rval); return -9; } } // Clear ddsd again. memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; // Determine the width and height. // NOTE: For DirectDraw, the actual 336 width is used. if (vdraw_ddraw_is_hw_render()) { // Normal render mode. 320x240 [336x240] ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; ddsd.dwWidth = 336; ddsd.dwHeight = 240; } else { // Larger than 1x. ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; ddsd.dwWidth = w; ddsd.dwHeight = h; } // Set the pixel format. ddsd.dwFlags |= DDSD_PIXELFORMAT; ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; ddsd.ddpfPixelFormat.dwFourCC = 0; // RGB ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0; // Bits per component. switch (bppOut) { case 15: // 15-bit color. (555) ddsd.ddpfPixelFormat.dwRGBBitCount = 16; ddsd.ddpfPixelFormat.dwRBitMask = 0x7C00; ddsd.ddpfPixelFormat.dwGBitMask = 0x03E0; ddsd.ddpfPixelFormat.dwBBitMask = 0x001F; break; case 16: // 16-bit color. (555) ddsd.ddpfPixelFormat.dwRGBBitCount = 16; ddsd.ddpfPixelFormat.dwRBitMask = 0xF800; ddsd.ddpfPixelFormat.dwGBitMask = 0x07E0; ddsd.ddpfPixelFormat.dwBBitMask = 0x001F; break; case 32: default: // 32-bit color. ddsd.ddpfPixelFormat.dwRGBBitCount = 32; ddsd.ddpfPixelFormat.dwRBitMask = 0xFF0000; ddsd.ddpfPixelFormat.dwGBitMask = 0x00FF00; ddsd.ddpfPixelFormat.dwBBitMask = 0x0000FF; break; } // Create the back surface. rval = lpDD->CreateSurface(&ddsd, &lpDDS_Back, NULL); if (FAILED(rval)) { // Failed to create the back surface. // If we attempted to create it in video memory, try system memory instead. if (ddsd.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) { LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDD->CreateSurface(&lpDDS_Back, DDSCAPS_VIDEOMEMORY) failed: 0x%08X", rval); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "Attempting to use DDSCAPS_SYSTEMMEMORY instead."); ddsd.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY; ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; rval = lpDD->CreateSurface(&ddsd, &lpDDS_Back, NULL); if (FAILED(rval)) { // Failed to create the back surface in system memory. vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDD->CreateSurface(&lpDDS_Back, DDSCAPS_SYSTEMMEMORY) failed: 0x%08X", rval); return -10; } } else { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDD->CreateSurface(&lpDDS_Back, DDSCAPS_SYSTEMMEMORY) failed: 0x%08X", rval); return -11; } } // TODO: Check if this is right. // I think this might be causing the frame counter flicker in full screen mode. //if (!vdraw_get_fullscreen() || (rendMode >= 1 && (/*FS_No_Res_Change ||*/ Res_X != 640 || Res_Y != 480))) if (!vdraw_get_fullscreen() || !vdraw_ddraw_is_hw_render()) lpDDS_Blit = lpDDS_Back; if (vdraw_ddraw_is_hw_render()) { // Normal rendering mode uses MD_Screen directly. memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); // TODO: This causes issues if the selected color depth isn't the // same as the desktop color depth. This only affects windowed mode, // since in fullscreen, the desktop color depth is changed. rval = lpDDS_Back->GetSurfaceDesc(&ddsd); if (FAILED(rval)) { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDDS_Back->GetSurfaceDesc() failed: 0x%08X", rval); return -12; } ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_LPSURFACE | DDSD_PIXELFORMAT; ddsd.dwWidth = 336; ddsd.dwHeight = 240; if (ddsd.ddpfPixelFormat.dwRGBBitCount > 16) { // 32-bit color. ddsd.lpSurface = MD_Screen.u32; ddsd.lPitch = 336 * 4; } else { // 15-bit or 16-bit color. ddsd.lpSurface = MD_Screen.u16; ddsd.lPitch = 336 * 2; } rval = lpDDS_Back->SetSurfaceDesc(&ddsd, 0); if (FAILED(rval)) { vdraw_ddraw_free_all(false); LOG_MSG(video, LOG_MSG_LEVEL_ERROR, "lpDDS_Back->SetSurfaceDesc() failed: 0x%08X", rval); return -13; } } // Initialize the destination rectangle. vdraw_ddraw_adjust_RectDest(); // Reset the render mode. vdraw_reset_renderer(false); // Synchronize menus. Sync_Gens_Window(); // vdraw_ddraw initialized. return 0; }
bool SocketClient::Connect(const char* hostname, uint16_t port) { static bool networkInited = false; // Initing networking if is not inited. if (!networkInited) { WSADATA wsaData; networkInited = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0); if (!networkInited) return false; } addrinfo *result = NULL; addrinfo hints; LOG_MSG("Host: %s, port: %d\n", hostname, port); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; std::stringstream converter; converter << port; // Resolve the server address and port int res = getaddrinfo(hostname, converter.str().c_str(), &hints, &result); if (res != 0) return false; // Attempt to connect to an address until one succeeds for (addrinfo *it = result; it != NULL; it = it->ai_next) { LOG_MSG("Addr: %u.%u.%u.%u\n", it->ai_addr->sa_data[2] & 0xFF, it->ai_addr->sa_data[3] & 0xFF, it->ai_addr->sa_data[4] & 0xFF, it->ai_addr->sa_data[5] & 0xFF); // Create a SOCKET for connecting to server socketHandle = socket(it->ai_family, it->ai_socktype, it->ai_protocol); if (socketHandle == INVALID_SOCKET) return false; // Connect to server. res = connect(socketHandle, it->ai_addr, static_cast<int>(it->ai_addrlen)); if (res == SOCKET_ERROR) { Close(); continue; } break; } freeaddrinfo(result); return socketHandle != INVALID_SOCKET; }
int SsbSipH264DecodeGetConfig(void *openHandle, H264_DEC_CONF conf_type, void *value) { _MFCLIB_H264_DEC *pCTX; MFC_ARGS mfc_args; BOOL r; //////////////////////////////// // Input Parameter Checking // //////////////////////////////// if (openHandle == NULL) { LOG_MSG(LOG_ERROR, "SsbSipH264DecodeGetConfig", "openHandle is NULL\n"); return SSBSIP_H264_DEC_RET_ERR_INVALID_HANDLE; } if (value == NULL) { LOG_MSG(LOG_ERROR, "SsbSipH264DecodeGetConfig", "value is NULL\n"); return SSBSIP_H264_DEC_RET_ERR_INVALID_PARAM; } pCTX = (_MFCLIB_H264_DEC *) openHandle; switch (conf_type) { case H264_DEC_GETCONF_STREAMINFO: ((SSBSIP_H264_STREAM_INFO *)value)->width = pCTX->width; ((SSBSIP_H264_STREAM_INFO *)value)->height = pCTX->height; break; case H264_DEC_GETCONF_PHYADDR_FRAM_BUF: ///////////////////////////////////////////////// ///// (DeviceIoControl) ///// ///// IOCTL_MFC_GET_FRAM_BUF_ADDR ///// ///////////////////////////////////////////////// // mfc_args.get_buf_addr.in_usr_data = pCTX->proc_id; r = DeviceIoControl(pCTX->hOpen, IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR, &mfc_args, sizeof(MFC_ARGS), NULL, 0, NULL, NULL); if ((r == FALSE) || (mfc_args.get_buf_addr.ret_code != 0)) { LOG_MSG(LOG_ERROR, "SsbSipH264DecodeGetConfig", "Error in H264_DEC_GETCONF_PHYADDR_FRAM_BUF.\n"); return SSBSIP_H264_DEC_RET_ERR_GETCONF_FAIL; } // Output arguments ((unsigned int*) value)[0] = mfc_args.get_buf_addr.out_buf_addr; ((unsigned int*) value)[1] = mfc_args.get_buf_addr.out_buf_size; break; case H264_DEC_GETCONF_FRAM_NEED_COUNT: mfc_args.get_config.in_config_param = MFC_GET_CONFIG_DEC_FRAME_NEED_COUNT; mfc_args.get_config.out_config_value[0] = 0; mfc_args.get_config.out_config_value[1] = 0; r = DeviceIoControl(pCTX->hOpen, IOCTL_MFC_GET_CONFIG, &mfc_args, sizeof(MFC_ARGS), NULL, 0, NULL, NULL); if ((r == FALSE) || (mfc_args.get_config.ret_code != 0)) { LOG_MSG(LOG_ERROR, "SsbSipH264DecodeGetConfig", "Error in H264_DEC_GETCONF_FRAM_NEED_COUNT.\n"); return SSBSIP_H264_DEC_RET_ERR_GETCONF_FAIL; } // Output arguments ((unsigned int*) value)[0] = mfc_args.get_config.out_config_value[0]; break; default: LOG_MSG(LOG_ERROR, "SsbSipH264DecodeGetConfig", "No such conf_type is supported.\n"); return SSBSIP_H264_DEC_RET_ERR_GETCONF_FAIL; } return SSBSIP_H264_DEC_RET_OK; }
void MainWindow::buttonClick_field_constituent(QAbstractButton* button) { LOG_MSG("buttonClick_field_constituent"); field->setFieldConstituent(button); }
void DOS_Shell::ParseLine(char * line) { LOG(LOG_EXEC,LOG_ERROR)("Parsing command line: %s",line); /* Check for a leading @ */ if (line[0] == '@') line[0] = ' '; line = trim(line); /* Do redirection and pipe checks */ char * in = 0; char * out = 0; Bit16u dummy,dummy2; Bit32u bigdummy = 0; Bitu num = 0; /* Number of commands in this line */ bool append; bool normalstdin = false; /* wether stdin/out are open on start. */ bool normalstdout = false; /* Bug: Assumed is they are "con" */ num = GetRedirection(line,&in, &out,&append); if (num>1) LOG_MSG("SHELL:Multiple command on 1 line not supported"); if (in || out) { normalstdin = (psp->GetFileHandle(0) != 0xff); normalstdout = (psp->GetFileHandle(1) != 0xff); } if (in) { if(DOS_OpenFile(in,OPEN_READ,&dummy)) { //Test if file exists DOS_CloseFile(dummy); LOG_MSG("SHELL:Redirect input from %s",in); if(normalstdin) DOS_CloseFile(0); //Close stdin DOS_OpenFile(in,OPEN_READ,&dummy); //Open new stdin } } if (out){ LOG_MSG("SHELL:Redirect output to %s",out); if(normalstdout) DOS_CloseFile(1); if(!normalstdin && !in) DOS_OpenFile("con",OPEN_READWRITE,&dummy); bool status = true; /* Create if not exist. Open if exist. Both in read/write mode */ if(append) { if( (status = DOS_OpenFile(out,OPEN_READWRITE,&dummy)) ) { DOS_SeekFile(1,&bigdummy,DOS_SEEK_END); } else { status = DOS_CreateFile(out,DOS_ATTR_ARCHIVE,&dummy); //Create if not exists. } } else { status = DOS_OpenFileExtended(out,OPEN_READWRITE,DOS_ATTR_ARCHIVE,0x12,&dummy,&dummy2); } if(!status && normalstdout) DOS_OpenFile("con",OPEN_READWRITE,&dummy); //Read only file, open con again if(!normalstdin && !in) DOS_CloseFile(0); } /* Run the actual command */ DoCommand(line); /* Restore handles */ if(in) { DOS_CloseFile(0); if(normalstdin) DOS_OpenFile("con",OPEN_READWRITE,&dummy); free(in); } if(out) { DOS_CloseFile(1); if(!normalstdin) DOS_OpenFile("con",OPEN_READWRITE,&dummy); if(normalstdout) DOS_OpenFile("con",OPEN_READWRITE,&dummy); if(!normalstdin) DOS_CloseFile(0); free(out); } }
void MainWindow::buttonClick_plane(QAbstractButton* button) { LOG_MSG("buttonClick_plane"); field->setPlane(button); }
//---------------------------------------------------------------------------- MBOOL ResMgrHalImp::LockMdpCrz(MBOOL Lock) { MBOOL Result = MTRUE; struct MdpPathStnrParameter StnrParam; // //LOG_MSG("Lock(%d)",Lock); // if(mInitCount <= 0) { LOG_ERR("Please init first!"); Result = MFALSE; goto EXIT; } // if(Lock) { if(mLockMdpCrz) { LOG_MSG("CRZ has been locked"); } else { StnrParam.b_crz_use_line_buffer = 0; StnrParam.b_prz0_use_line_buffer = 1; StnrParam.b_prz1_use_line_buffer = 1; // if(mMdpPathStnr.Config(&StnrParam) < 0)//Config { LOG_ERR("CRZ:Config() fail"); Result = MFALSE; goto EXIT; } // if(mMdpPathStnr.Start(NULL) < 0)//Execute { LOG_ERR("CRZ:Start() fail"); Result = MFALSE; goto EXIT; } mLockMdpCrz = MTRUE; LOG_MSG("CRZ locked OK"); } } else { if(mLockMdpCrz) { if(mMdpPathStnr.End(NULL) < 0) //Release resource { LOG_ERR("CRZ:End() fail"); } mLockMdpCrz = MFALSE; LOG_MSG("CRZ unlocked OK"); } else { LOG_MSG("CRZ has been unlocked"); } } // EXIT: //LOG_MSG("Result(%d)",Result); return Result; }
void MainWindow::buttonClick_canvas(QAbstractButton* button) { LOG_MSG("buttonClick_canvas"); }
/*Traces the translator stack on the given underlying node until it finds the first translator called `name` and returns the port pointing to the translator sitting under this one.*/ error_t trace_find (mach_port_t underlying, const char *name, int flags, mach_port_t * port) { error_t err = 0; /*Identity information about the current process */ uid_t *uids; size_t nuids; gid_t *gids; size_t ngids; /*The name and arguments of the translator being passed now */ char *argz = NULL; size_t argz_len = 0; /*The current working directory */ char *cwd = NULL; /*The port to the directory containing the file pointed to by `underlying` */ file_t dir; /*The unauthenticated version of `dir` */ file_t unauth_dir; /*The control port of the current translator */ fsys_t fsys; /*The port to the translator we are currently looking at */ mach_port_t node = underlying; /*The port to the previous translator */ mach_port_t prev_node = MACH_PORT_NULL; /*The retry name and retry type returned by fsys_getroot */ string_t retry_name; retry_type retry; /*Finalizes the execution of this function */ void finalize (void) { /*If there is a working directory, free it */ if (cwd) free (cwd); /*If the ports to the directory exist */ if (dir) PORT_DEALLOC (dir); } /*finalize */ /*Obtain the current working directory */ cwd = getcwd (NULL, 0); if (!cwd) { LOG_MSG ("trace_find: Could not obtain cwd."); return EINVAL; } LOG_MSG ("trace_find: cwd: '%s'", cwd); /*Open a port to this directory */ dir = file_name_lookup (cwd, 0, 0); if (!dir) { finalize (); return ENOENT; } /*Try to get the number of effective UIDs */ nuids = geteuids (0, 0); if (nuids < 0) { finalize (); return EINVAL; } /*Allocate some memory for the UIDs on the stack */ uids = alloca (nuids * sizeof (uid_t)); /*Fetch the UIDs themselves */ nuids = geteuids (nuids, uids); if (nuids < 0) { finalize (); return EINVAL; } /*Try to get the number of effective GIDs */ ngids = getgroups (0, 0); if (ngids < 0) { finalize (); return EINVAL; } /*Allocate some memory for the GIDs on the stack */ gids = alloca (ngids * sizeof (gid_t)); /*Fetch the GIDs themselves */ ngids = getgroups (ngids, gids); if (ngids < 0) { finalize (); return EINVAL; } /*Obtain the unauthenticated version of `dir` */ err = io_restrict_auth (dir, &unauth_dir, 0, 0, 0, 0); if (err) { finalize (); return err; } char buf[256]; char *_buf = buf; size_t len = 256; io_read (node, &_buf, &len, 0, len); LOG_MSG ("trace_find: Read from underlying: '%s'", buf); /*Go up the translator stack */ for (; !err;) { /*retreive the name and options of the current translator */ err = file_get_fs_options (node, &argz, &argz_len); if (err) break; LOG_MSG ("trace_find: Obtained translator '%s'", argz); if (strcmp (argz, name) == 0) { LOG_MSG ("trace_find: Match. Stopping here."); break; } /*try to fetch the control port for this translator */ err = file_get_translator_cntl (node, &fsys); LOG_MSG ("trace_find: err = %d", (int) err); if (err) break; LOG_MSG ("trace_find: Translator control port: %lu", (unsigned long) fsys); prev_node = node; /*fetch the root of the translator */ err = fsys_getroot (fsys, unauth_dir, MACH_MSG_TYPE_COPY_SEND, uids, nuids, gids, ngids, flags | O_NOTRANS, &retry, retry_name, &node); LOG_MSG ("trace_find: fsys_getroot returned %d", (int) err); LOG_MSG ("trace_find: Translator root: %lu", (unsigned long) node); /*TODO: Remove this debug output. */ /*char buf[256]; char * _buf = buf; size_t len = 256; io_read(node, &_buf, &len, 0, len); LOG_MSG("trace_find: Read: '%s'", buf); */ } /*If the error occurred (most probably) because of the fact that we have reached the top of the translator stack */ if ((err == EMACH_SEND_INVALID_DEST) || (err == ENXIO)) /*this is OK */ err = 0; /*Return the port to read from */ *port = prev_node; /*Return the result of operations */ finalize (); return err; } /*trace_find */
void MainWindow::textEdited_fraction(QString text) { LOG_MSG("textEdited_fraction"); field->setFraction(text); }
ConditionalHistogramCanvas::~ConditionalHistogramCanvas() { LOG_MSG("In ConditionalHistogramCanvas::~ConditionalHistogramCanvas"); }
//----------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- void Field::chooseFieldColor(double c, double cmin, double cmax, bool use_logscale, int rgbcol[]) { double f, denom, logcmin, logc; int rgb_lo[3], rgb_hi[3], i; bool copy_scell = false; if (copy_scell) { rgbcol[0] = 0; if (cmax > 0) { rgbcol[1] = 255*min(c,cmax)/cmax; rgbcol[2] = 255*min(c,cmax)/cmax; } else { rgbcol[1] = 0; rgbcol[2] = 0; } return; } if (use_logscale) { if (cmin == cmax) { f = 1; } else { // if (cmin > 0.0001) // logcmin = log(cmin); // else // logcmin = 1.0e6; // if (c > 0.0001) // logc = log(c); // else // logc = 1.0e6; cmin = max(cmin, 0.00001); c = max(c, 0.00001); denom = (log(cmax) - log(cmin)); if (denom < 0.001) f = 1; else f = (log(c) - log(cmin))/denom; } } else { f = c/cmax; } // if (cell_constituent == OXYGEN) { if (field_constituent == OXYGEN) { rgb_hi[0] = 0; rgb_hi[1] = 0; rgb_hi[2] = 0; rgb_lo[0] = 255; rgb_lo[1] = 0; rgb_lo[2] = 0; for (i=0; i<3; i++) { rgbcol[i] = int((1-f)*rgb_lo[i] + f*rgb_hi[i]); if (rgbcol[i] < 0 || rgbcol[i] > 255) { sprintf(msg,"chooseFieldColor: %f %f %f %f %d %d",c,cmin,cmax,f,i,rgbcol[i]); LOG_MSG(msg); exit(1); } } } else { rgb_hi[0] = 0; rgb_hi[1] = 255; rgb_hi[2] = 255; rgb_lo[0] = 0; rgb_lo[1] = 0; rgb_lo[2] = 0; for (i=0; i<3; i++) { rgbcol[i] = int((1-f)*rgb_lo[i] + f*rgb_hi[i]); if (rgbcol[i] < 0 || rgbcol[i] > 255) { sprintf(msg,"chooseFieldColor: %f %f %f %f %d %d",c,cmin,cmax,f,i,rgbcol[i]); LOG_MSG(msg); exit(1); } } } }
/** based on horiz_cat_data, vert_cat_data, num_time_vals, data_min_over_time, data_max_over_time, cur_intervals, scale_x_over_time: calculate interval breaks and populate obs_id_to_sel_shp, ival_obs_cnt and ival_obs_sel_cnt */ void ConditionalHistogramCanvas::InitIntervals() { LOG_MSG("Entering ConditionalHistogramCanvas::InitIntervals"); std::vector<bool>& hs = highlight_state->GetHighlight(); // determine correct ivals for each obs in current time period min_ival_val.resize(num_time_vals); max_ival_val.resize(num_time_vals); max_num_obs_in_ival.resize(num_time_vals); overall_max_num_obs_in_ival = 0; for (int t=0; t<num_time_vals; t++) max_num_obs_in_ival[t] = 0; ival_breaks.resize(boost::extents[num_time_vals][cur_intervals-1]); for (int t=0; t<num_time_vals; t++) { if (scale_x_over_time) { min_ival_val[t] = data_min_over_time; max_ival_val[t] = data_max_over_time; } else { min_ival_val[t] = data_sorted[t][0].first; max_ival_val[t] = data_sorted[t][num_obs-1].first; } if (min_ival_val[t] == max_ival_val[t]) { if (min_ival_val[t] == 0) { max_ival_val[t] = 1; } else { max_ival_val[t] += fabs(max_ival_val[t])/2.0; } } double range = max_ival_val[t] - min_ival_val[t]; double ival_size = range/((double) cur_intervals); for (int i=0; i<cur_intervals-1; i++) { ival_breaks[t][i] = min_ival_val[t]+ival_size*((double) (i+1)); } } obs_id_to_sel_shp.resize(boost::extents[num_time_vals][num_obs]); cell_data.resize(num_time_vals); for (int t=0; t<num_time_vals; t++) { int vt = var_info[VERT_VAR].time_min; if (var_info[VERT_VAR].sync_with_global_time) vt += t; int ht = var_info[HOR_VAR].time_min; if (var_info[HOR_VAR].sync_with_global_time) ht += t; int rows = vert_cat_data.categories[vt].cat_vec.size(); int cols = horiz_cat_data.categories[ht].cat_vec.size(); cell_data[t].resize(boost::extents[rows][cols]); for (int r=0; r<rows; r++) { for (int c=0; c<cols; c++) { cell_data[t][r][c].ival_obs_cnt.resize(cur_intervals); cell_data[t][r][c].ival_obs_sel_cnt.resize(cur_intervals); cell_data[t][r][c].ival_to_obs_ids.resize(cur_intervals); for (int i=0; i<cur_intervals; i++) { cell_data[t][r][c].ival_obs_cnt[i] = 0; cell_data[t][r][c].ival_obs_sel_cnt[i] = 0; cell_data[t][r][c].ival_to_obs_ids[i].clear(); } } } int dt = var_info[HIST_VAR].time_min; if (var_info[HIST_VAR].sync_with_global_time) dt += t; // record each obs in the correct cell and ival. for (int i=0, cur_ival=0; i<num_obs; i++) { while (cur_ival <= cur_intervals-2 && data_sorted[dt][i].first >= ival_breaks[t][cur_ival]) { cur_ival++; } int id = data_sorted[dt][i].second; int r = vert_cat_data.categories[vt].id_to_cat[id]; int c = horiz_cat_data.categories[ht].id_to_cat[id]; obs_id_to_sel_shp[t][id] = cell_to_sel_shp_gen(r, c, cur_ival, cols, cur_intervals); //LOG_MSG(wxString::Format("obs_id: %d -> shp_id: %d", id, // obs_id_to_sel_shp[t][id])); cell_data[t][r][c].ival_to_obs_ids[cur_ival]. push_front(data_sorted[dt][i].second); cell_data[t][r][c].ival_obs_cnt[cur_ival]++; if (cell_data[t][r][c].ival_obs_cnt[cur_ival] > max_num_obs_in_ival[t]) { max_num_obs_in_ival[t] = cell_data[t][r][c].ival_obs_cnt[cur_ival]; if (max_num_obs_in_ival[t] > overall_max_num_obs_in_ival) { overall_max_num_obs_in_ival = max_num_obs_in_ival[t]; } } if (hs[data_sorted[dt][i].second]) { cell_data[t][r][c].ival_obs_sel_cnt[cur_ival]++; } } } /* for (int t=0; t<num_time_vals; t++) { int vt = var_info[VERT_VAR].time_min; if (var_info[VERT_VAR].sync_with_global_time) vt += t; int ht = var_info[HOR_VAR].time_min; if (var_info[HOR_VAR].sync_with_global_time) ht += t; int rows = vert_cat_data.categories[vt].cat_vec.size(); int cols = horiz_cat_data.categories[ht].cat_vec.size(); LOG_MSG(wxString::Format("time %d:", t)); LOG_MSG(wxString::Format("min_ival_val: %f", min_ival_val[t])); LOG_MSG(wxString::Format("max_ival_val: %f", max_ival_val[t])); for (int r=0; r<rows; r++) { for (int c=0; c<cols; c++) { for (int i=0; i<cur_intervals; i++) { wxString s = "cell_data[%d][%d][%d].ival_obs_cnt[%d] = %d"; LOG_MSG(wxString::Format(s, t, r, c, i, cell_data[t][r][c].ival_obs_cnt[i])); } } } } */ /* for (int i=0; i<num_obs; i++) { int t=0; wxString s; int shp_id = obs_id_to_sel_shp[t][i]; s << "obs_id: " << i << " -> " << "shp_id: " << shp_id; int r, c, ival; sel_shp_to_cell_gen(shp_id, r, c, ival, horiz_num_cats, cur_intervals); s << " -> " << "row: " << r << ", col: " << c; s << " ival: " << ival; s << " -> shp_id: " << cell_to_sel_shp_gen(r, c, ival, horiz_num_cats, cur_intervals); LOG_MSG(s); } */ LOG_MSG("Exiting ConditionalHistogramCanvas::InitIntervals"); }
//----------------------------------------------------------------------------------------- // New version, site/cell size is fixed, the blob grows //----------------------------------------------------------------------------------------- void Field::displayField(int hr, int *res) { // QGraphicsScene* scene = new QGraphicsScene(QRect(0, 0, CANVAS_WIDTH, CANVAS_WIDTH)); QBrush brush; int i, k, ix, iy, iz, w, rgbcol[3], ichemo, ixyz; double xp, yp, x, y, d, C, cmin, cmax, rmax, valmin; double a, b, Wc, dx, Wx, radius; int Nc, NX, NY, NZ; double beta = 1.0; NEW_FIELD_DATA fdata; ichemo = Global::GUI_to_DLL_index[field_constituent]; LOG_QMSG("displayField: field: " + QString::number(field_constituent) + " --> " + QString::number(ichemo)); use_log = false; // temporary *res = 0; if (hr >= 0) hour = hr; if (slice_changed) { // LOG_MSG("call new_get_fielddata"); new_get_fielddata(&axis, &fraction, &fdata, &ixyz, res); if (*res != 0) { LOG_MSG("Error: new_get_fielddata: FAILED"); sprintf(msg, "axis: %d fraction: %6.3f ixyz: %d res: %d",axis,fraction,ixyz,*res); LOG_MSG(msg); // exit(1); return; } // sprintf(msg,"fdata: %d %d %d %d ncells: %d",fdata.NX,fdata.NY,fdata.NZ,fdata.NCONST,fdata.ncells); // LOG_MSG(msg); slice_changed = false; } cmin = 1.0e10; cmax = 0; rmax = 1; NX = fdata.NX; NY = fdata.NY; NZ = fdata.NZ; dx = fdata.DX; Wx = (NX-1)*dx; Wc = CANVAS_WIDTH; a = Wc/(beta*Wx); b = Wc/2 - a*Wx/2; // sprintf(msg,"NX: %d dx: %f Wx: %f Wc: %f a: %f b: %f",NX,dx,Wx,Wc,a,b); // LOG_MSG(msg); brush.setStyle(Qt::SolidPattern); brush.setColor(QColor(0,0,0)); scene->addRect(0,0,CANVAS_WIDTH,CANVAS_WIDTH,Qt::NoPen, brush); view->setScene(scene); view->setGeometry(QRect(0, 0, CANVAS_WIDTH+4, CANVAS_WIDTH+4)); cmax = line_maxConc_list[field_constituent]->text().toDouble(); // sprintf(msg,"displayField: field constituent: %d ichemo: %d cmax: %f",field_constituent,ichemo,cmax); // LOG_MSG(msg); rgbcol[0] = 0; rgbcol[1] = 0; rgbcol[2] = 0; w = a*dx + 0.5; valmin = 1.0e10; scene->clear(); if (axis == X_AXIS) { // Y-Z plane ix = ixyz; for (iy=0; iy<NY; iy++) { x = iy*dx; for (iz=0; iz<NZ; iz++) { y = (NZ-1-iz)*dx; k = (ichemo-1)*NZ*NY*NX + iz*NY*NX + iy*NX + ix; // index(ix,iy,iz,ichemo); C = fdata.Cave[k]; valmin = MIN(C,valmin); rgbcol[1] = 255*min(C,cmax)/cmax; rgbcol[2] = 255*min(C,cmax)/cmax; xp = int(a*x + b); yp = int(a*y + b); // chooseFieldColor(data[i].conc[ichemo],cmin,cmax,use_log,rgbcol); // sprintf(msg,"c: %f %f %f rgbcol: %d %d %d",data[i].conc[constituent],cmin,cmax,rgbcol[0],rgbcol[1],rgbcol[2]); // LOG_MSG(msg); brush.setColor(QColor(rgbcol[0],rgbcol[1],rgbcol[2])); scene->addRect(xp,yp,w,w,Qt::NoPen, brush); } } } else if (axis == Y_AXIS) { // X-Z plane iy = ixyz; for (ix=0; ix<NX; ix++) { x = ix*dx; for (iz=0; iz<NZ; iz++) { y = (NZ-1-iz)*dx; k = (ichemo-1)*NZ*NY*NX + iz*NY*NX + iy*NX + ix; // index(ix,iy,iz,ichemo); C = fdata.Cave[k]; valmin = MIN(C,valmin); rgbcol[1] = 255*min(C,cmax)/cmax; rgbcol[2] = 255*min(C,cmax)/cmax; xp = int(a*x + b); yp = int(a*y + b); brush.setColor(QColor(rgbcol[0],rgbcol[1],rgbcol[2])); scene->addRect(xp,yp,w,w,Qt::NoPen, brush); } } } else if (axis == Z_AXIS) { // X-Y plane iz = ixyz; for (ix=0; ix<NX; ix++) { x = ix*dx; for (iy=0; iy<NY; iy++) { y = iy*dx; k = (ichemo-1)*NZ*NY*NX + iz*NY*NX + iy*NX + ix; // index(ix,iy,iz,ichemo); C = fdata.Cave[k]; // sprintf(msg,"%d %d %d %d %d %d %d %d %8.3f",NX,NY,NZ,ichemo,ix,iy,iz,k,C); // LOG_MSG(msg); valmin = MIN(C,valmin); rgbcol[1] = 255*min(C,cmax)/cmax; rgbcol[2] = 255*min(C,cmax)/cmax; // if (ix == NX/2) { // sprintf(msg,"iy,C,cmax: %4d %8.3f %8.3f rgb: %3d %3d %3d",iy,C,cmax, // rgbcol[0],rgbcol[1],rgbcol[2]); // LOG_MSG(msg); // } xp = int(a*x + b); yp = int(a*y + b); brush.setColor(QColor(rgbcol[0],rgbcol[1],rgbcol[2])); scene->addRect(xp,yp,w,w,Qt::NoPen, brush); } } } // sprintf(msg,"axis: %d valmin: %f",axis,valmin); // LOG_MSG(msg); if (!show_cells) return; // ichemo = Global::GUI_to_DLL_index[cell_constituent]; // LOG_QMSG("displayField: cell: " + QString::number(cell_constituent) + " --> " + QString::number(ichemo)); // LOG_QMSG("displayField: nc: " + QString::number(fdata.ncells)); for (i=0; i<fdata.ncells; i++) { x = fdata.cell_data[i].centre[0]; y = fdata.cell_data[i].centre[1]; radius = fdata.cell_data[i].radius; xp = a*x + b; yp = a*y + b; d = 2*a*radius; // sprintf(msg,"Cell: %d x,y: %f %f radius: %f xp,yp: %f %f",i,x,y,radius,xp,yp); // LOG_MSG(msg); int status = fdata.cell_data[i].status; if (Global::only2colours2D && Global::celltypecolours2D) { if (status == 0 || status == 10 || status == 1 || status == 3) { int celltype = fdata.cell_data[i].celltype; QColor color = Global::celltype_colour[celltype]; rgbcol[0] = color.red(); rgbcol[1] = color.green(); rgbcol[2] = color.blue(); } else if (status == 2 || status == 4) { // tagged to die of starvation rgbcol[0] = 0; rgbcol[1] = 0; rgbcol[2] = 255; } else if (status > 10) { // tagged to die of treatment rgbcol[0] = 255; rgbcol[1] = 150; rgbcol[2] = 0; } } else { if (status == 0 || status == 10) { // growing (This is unnecessarily complicated, since cell_data[].celltype is available) if (!Global::celltypecolours2D) { // use original colour (light green) rgbcol[0] = 0; rgbcol[1] = 255; rgbcol[2] = 0; } else if (status == 0) { // use colours from 3D screen QColor color = Global::celltype_colour[1]; rgbcol[0] = color.red(); rgbcol[1] = color.green(); rgbcol[2] = color.blue(); } else { QColor color = Global::celltype_colour[2]; rgbcol[0] = color.red(); rgbcol[1] = color.green(); rgbcol[2] = color.blue(); } } else if (status == 1) { // radiobiological hypoxia rgbcol[0] = 50; rgbcol[1] = 100; rgbcol[2] = 32; } else if (status == 2 || status == 4) { // tagged to die of starvation rgbcol[0] = 0; rgbcol[1] = 0; rgbcol[2] = 255; } else if (status == 3) { // mitosis rgbcol[0] = 255; rgbcol[1] = 0; rgbcol[2] = 255; } else if (status > 10) { // tagged to die of treatment rgbcol[0] = 255; rgbcol[1] = 150; rgbcol[2] = 0; } } brush.setColor(QColor(rgbcol[0],rgbcol[1],rgbcol[2])); scene->addEllipse(xp,yp,d,d,Qt::NoPen, brush); } double w_scalebar = a*0.01 + b; // 100um = 0.01cm double scalebar0 = a*2*dx + b; QPen pen; QFont font; pen.setBrush(Qt::black); pen.setWidth(3); scene->addLine(scalebar0, scalebar0, scalebar0+w_scalebar, scalebar0, pen); QGraphicsTextItem *scalebar_text = scene->addText("100 um",font); scalebar_text->setPos(scalebar0,1.4*scalebar0); view->show(); // return; if (save_images && hour >= record2D_start_hour && hour <= record2D_end_hour) { scene->clearSelection(); // Selections would also render to the file scene->setSceneRect(scene->itemsBoundingRect()); // Re-shrink the scene to it's bounding contents QImage image(scene->sceneRect().size().toSize(), QImage::Format_ARGB32); // Create the image with the exact size of the shrunk scene image.fill(Qt::transparent); // Start all pixels transparent QPainter painter(&image); scene->render(&painter); ifield++; QString numstr = QString("%1").arg(hour, 4, 10, QChar('0')); QString filename = record2D_base_name + numstr + ".png"; // char *filename = qstr.toAscii(); // char filename[] = "image/field0000.png"; // char numstr[5]; // sprintf(numstr,"%04d",hour); // for (int i=0; i<4; i++) // filename[11+i] = numstr[i]; image.save(filename); } }
void WeightsManFrame::OnCreateBtn(wxCommandEvent& ev) { LOG_MSG("In WeightsManFrame::OnCreateBtn"); GdaFrame::GetGdaFrame()->OnToolsWeightsCreate(ev); }
//------------------------------------------------------------------------------ static int SYSRAM_Release( struct inode* pInode, struct file* pFile) { MUINT32 Index = 0; MUINT32 Sec = 0,USec = 0; MUINT64 Time64 = 0; SYSRAM_PROC_STRUCT* pProc; // SYSRAM_GetTime(&Time64, &Sec, &USec); // LOG_MSG("Cur:Name(%s),pid(%d),tgid(%d),Time(%ld.%06ld)", current->comm, current->pid, current->tgid, Sec, USec); // if(pFile->private_data != NULL) { pProc = (SYSRAM_PROC_STRUCT*)(pFile->private_data); // if( pProc->Pid != 0 || pProc->Tgid != 0 || pProc->Table != 0) { // LOG_WRN("Proc:Name(%s),pid(%d),tgid(%d),Table(0x%08lX),Time(%ld.%06ld)", pProc->ProcName, pProc->Pid, pProc->Tgid, pProc->Table, pProc->TimeS, pProc->TimeUS); // if(pProc->Table) { LOG_WRN("Force to release"); /* LOG_WRN("Proc:Name(%s),pid(%d),tgid(%d),Table(0x%08lX),Time(%ld.%06ld)", pProc->ProcName, pProc->Pid, pProc->Tgid, pProc->Table, pProc->TimeS, pProc->TimeUS); */ SYSRAM_DumpLayout(); // for(Index = 0 ; Index < SYSRAM_USER_AMOUNT; Index++) { if(pProc->Table & (1 << Index)) { SYSRAM_IOC_Free((SYSRAM_USER_ENUM)Index); } } } } // kfree(pFile->private_data); pFile->private_data = NULL; } else { LOG_WRN("private_data is NULL"); /* LOG_WRN("Cur:Name(%s),pid(%d),tgid(%d),Time(%ld.%06ld)", current->comm, current->pid, current->tgid, Sec, USec); */ } // return 0; }