void ConfigurationDialog::SetConfigurations(std::list<RouteMapConfiguration> configurations) { m_bBlockUpdate = true; SET_CHOICE(Start); bool ult = m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue(); #define STARTTIME (ult ? it->StartTime.FromUTC() : it->StartTime) SET_CONTROL_VALUE(STARTTIME, m_dpStartDate, SetValue, wxDateTime, wxDateTime()); SET_CONTROL_VALUE(wxString::Format(_T("%.2f"), STARTTIME.GetHour() + (double)STARTTIME.GetMinute()/60.0), m_tStartHour, SetValue, wxString, _T("")); SET_SPIN_VALUE(TimeStepHours, (int)((*it).dt / 3600)); SET_SPIN_VALUE(TimeStepMinutes, ((int)(*it).dt / 60) % 60); SET_SPIN_VALUE(TimeStepSeconds, (int)(*it).dt%60); SET_CONTROL(boatFileName, m_tBoat, SetValue, wxString, _T("")); SET_CHOICE(End); SET_SPIN(FromDegree); SET_SPIN(ToDegree); SET_CONTROL_VALUE(wxString::Format(_T("%f"), (*it).ByDegrees), m_tByDegrees, SetValue, wxString, _T("")); SET_CONTROL_VALUE(((*it).Integrator == RouteMapConfiguration::RUNGE_KUTTA ? _T("Runge Kutta") : _T("Newton")), m_cIntegrator, SetValue, wxString, _T("")); SET_SPIN(MaxDivertedCourse); SET_SPIN(MaxCourseAngle); SET_SPIN(MaxSearchAngle); SET_SPIN(MaxTrueWindKnots); SET_SPIN(MaxApparentWindKnots); SET_SPIN(MaxSwellMeters); SET_SPIN(MaxLatitude); SET_SPIN(TackingTime); SET_SPIN(WindVSCurrent); SET_CHECKBOX(AvoidCycloneTracks); SET_SPIN(CycloneMonths); SET_SPIN(CycloneDays); SET_CHECKBOX(DetectLand); SET_CHECKBOX(Currents); SET_CHECKBOX(InvertedRegions); SET_CHECKBOX(Anchoring); SET_CHECKBOX(UseGrib); SET_CONTROL(ClimatologyType, m_cClimatologyType, SetSelection, int, -1); SET_CHECKBOX(AllowDataDeficient); SET_SPIN_VALUE(WindStrength, (int)((*it).WindStrength * 100)); m_bBlockUpdate = false; }
static void control_finalize(void *control_ptr) { struct sml_control *control = control_ptr; if (control == NULL) return; detach_control(control); #ifdef MULTITHREAD pthread_mutex_destroy(&control->state_lock); pthread_cond_destroy(&control->state_cond); #endif /* MULTITHREAD */ sml_heap_thread_free(control->heap); sml_exn_free(control->exn); free(control); SET_CONTROL(NULL); DBG(("FINISH THREAD %p", control)); }
SML_PRIMITIVE void sml_control_start() { struct sml_control *control = CONTROL(); void **frame_end = CALLER_FRAME_END_ADDRESS(); short *layout; if (control != NULL) { control_resume(control); layout = lookup_stack_layout(FRAME_CODE_ADDRESS(frame_end)); ASSERT(layout != NULL); ASSERT(NUM_ROOTS(layout) > 0); frame_end[ROOTS(layout)[0]] = control->frame_stack_top; control->frame_stack_top = frame_end; return; } control = xmalloc(sizeof(struct sml_control)); control->state = RUN; #ifdef MULTITHREAD if (pthread_mutex_init(&control->state_lock, NULL) != 0) sml_sysfatal("pthread_mutex_init failed"); if (pthread_cond_init(&control->state_cond, NULL) != 0) sml_sysfatal("pthread_cond_init failed"); #ifdef CONCURRENT control->phase = ASYNC; #endif /* CONCURRENT */ #endif /* MULTITHREAD */ control->frame_stack_top_override = NULL; control->frame_stack_top = frame_end; control->frame_stack_bottom = frame_end; control->tmp_root[0] = NULL; control->tmp_root[1] = NULL; control->heap = sml_heap_thread_init(); control->exn = sml_exn_init(); SET_CONTROL(control); attach_control(control); DBG(("START THREAD %p", control)); }
/*****************组SPDU帧*********************/ int* SPDU_framing(void) { int *Transmitter_P; int *Control_P; int *Receiver_P; int *VR; int *Report_Request; int *Hall_Commond; int *PL_Extensions; int *Report_Source_SCID; int *Pre_SPDU_Data; int *SPDU_Data; int Num_Commond = 0; Pre_SPDU_Data = (int *)malloc(128 * sizeof(int)); if (SetTransmitterParameters == 1) { Transmitter_P = (int *)malloc(16 * sizeof(int)); Transmitter_P = SET_TRANSMITTER(); for (int n = 0; n<16; n++) { *(Pre_SPDU_Data + n) = *(Transmitter_P + n); } Num_Commond++; } if (SetControlParameters == 1) { Control_P = (int *)malloc(16 * sizeof(int)); Control_P = SET_CONTROL(); for (int n = 0; n<16; n++) { *(Pre_SPDU_Data + 16 * Num_Commond + n) = *(Control_P + n); } Num_Commond++; } if (SetReceiverParameters == 1) { Receiver_P = (int *)malloc(16 * sizeof(int)); Receiver_P = SET_RECEIVER(); for (int n = 0; n<16; n++) { *(Pre_SPDU_Data + 16 * Num_Commond + n) = *(Receiver_P + n); } Num_Commond++; } if (SetVR == 1) { VR = (int *)malloc(16 * sizeof(int)); VR = SET_VR(); for (int n = 0; n<16; n++) { *(Pre_SPDU_Data + 16 * Num_Commond + n) = *(VR + n); } Num_Commond++; } if (ReportRequest == 1) { Report_Request = (int *)malloc(16 * sizeof(int)); Report_Request = REPORT_REQUEST(); for (int n = 0; n<16; n++) { *(Pre_SPDU_Data + 16 * Num_Commond + n) = *(Report_Request + n); } Num_Commond++; } if (HallCommond == 1) { Hall_Commond = (int *)malloc(16 * sizeof(int)); Hall_Commond = HALL_COMMOND(); for (int n = 0; n<16; n++) { *(Pre_SPDU_Data + 16 * Num_Commond + n) = *(Hall_Commond + n); } Num_Commond++; } if (SetPLExtensions == 1) { PL_Extensions = (int *)malloc(16 * sizeof(int)); PL_Extensions = SET_PL_EXTENSIONS(); for (int n = 0; n<16; n++) { *(Pre_SPDU_Data + 16 * Num_Commond + n) = *(PL_Extensions + n); } Num_Commond++; } if (ReportSourceSCID == 1) { Report_Source_SCID = (int *)malloc(16 * sizeof(int)); Report_Source_SCID = REPORT_SOURCE_SCID(); for (int n = 0; n<16; n++) { *(Pre_SPDU_Data + 16 * Num_Commond + n) = *(Report_Source_SCID + n); } Num_Commond++; } SPDU_Data = (int *)malloc((8 + 16 * Num_Commond)*sizeof(int)); for (int i = 0; i<16 * Num_Commond; i++) { *(SPDU_Data + 8 + i) = *(Pre_SPDU_Data + i); } for (int j = 0; j<4; j++) { *(SPDU_Data + j) = 0; } int l = 2 * Num_Commond - 1; for (int k = 0; k<4; k++) { *(SPDU_Data + 7 - k) = l % 2; l = l / 2; } return SPDU_Data; }
void ConfigurationDialog::SetConfigurations(std::list<RouteMapConfiguration> configurations) { m_bBlockUpdate = true; m_edited_controls.clear(); SET_CHOICE(Start); bool ult = m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue(); #define STARTTIME (ult ? it->StartTime.FromUTC() : it->StartTime) SET_CONTROL_VALUE(STARTTIME.GetDateOnly(), m_dpStartDate, SetValue, wxDateTime, wxDateTime()); SET_CONTROL_VALUE(STARTTIME, m_tpTime, SetValue, wxDateTime, wxDateTime()); m_bCurrentTime->Enable(m_tpTime->IsEnabled() && m_dpStartDate->IsEnabled()); m_bGribTime->Enable(m_tpTime->IsEnabled() && m_dpStartDate->IsEnabled()); SET_SPIN_VALUE(TimeStepHours, (int)((*it).DeltaTime / 3600)); SET_SPIN_VALUE(TimeStepMinutes, ((int)(*it).DeltaTime / 60) % 60); SET_SPIN_VALUE(TimeStepSeconds, (int)(*it).DeltaTime%60); SET_CONTROL(boatFileName, m_tBoat, SetValue, wxString, _T("")); long l = m_tBoat->GetValue().Length(); m_tBoat->SetSelection(l, l); SET_CHOICE(End); // if there's a GUID it's an OpenCPN route, for now disable start and end // which would invalidate the it bool oRoute = false; for(auto it : configurations ) { if (!it.RouteGUID.IsEmpty()) { oRoute = true; break; } } m_cStart->Enable(!oRoute); m_cEnd->Enable(!oRoute); SET_SPIN(FromDegree); SET_SPIN(ToDegree); SET_CONTROL_VALUE(wxString::Format(_T("%f"), (*it).ByDegrees), m_tByDegrees, SetValue, wxString, _T("")); SET_CHOICE_VALUE(Integrator, ((*it).Integrator == RouteMapConfiguration::RUNGE_KUTTA ? _T("Runge Kutta") : _T("Newton"))); SET_SPIN(MaxDivertedCourse); SET_SPIN(MaxCourseAngle); SET_SPIN(MaxSearchAngle); SET_SPIN(MaxTrueWindKnots); SET_SPIN(MaxApparentWindKnots); SET_SPIN(MaxSwellMeters); SET_SPIN(MaxLatitude); SET_SPIN(TackingTime); SET_SPIN(WindVSCurrent); SET_CHECKBOX(AvoidCycloneTracks); SET_SPIN(CycloneMonths); SET_SPIN(CycloneDays); SET_SPIN(SafetyMarginLand); SET_CHECKBOX(DetectLand); SET_CHECKBOX(DetectBoundary); SET_CHECKBOX(Currents); SET_CHECKBOX(OptimizeTacking); SET_CHECKBOX(InvertedRegions); SET_CHECKBOX(Anchoring); SET_CHECKBOX(UseGrib); SET_CONTROL(ClimatologyType, m_cClimatologyType, SetSelection, int, -1); SET_CHECKBOX(AllowDataDeficient); SET_SPIN_VALUE(WindStrength, (int)((*it).WindStrength * 100)); m_bBlockUpdate = false; }
void do_it ( unsigned int base ) { unsigned int ra; unsigned int beg,end; unsigned int rb; unsigned int min,max; unsigned int rc; stop_l1cache(); //just in case invalidate_l1cache(); hexstrings(base); hexstrings(base); hexstrings(base); hexstring(base); hexstring(GET_CONTROL()); CLR_CONTROL(1<<11); hexstring(GET_CONTROL()); max=0; min=0; min--; for(ra=base+0x6000;ra<base+0x6100;ra+=4) { unsigned int flag; PUT32(ra+0x00,0xe2500001); PUT32(ra+0x04,0x1afffffd); PUT32(ra+0x08,0xe12fff1e); GET32(ra+0x08); PrefetchFlush(); for(rc=0;rc<4;rc++) { beg=GET32(ARM_TIMER_CNT); HOP(0x20000,ra); end=GET32(ARM_TIMER_CNT); rb=end-beg; flag=0; if(rb>gmax) gmax=rb; if(rb<gmin) gmin=rb; if(rb>max) { flag++; max=rb; } if(rb<min) { flag++; min=rb; } if(flag) { hexstrings(ra); hexstrings(rb); hexstrings(min); hexstrings(max); hexstring(max-min); } } } hexstring(GET_CONTROL()); SET_CONTROL(1<<11); hexstring(GET_CONTROL()); if(1) { max=0; min=0; min--; for(ra=base+0x6000;ra<base+0x6100;ra+=4) { unsigned int flag; PUT32(ra+0x00,0xe2500001); PUT32(ra+0x04,0x1afffffd); PUT32(ra+0x08,0xe12fff1e); GET32(ra+0x08); PrefetchFlush(); for(rc=0;rc<4;rc++) { beg=GET32(ARM_TIMER_CNT); HOP(0x20000,ra); end=GET32(ARM_TIMER_CNT); rb=end-beg; flag=0; if(rb>gmax) gmax=rb; if(rb<gmin) gmin=rb; if(rb>max) { flag++; max=rb; } if(rb<min) { flag++; min=rb; } if(flag) { hexstrings(ra); hexstrings(rb); hexstrings(min); hexstrings(max); hexstring(max-min); } } } } hexstring(GET_CONTROL()); CLR_CONTROL(1<<11); hexstring(GET_CONTROL()); ra=GET32(ARM_TIMER_CNT); start_l1cache(); max=0; min=0; min--; for(ra=base+0x6000;ra<base+0x6100;ra+=4) { unsigned int flag; PUT32(ra+0x00,0xe2500001); PUT32(ra+0x04,0x1afffffd); PUT32(ra+0x08,0xe12fff1e); GET32(ra+0x08); PrefetchFlush(); invalidate_l1cache(); for(rc=0;rc<4;rc++) { beg=GET32(ARM_TIMER_CNT); HOP(0x20000,ra); end=GET32(ARM_TIMER_CNT); rb=end-beg; flag=0; if(rb>gmax) gmax=rb; if(rb<gmin) gmin=rb; if(rb>max) { flag++; max=rb; } if(rb<min) { flag++; min=rb; } if(flag) { hexstrings(ra); hexstrings(rb); hexstrings(min); hexstrings(max); hexstring(max-min); } } } hexstring(GET_CONTROL()); SET_CONTROL(1<<11); hexstring(GET_CONTROL()); max=0; min=0; min--; for(ra=base+0x6000;ra<base+0x6100;ra+=4) { unsigned int flag; PUT32(ra+0x00,0xe2500001); PUT32(ra+0x04,0x1afffffd); PUT32(ra+0x08,0xe12fff1e); GET32(ra+0x08); PrefetchFlush(); invalidate_l1cache(); for(rc=0;rc<4;rc++) { beg=GET32(ARM_TIMER_CNT); HOP(0x20000,ra); end=GET32(ARM_TIMER_CNT); rb=end-beg; flag=0; if(rb>gmax) gmax=rb; if(rb<gmin) gmin=rb; if(rb>max) { flag++; max=rb; } if(rb<min) { flag++; min=rb; } if(flag) { hexstrings(ra); hexstrings(rb); hexstrings(min); hexstrings(max); hexstring(max-min); } } } hexstring(GET_CONTROL()); CLR_CONTROL(1<<11); hexstring(GET_CONTROL()); stop_l1cache(); }