void VolumeControl::_ConnectVolume() { _DisconnectVolume(); const char* errorString = NULL; float volume = 0.0; fMixerControl->Connect(fMixerControl->VolumeWhich(), &volume, &errorString); if (errorString != NULL) { SetLabel(errorString); SetLimits(-60, 18); } else { SetLabel(B_TRANSLATE("Volume")); SetLimits((int32)floorf(fMixerControl->Minimum()), (int32)ceilf(fMixerControl->Maximum())); BMediaRoster* roster = BMediaRoster::CurrentRoster(); if (roster != NULL && fMixerControl->GainNode() != media_node::null) { roster->StartWatching(this, fMixerControl->GainNode(), B_MEDIA_NEW_PARAMETER_VALUE); } } SetEnabled(errorString == NULL); fOriginalValue = (int32)volume; SetValue((int32)volume); }
void SliderInputCombo::Init( double min, double max, double val, double range ) { SetLimits( min, max ); SetVal( val ); SetRange( range ); UpdateGui(); }
/*--------------------------------------------------------------------------*/ PegFiniteDial::PegFiniteDial(const PegRect& Rect, SIGNED iMinAngle, SIGNED iMaxAngle, LONG lMinValue, LONG lMaxValue, WORD wStyle) : PegDial(Rect, wStyle) { Type(TYPE_FDIAL); SetLimits(iMinAngle, iMaxAngle, lMinValue, lMaxValue); }
/*--------------------------------------------------------------------------*/ PegFiniteDial::PegFiniteDial(SIGNED iLeft, SIGNED iTop, SIGNED iMinAngle, SIGNED iMaxAngle, LONG lMinValue, LONG lMaxValue, WORD wStyle) : PegDial(iLeft, iTop, wStyle) { Type(TYPE_FDIAL); SetLimits(iMinAngle, iMaxAngle, lMinValue, lMaxValue); }
Slider::Slider( int upper, int lower ) : m_curValue(0),m_lowerLimit(lower), m_upperLimit(upper), m_sliderDrag(false),m_hotSpotX(0), m_hotSpotY(0) { m_movable = false; m_type = SLIDER; m_cursorRect.w = 15; SetLimits(m_lowerLimit,m_upperLimit); }
Range::Range(const char *defstr /*=NULL*/, int minval /*=0*/, int ulimval /*=RNG_VAL_BAD*/) { def_string = NULL; rangeList = NULL; type = RNG_TYPE_NONE; min_val=0; max_val=0; SetLimits(minval, ulimval); SetDefStr(defstr?defstr:"all"); }
/************************************************************************* * AM-VELOCITY-VIEW *************************************************************************/ AmVelocityView::AmVelocityView( BRect frame, AmSongRef songRef, AmTrackRef trackRef) : inherited(frame, "AmVelocityView", NULL, NULL, B_FOLLOW_TOP | B_FOLLOW_LEFT, B_WILL_DRAW), AmSongObserver(songRef), mContainer(0), mNoteOn(0), mTrackRef(trackRef) { SetLimits(0, 127); }
/************************************************************************* * AM-CHANNEL-PRESSURE-CONTROL *************************************************************************/ AmChannelPressureControl::AmChannelPressureControl( BRect frame, AmSongRef songRef, AmTrackRef trackRef) : inherited(frame, "AmChannelPressureControl", NULL, NULL, B_FOLLOW_TOP | B_FOLLOW_LEFT, B_WILL_DRAW), AmSongObserver(songRef), mContainer(NULL), mChannelPressure(NULL), mTrackRef(trackRef) { SetLimits(0, 127); }
/************************************************************************* * AM-PITCH-BEND-TEXT-VIEW *************************************************************************/ AmPitchBendView::AmPitchBendView( BRect frame, AmSongRef songRef, AmTrackRef trackRef) : inherited(frame, "AmPitchBendView", NULL, NULL, B_FOLLOW_TOP | B_FOLLOW_LEFT, B_WILL_DRAW), AmSongObserver(songRef), mContainer(0), mPitchBend(0), mTrackRef(trackRef) { SetLimits(AM_PITCH_MIN, AM_PITCH_MAX); SetMotion( new ArpIntControlMediumMotion() ); }
/************************************************************************* * AM-TEMPO-TEXT-VIEW *************************************************************************/ AmTempoTextView::AmTempoTextView( BRect frame, AmSongRef songRef, AmTrackRef trackRef) : inherited(frame, "AmTempoTextView", 0, 0, B_FOLLOW_TOP | B_FOLLOW_LEFT, B_WILL_DRAW), mSongRef(songRef), mTrackRef(trackRef), mContainer(NULL), mTempoChange(NULL) { SetLimits(1, 400); SetSteps(1); }
int main (int argc, char * argv[]) { if (argc < 2) { printf ("format: proj1 <filename>\n"); exit (1); } SetLimits (); SyntacticalAnalyzer parse (argv[1]); return 0; }
CGUIResizeControl::CGUIResizeControl(DWORD dwParentID, DWORD dwControlId, float posX, float posY, float width, float height, const CImage& textureFocus, const CImage& textureNoFocus) : CGUIControl(dwParentID, dwControlId, posX, posY, width, height) , m_imgFocus(dwParentID, dwControlId, posX, posY, width, height, textureFocus) , m_imgNoFocus(dwParentID, dwControlId, posX, posY, width, height, textureNoFocus) { m_dwFrameCounter = 0; m_dwLastMoveTime = 0; m_fSpeed = 1.0; m_fAnalogSpeed = 2.0f; // TODO: implement correct analog speed m_fAcceleration = 0.2f; // TODO: implement correct computation of acceleration m_fMaxSpeed = 10.0; // TODO: implement correct computation of maxspeed ControlType = GUICONTROL_RESIZE; SetLimits(0, 0, 720, 576); // defaults }
void tGauge::UnitsChanged( tUnitsType type, int unitsValue ) { if( ( m_Indicators.size() > 0 ) && ( m_UnitsType == type ) ) { tDigitalData pData( m_Indicators.at( 0 ).dataId ); tConvert* pConverter = tConvert::Instance(); //special case for UNITS_ECONOMY. They can be inverted by the user, and we need //to retrieve the new limits from tDigitalData, which handles this. if( type == UNITS_ECONOMY ) { RealLimits.max = pData.MaxConverted(); RealLimits.min = pData.MinConverted(); RealWarnings.max = pData.WarningHighConverted(); RealWarnings.min = pData.WarningLowConverted(); AbsoluteLimits.max = pData.AbsoluteMaxConverted(); AbsoluteLimits.min = pData.AbsoluteMinConverted(); } else { tFloatLimits limits; limits.max = pConverter->ToUser( m_UnitsType, m_UnitsValue, RealLimits.max ); limits.min = pConverter->ToUser( m_UnitsType, m_UnitsValue, RealLimits.min ); tFloatLimits warnings; warnings.max = pConverter->ToUser( m_UnitsType, m_UnitsValue, RealWarnings.max ); warnings.min = pConverter->ToUser( m_UnitsType, m_UnitsValue, RealWarnings.min ); tFloatLimits absLimits; absLimits.max = pConverter->ToUser( m_UnitsType, m_UnitsValue, AbsoluteLimits.max ); absLimits.min = pConverter->ToUser( m_UnitsType, m_UnitsValue, AbsoluteLimits.min ); AbsoluteLimits = absLimits; SetLimits( limits, warnings ); } m_UnitsType = type; m_UnitsValue = unitsValue; int limitIndex = GetCustomHobartLimits(); SetCustomHobartLimits( limitIndex ); OnLimitsChanged(); m_UnitsStr = pData.UnitStr(); ReconfigureGauge(); InvalidateBackground(); } }
CGUIMoverControl::CGUIMoverControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus) : CGUIControl(parentID, controlID, posX, posY, width, height) , m_imgFocus(posX, posY, width, height, textureFocus) , m_imgNoFocus(posX, posY, width, height, textureNoFocus) { m_frameCounter = 0; m_lastMoveTime = 0; m_fSpeed = 1.0; m_fAnalogSpeed = 2.0f; // TODO: implement correct analog speed m_fAcceleration = 0.2f; // TODO: implement correct computation of acceleration m_fMaxSpeed = 10.0; // TODO: implement correct computation of maxspeed ControlType = GUICONTROL_MOVER; SetLimits(0, 0, 720, 576); // defaults SetLocation(0, 0, false); // defaults }
CGUIResizeControl::CGUIResizeControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus) : CGUIControl(parentID, controlID, posX, posY, width, height) , m_imgFocus(posX, posY, width, height, textureFocus) , m_imgNoFocus(posX, posY, width, height, textureNoFocus) { m_frameCounter = 0; m_lastMoveTime = 0; m_fSpeed = 1.0; m_fAnalogSpeed = 2.0f; //! @todo implement correct analog speed m_fAcceleration = 0.2f; //! @todo implement correct computation of acceleration m_fMaxSpeed = 10.0; //! @todo implement correct computation of maxspeed ControlType = GUICONTROL_RESIZE; SetLimits(0, 0, 720, 576); // defaults m_nDirection = DIRECTION_NONE; }
void tGauge::OnLimitsChanged() { tDigitalData digitalData( GetDataId().DataType() ); tFloatLimits limits; tFloatLimits warnings; if ( tInstrumentUiSettings::Instance()->GetUserDataTypeLimits( GetDataId().DataType(), warnings, limits ) ) { // Data stored unconverted so need to convert to current units type. tFloatLimits convertedLimits = digitalData.ConvertLimits( limits ); tFloatLimits convertedWarnings = digitalData.ConvertLimits( warnings ); SetLimits( convertedLimits, convertedWarnings, true ); } }
//______________________________________________________________________________ void ArgusHistoDisplay::Modified(Bool_t processEvents) { if (!fCanvas) { return; } Int_t i, j; double x1, x2, y1, y2; TObject *ptr; fStyle->cd(); for (i = 0; i < fNumberOfPads; i++) { fPad[i]->GetRangeAxis(x1, y1, x2, y2); for (j = 0; j < fNumberOfCurrentDisplayTypes; j++) { ptr = static_cast<TObjArray*>(fObjects->At(fCurrentDisplayType->At(j)))->At(i); if (x1 != 0 && TMath::Abs((1.1 - x2) / 1.1) > 1e-6 && y1 !=0 && TMath::Abs((1.1 - y2)/1.1) > 1e-6) { if (!strcmp(ptr->ClassName(), "ROMETGraph") || !strcmp(ptr->ClassName(), "ROMETCutG")) { static_cast<ROMETGraph*>(ptr)->GetXaxis()->SetRangeUser(x1, x2); static_cast<ROMETGraph*>(ptr)->GetYaxis()->SetRangeUser(y1, y2); } else { static_cast<TH1*>(ptr)->GetXaxis()->SetRangeUser(x1, x2); static_cast<TH1*>(ptr)->GetYaxis()->SetRangeUser(y1, y2); } } if (!strcmp(ptr->ClassName(), "ROMETGraph") || !strcmp(ptr->ClassName(), "ROMETCutG")) { SetStatisticBox(true); // this allows changing X range fPad[i]->cd(); SetLimits(static_cast<TGraph*>(ptr)); } } fPad[i]->Modified(); } fCanvas->GetCanvas()->cd(1); fCanvas->GetCanvas()->Modified(); fCanvas->GetCanvas()->Update(); if (processEvents) { gROME->GetApplication()->DisableFPETrap(); gSystem->ProcessEvents(); gROME->GetApplication()->EnableFPETrap(); gSystem->Sleep(10); } }
void tGauge::ChangeDataType( const tDataId& dataId ) { m_SaveLimits = false; if( dataId == DATA_TYPE_INVALID ) { return; } //clear existing indicators m_Indicators.clear(); m_Indicators << tIndicator( dataId ); //set captions and limits tDigitalData pData( dataId ); AbsoluteLimits = pData.AbsoluteLimitsConverted(); tFloatLimits limits( pData.MinConverted(), pData.MaxConverted() ); tFloatLimits warnings( pData.WarningLowConverted(), pData.WarningHighConverted() ); m_UnitsType = pData.Units(); m_UnitsValue = tUnitsSettings::Instance()->Units( m_UnitsType ); //set update timer and update immediately UpdateValues(); //autoconfigure if applicable if( CanAutoConfigure() && AutoConfigure() ) { DoAutoConfigure(); } SetLimits( limits, warnings ); SetCaptions(); //does any type specific config ReconfigureGauge(); m_BackIsCached = false; m_ForeIsCached = false; update(); m_Modified = true; if( m_UnitsType != UNITS_ECONOMY ) { // m_SaveLimits = true; } }
void dgBallConstraint::SetPivotPoint(const dgVector &pivot) { dgAssert (m_body0); dgAssert (m_body1); const dgMatrix& matrix = m_body0->GetMatrix(); dgVector pin (pivot - matrix.m_posit); if ((pin % pin) < dgFloat32 (1.0e-3f)) { pin = matrix.m_front; } SetPivotAndPinDir (pivot, pin); dgMatrix matrix0; dgMatrix matrix1; CalculateGlobalMatrixAndAngle (matrix0, matrix1); SetLimits (matrix0.m_front, -dgPI * dgFloat32 (0.5f), dgPI * dgFloat32 (0.5f), dgPI * dgFloat32 (0.5f), matrix0.m_right, dgFloat32 (0.0f), dgFloat32 (0.0f)); }
int main (int argc, char * argv[]) { SetLimits(); if (argc < 2) { printf ("format: proj1 <filename>\n"); exit(1); } char *filename = argv[1]; if (!has_proper_extension(filename)) { printf("input file must have .in extension\n"); exit(1); } char *basename = remove_extension(filename); char *listname = listname_from_basename(basename); char *debugname = debugname_from_basename(basename); FILE *input_file = fopen(filename, "r"); FILE *output_file = fopen(listname, "w"); FILE *debug_file = fopen(debugname, "w"); if (input_file == NULL || output_file == NULL || debug_file == NULL) { printf ("error opening files\n"); exit(1); } fprintf(output_file, "Input file: %s\n", filename); syn_state ss; init_syn(&ss, input_file, output_file, debug_file); parse_syn(&ss); end_syn(&ss); fclose(input_file); fclose(output_file); return 0; }
//______________________________________________________________________________ void ROMETGraph::Add(const TObject *obj) { if (!obj) { return; } if (!obj->InheritsFrom("TGraph")) { return; } const TGraph *g1 = static_cast<const TGraph*>(obj); Int_t n = g1->GetN(); Int_t oldN = fNpoints; Int_t newN = fNpoints + n; Set(newN); memcpy(fX + oldN, g1->GetX(), sizeof(Double_t) * n); memcpy(fY + oldN, g1->GetY(), sizeof(Double_t) * n); SetLimits(); }
Slider::Slider() : m_curValue(0),m_lowerLimit(0), m_upperLimit(100), m_sliderDrag(false),m_hotSpotX(0),m_hotSpotY(0) { m_movable = false; m_type = SLIDER; m_cursorRect.w = 15; m_cursorRect.h = 20; m_cursor = sf::Shape::Rectangle(0,0,(float)m_cursorRect.w, (float)m_cursorRect.h,sf::Color(213,198,224)); //buttons particular size hint m_sizeHint.x = 75; m_sizeHint.y = 25; //buttons particular size policy m_horizontalPolicy = MinimumExpand; m_verticalPolicy = Fixed; SetLimits(m_lowerLimit,m_upperLimit); }
int main( int argc, char **argv ) { struct stat stat_buff; stat_record_t sum_stat; printer_t print_header, print_record; nfprof_t profile_data; char *rfile, *Rfile, *Mdirs, *wfile, *ffile, *filter, *tstring, *stat_type; char *byte_limit_string, *packet_limit_string, *print_format, *record_header; char *print_order, *query_file, *UnCompress_file, *nameserver, *aggr_fmt; int c, ffd, ret, element_stat, fdump; int i, user_format, quiet, flow_stat, topN, aggregate, aggregate_mask, bidir; int print_stat, syntax_only, date_sorted, do_tag, compress, do_xstat; int plain_numbers, GuessDir, pipe_output, csv_output; time_t t_start, t_end; uint32_t limitflows; char Ident[IDENTLEN]; rfile = Rfile = Mdirs = wfile = ffile = filter = tstring = stat_type = NULL; byte_limit_string = packet_limit_string = NULL; fdump = aggregate = 0; aggregate_mask = 0; bidir = 0; t_start = t_end = 0; syntax_only = 0; topN = -1; flow_stat = 0; print_stat = 0; element_stat = 0; do_xstat = 0; limitflows = 0; date_sorted = 0; total_bytes = 0; total_flows = 0; skipped_blocks = 0; do_tag = 0; quiet = 0; user_format = 0; compress = 0; plain_numbers = 0; pipe_output = 0; csv_output = 0; is_anonymized = 0; GuessDir = 0; nameserver = NULL; print_format = NULL; print_header = NULL; print_record = NULL; print_order = NULL; query_file = NULL; UnCompress_file = NULL; aggr_fmt = NULL; record_header = NULL; Ident[0] = '\0'; while ((c = getopt(argc, argv, "6aA:Bbc:D:E:s:hHn:i:j:f:qzr:v:w:K:M:NImO:R:XZt:TVv:x:l:L:o:")) != EOF) { switch (c) { case 'h': usage(argv[0]); exit(0); break; case 'a': aggregate = 1; break; case 'A': if ( !ParseAggregateMask(optarg, &aggr_fmt ) ) { exit(255); } aggregate_mask = 1; break; case 'B': GuessDir = 1; case 'b': if ( !SetBidirAggregation() ) { exit(255); } bidir = 1; // implies aggregate = 1; break; case 'D': nameserver = optarg; if ( !set_nameserver(nameserver) ) { exit(255); } break; case 'E': query_file = optarg; if ( !InitExporterList() ) { exit(255); } PrintExporters(query_file); exit(0); break; case 'X': fdump = 1; break; case 'Z': syntax_only = 1; break; case 'q': quiet = 1; break; case 'z': compress = 1; break; case 'c': limitflows = atoi(optarg); if ( !limitflows ) { LogError("Option -c needs a number > 0\n"); exit(255); } break; case 's': stat_type = optarg; if ( !SetStat(stat_type, &element_stat, &flow_stat) ) { exit(255); } break; case 'V': { char *e1, *e2; e1 = ""; e2 = ""; #ifdef NSEL e1 = "NSEL-NEL"; #endif printf("%s: Version: %s%s%s\n",argv[0], e1, e2, nfdump_version); exit(0); } break; case 'l': packet_limit_string = optarg; break; case 'K': LogError("*** Anonymisation moved! Use nfanon to anonymise flows!\n"); exit(255); break; case 'H': do_xstat = 1; break; case 'L': byte_limit_string = optarg; break; case 'N': plain_numbers = 1; break; case 'f': ffile = optarg; break; case 't': tstring = optarg; break; case 'r': rfile = optarg; if ( strcmp(rfile, "-") == 0 ) rfile = NULL; break; case 'm': print_order = "tstart"; Parse_PrintOrder(print_order); date_sorted = 1; LogError("Option -m depricated. Use '-O tstart' instead\n"); break; case 'M': Mdirs = optarg; break; case 'I': print_stat++; break; case 'o': // output mode print_format = optarg; break; case 'O': { // stat order by int ret; print_order = optarg; ret = Parse_PrintOrder(print_order); if ( ret < 0 ) { LogError("Unknown print order '%s'\n", print_order); exit(255); } date_sorted = ret == 6; // index into order_mode } break; case 'R': Rfile = optarg; break; case 'w': wfile = optarg; break; case 'n': topN = atoi(optarg); if ( topN < 0 ) { LogError("TopnN number %i out of range\n", topN); exit(255); } break; case 'T': do_tag = 1; break; case 'i': strncpy(Ident, optarg, IDENT_SIZE); Ident[IDENT_SIZE - 1] = 0; if ( strchr(Ident, ' ') ) { LogError("Ident must not contain spaces\n"); exit(255); } break; case 'j': UnCompress_file = optarg; UnCompressFile(UnCompress_file); exit(0); break; case 'x': query_file = optarg; InitExtensionMaps(NO_EXTENSION_LIST); DumpExMaps(query_file); exit(0); break; case 'v': query_file = optarg; QueryFile(query_file); exit(0); break; case '6': // print long IPv6 addr Setv6Mode(1); break; default: usage(argv[0]); exit(0); } } if (argc - optind > 1) { usage(argv[0]); exit(255); } else { /* user specified a pcap filter */ filter = argv[optind]; FilterFilename = NULL; } // Change Ident only if ( rfile && strlen(Ident) > 0 ) { ChangeIdent(rfile, Ident); exit(0); } if ( (element_stat || flow_stat) && (topN == -1) ) topN = 10; if ( topN < 0 ) topN = 0; if ( (element_stat && !flow_stat) && aggregate_mask ) { LogError("Warning: Aggregation ignored for element statistics\n"); aggregate_mask = 0; } if ( !flow_stat && aggregate_mask ) { aggregate = 1; } if ( rfile && Rfile ) { LogError("-r and -R are mutually exclusive. Plase specify either -r or -R\n"); exit(255); } if ( Mdirs && !(rfile || Rfile) ) { LogError("-M needs either -r or -R to specify the file or file list. Add '-R .' for all files in the directories.\n"); exit(255); } extension_map_list = InitExtensionMaps(NEEDS_EXTENSION_LIST); if ( !InitExporterList() ) { exit(255); } SetupInputFileSequence(Mdirs, rfile, Rfile); if ( print_stat ) { nffile_t *nffile; if ( !rfile && !Rfile && !Mdirs) { LogError("Expect data file(s).\n"); exit(255); } memset((void *)&sum_stat, 0, sizeof(stat_record_t)); sum_stat.first_seen = 0x7fffffff; sum_stat.msec_first = 999; nffile = GetNextFile(NULL, 0, 0); if ( !nffile ) { LogError("Error open file: %s\n", strerror(errno)); exit(250); } while ( nffile && nffile != EMPTY_LIST ) { SumStatRecords(&sum_stat, nffile->stat_record); nffile = GetNextFile(nffile, 0, 0); } PrintStat(&sum_stat); exit(0); } // handle print mode if ( !print_format ) { // automatically select an appropriate output format for custom aggregation // aggr_fmt is compiled by ParseAggregateMask if ( aggr_fmt ) { int len = strlen(AggrPrependFmt) + strlen(aggr_fmt) + strlen(AggrAppendFmt) + 7; // +7 for 'fmt:', 2 spaces and '\0' print_format = malloc(len); if ( !print_format ) { LogError("malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) ); exit(255); } snprintf(print_format, len, "fmt:%s %s %s",AggrPrependFmt, aggr_fmt, AggrAppendFmt ); print_format[len-1] = '\0'; } else if ( bidir ) { print_format = "biline"; } else print_format = DefaultMode; } if ( strncasecmp(print_format, "fmt:", 4) == 0 ) { // special user defined output format char *format = &print_format[4]; if ( strlen(format) ) { if ( !ParseOutputFormat(format, plain_numbers, printmap) ) exit(255); print_record = format_special; record_header = get_record_header(); user_format = 1; } else { LogError("Missing format description for user defined output format!\n"); exit(255); } } else { // predefined output format // Check for long_v6 mode i = strlen(print_format); if ( i > 2 ) { if ( print_format[i-1] == '6' ) { Setv6Mode(1); print_format[i-1] = '\0'; } else Setv6Mode(0); } i = 0; while ( printmap[i].printmode ) { if ( strncasecmp(print_format, printmap[i].printmode, MAXMODELEN) == 0 ) { if ( printmap[i].Format ) { if ( !ParseOutputFormat(printmap[i].Format, plain_numbers, printmap) ) exit(255); // predefined custom format print_record = printmap[i].func; record_header = get_record_header(); user_format = 1; } else { // To support the pipe output format for element stats - check for pipe, and remember this if ( strncasecmp(print_format, "pipe", MAXMODELEN) == 0 ) { pipe_output = 1; } if ( strncasecmp(print_format, "csv", MAXMODELEN) == 0 ) { csv_output = 1; set_record_header(); record_header = get_record_header(); } // predefined static format print_record = printmap[i].func; user_format = 0; } break; } i++; } } if ( !print_record ) { LogError("Unknown output mode '%s'\n", print_format); exit(255); } // this is the only case, where headers are printed. if ( strncasecmp(print_format, "raw", 16) == 0 ) print_header = format_file_block_header; if ( aggregate && (flow_stat || element_stat) ) { aggregate = 0; LogError("Command line switch -s overwrites -a\n"); } if ( !filter && ffile ) { if ( stat(ffile, &stat_buff) ) { LogError("Can't stat filter file '%s': %s\n", ffile, strerror(errno)); exit(255); } filter = (char *)malloc(stat_buff.st_size+1); if ( !filter ) { LogError("malloc() error in %s line %d: %s\n", __FILE__, __LINE__, strerror(errno) ); exit(255); } ffd = open(ffile, O_RDONLY); if ( ffd < 0 ) { LogError("Can't open filter file '%s': %s\n", ffile, strerror(errno)); exit(255); } ret = read(ffd, (void *)filter, stat_buff.st_size); if ( ret < 0 ) { perror("Error reading filter file"); close(ffd); exit(255); } total_bytes += ret; filter[stat_buff.st_size] = 0; close(ffd); FilterFilename = ffile; } // if no filter is given, set the default ip filter which passes through every flow if ( !filter || strlen(filter) == 0 ) filter = "any"; Engine = CompileFilter(filter); if ( !Engine ) exit(254); if ( fdump ) { printf("StartNode: %i Engine: %s\n", Engine->StartNode, Engine->Extended ? "Extended" : "Fast"); DumpList(Engine); exit(0); } if ( syntax_only ) exit(0); if ( print_order && flow_stat ) { printf("-s record and -O (-m) are mutually exclusive options\n"); exit(255); } if ((aggregate || flow_stat || print_order) && !Init_FlowTable() ) exit(250); if (element_stat && !Init_StatTable(HashBits, NumPrealloc) ) exit(250); SetLimits(element_stat || aggregate || flow_stat, packet_limit_string, byte_limit_string); if ( tstring ) { if ( !ScanTimeFrame(tstring, &t_start, &t_end) ) exit(255); } if ( !(flow_stat || element_stat || wfile || quiet ) && record_header ) { if ( user_format ) { printf("%s\n", record_header); } else { // static format - no static format with header any more, but keep code anyway if ( Getv6Mode() ) { printf("%s\n", record_header); } else printf("%s\n", record_header); } } nfprof_start(&profile_data); sum_stat = process_data(wfile, element_stat, aggregate || flow_stat, print_order != NULL, print_header, print_record, t_start, t_end, limitflows, do_tag, compress, do_xstat); nfprof_end(&profile_data, total_flows); if ( total_bytes == 0 ) { printf("No matched flows\n"); exit(0); } if (aggregate || print_order) { if ( wfile ) { nffile_t *nffile = OpenNewFile(wfile, NULL, compress, is_anonymized, NULL); if ( !nffile ) exit(255); if ( ExportFlowTable(nffile, aggregate, bidir, date_sorted, extension_map_list) ) { CloseUpdateFile(nffile, Ident ); } else { CloseFile(nffile); unlink(wfile); } DisposeFile(nffile); } else { PrintFlowTable(print_record, topN, do_tag, GuessDir, extension_map_list); } } if (flow_stat) { PrintFlowStat(record_header, print_record, topN, do_tag, quiet, csv_output, extension_map_list); #ifdef DEVEL printf("Loopcnt: %u\n", loopcnt); #endif } if (element_stat) { PrintElementStat(&sum_stat, plain_numbers, record_header, print_record, topN, do_tag, quiet, pipe_output, csv_output); } if ( !quiet ) { if ( csv_output ) { PrintSummary(&sum_stat, plain_numbers, csv_output); } else if ( !wfile ) { if (is_anonymized) printf("IP addresses anonymised\n"); PrintSummary(&sum_stat, plain_numbers, csv_output); if ( t_last_flow == 0 ) { // in case of a pre 1.6.6 collected and empty flow file printf("Time window: <unknown>\n"); } else { printf("Time window: %s\n", TimeString(t_first_flow, t_last_flow)); } printf("Total flows processed: %u, Blocks skipped: %u, Bytes read: %llu\n", total_flows, skipped_blocks, (unsigned long long)total_bytes); nfprof_print(&profile_data, stdout); } } Dispose_FlowTable(); Dispose_StatTable(); FreeExtensionMaps(extension_map_list); #ifdef DEVEL if ( hash_hit || hash_miss ) printf("Hash hit: %i, miss: %i, skip: %i, ratio: %5.3f\n", hash_hit, hash_miss, hash_skip, (float)hash_hit/((float)(hash_hit+hash_miss))); #endif return 0; }
/// \brief Re-enable insertion device motor /// \pre Insertion device is still connected /// \post Limits are set again and the MCDC is re-enabled void InsertionDevice::ReEnable(DeviceParams params) { SetLimits(params); //Set limits again just to be safe MotionController::EnableDevice(); //"EN" command MotionController::ResetEncoder(); //Reset encoder ticks to zero }
void CODESolver::Integrate(ODESolverBase *ODEBase, double Stop_Time, double Max_dTime, flag OneIteration, flag HoldAdvance) { pODEBase=ODEBase; Time_Stop=Stop_Time; if (m_iMethod != ODE_RK4) m_iStepSizeControl=ODE_SSC_Fixed; rIC.m_TimeIncMx=Min(rIC.m_TimeIncMxRqd, Max_dTime); rIC.m_TimeIncMn=rIC.m_TimeIncMnRqd; dEstMaxDT=0.0; fStepTooLarge=False; fStepSizeTooSmall=0; //nBadVarRange=0; rIC.m_TimeIncMx=Max(1.0e-5, rIC.m_TimeIncMx); rIC.m_TimeIncMn=Max(1.0e-6, rIC.m_TimeIncMn); if (m_iStepSizeControl==ODE_SSC_Fixed) rIC.m_TimeIncNext=rIC.m_TimeIncMx; flag ShortStep=0; rIC.m_TimeIncNext=Range(rIC.m_TimeIncMn, Valid(rIC.m_TimeIncNext) ? rIC.m_TimeIncNext : rIC.m_TimeInc, rIC.m_TimeIncMx); while (rIC.m_Time < Time_Stop && !fStepSizeTooSmall) { double dT_Reqd; rIC.m_TimeInc=rIC.m_TimeIncNext; rIC.m_TimeIncInit=rIC.m_TimeInc; dT_Reqd = Min(Max_dTime, Min(rIC.m_TimeInc, (Time_Stop-rIC.m_Time))); ShortStep = (dT_Reqd < rIC.m_TimeInc * 0.99); rIC.m_TimeInc = dT_Reqd; LoadIC(IC_StepStart | IC_StepPreStart, "===="); // Clear the last Iterations Errors m_BadTolList.Len=0; m_BadLim.Len=0; // Must Converge States Before Starting CODEDataBlock ODB(this); ODB.Set(eStateConverge, -1, CODEDataBlock::Converge, pODEBase); pODEBase->ODEStartStep(); LoadIC(IC_StepStart , "===="); pODEBase->ODEDerivs(); SaveStart(); #if dbgODESolve if (dbgDumpDerivs()) DumpIntegrators(hDumpFile, rIC.m_Time, rIC.m_TimeInc, "Strt"); #endif SetLimits(); int IntLoop=0; m_BadTolList.Len=0; m_BadTolCopy.Len=0; for (flag OK=0; (!OK ) ; ) { m_BadLim.Len=0; IntLoop++; if (IntLoop > 1) { LoadIC(IC_StepReStart ,"=..="); pODEBase->ODEStartStep(); pODEBase->ODEDerivs(); } flag IsBad=0; OK=1; dTimeWrk = rIC.m_TimeInc; IntOneStep(); if (fStepTooLarge) { IsBad=True; } else switch (m_iStepSizeControl) { case ODE_SSC_Var_1: SaveIntermediate(); ReStart(); dTimeWrk *= 0.5; LoadIC(0 , " =="); // Derivatives @ Start still the Same IntOneStep(); if (!fStepTooLarge) { LoadIC(0 , " --"); pODEBase->ODEDerivs(); IntOneStep(); dTimeWrk *= 2.0; CalculateErrors(); IsBad = !StepSizeOK_1(); } break; case ODE_SSC_Var_2 : CalculateErrors(); IsBad=!StepSizeOK_2(); break; default: IsBad=0; break; } // FindOut what action to take // If bad then restart if (IsBad) { if (fStepTooLarge) { rIC.m_TimeInc=dEstMaxDT; ReStart(); OK=0; m_nBadIters++; fStepTooLarge=False; } else if (fStepSizeTooSmall) { rIC.m_TimeIncNext=rIC.m_TimeIncMn; m_nGoodIters++; m_nIters4Step++; } else //if (!fStepSizeTooSmall) { rIC.m_TimeInc=rIC.m_TimeIncRestart; ReStart(); OK=0; m_nBadIters++; m_nIters4Step++; } } else { m_nGoodIters++; m_nIters4Step++; } } // Must be called independently // EvalAllDiscrete(); #if dbgODESolve if (dbgDumpDerivs()) DumpIntegrators(hDumpFile, rIC.m_Time, rIC.m_TimeInc, "Done"); #endif if (ShortStep && !fStepSizeTooSmall) { if (rIC.m_TimeIncNext >= rIC.m_TimeInc) // Test Passed Easily but step was artificially short - use prev dT rIC.m_TimeIncNext=rIC.m_TimeIncInit; break; } rIC.m_TimeIncNext=Min(Max_dTime, rIC.m_TimeIncNext); rIC.m_TimeIncNext=Min(Max_dTime, rIC.m_TimeIncNext); if (OneIteration) break; } pODEBase=NULL; };
void ConnectTel(void) { struct termios tty; /* Packet to request version of azimuth motor driver */ char sendstr[] = { 0x50, 0x01, 0x10, 0xfe, 0x00, 0x00, 0x00, 0x02 }; /* Packet format: */ /* preamble */ /* packet length */ /* destination */ /* message id */ /* three message bytes */ /* number of response bytes */ char returnstr[32]; /* Packet format: */ /* response bytes if any */ /* # */ int numRead; int limits, flag; if(TelConnectFlag != FALSE) { return; } /* Make the connection */ /* TelPortFD = open("/dev/ttyS0",O_RDWR); */ TelPortFD = open(telserial,O_RDWR); if(TelPortFD == -1) { fprintf(stderr,"Serial port not available ... \n"); return; } tcgetattr(TelPortFD,&tty); cfsetospeed(&tty, (speed_t) B9600); cfsetispeed(&tty, (speed_t) B9600); tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; tty.c_iflag = IGNBRK; tty.c_lflag = 0; tty.c_oflag = 0; tty.c_cflag |= CLOCAL | CREAD; tty.c_cc[VMIN] = 1; tty.c_cc[VTIME] = 5; tty.c_iflag &= ~(IXON|IXOFF|IXANY); tty.c_cflag &= ~(PARENB | PARODD); tcsetattr(TelPortFD, TCSANOW, &tty); /* Flush the input (read) buffer */ tcflush(TelPortFD,TCIOFLUSH); /* Test connection by asking for version of azimuth motor */ writen(TelPortFD,sendstr,8); numRead=readn(TelPortFD,returnstr,3,2); if (numRead == 3) { fprintf(stderr,"RA/Azimuth "); fprintf(stderr,"controller version %d.%d ", returnstr[0], returnstr[1]); fprintf(stderr,"connected \n"); } else { fprintf(stderr,"RA/Azimuth drive not responding ...\n"); return; } /* Test connection by asking for version of altitude motor */ sendstr[2] = 0x11; /* Flush the input buffer */ tcflush(TelPortFD,TCIOFLUSH); /* Send the request */ writen(TelPortFD,sendstr,8); numRead=readn(TelPortFD,returnstr,3,2); /* Add null terminator to simplify handling the return data */ returnstr[numRead] = '\0'; if (numRead == 3) { fprintf(stderr,"Declination/Altitude "); fprintf(stderr,"controller version %d.%d ", returnstr[0], returnstr[1]); fprintf(stderr,"connected\n"); TelConnectFlag = TRUE; } else { fprintf(stderr,"Declination/altitude drive not responding ...\n"); return; } /* Perform startup tests */ flag = GetLimits(&limits); usleep(500000); limits = FALSE; flag = SetLimits(limits); usleep(500000); flag = GetLimits(&limits); /* Set global switch angles for a GEM OTA over the pier pointing at pole */ /* They correspond to ha ~ -6 hr and dec ~ +90 deg for northern telescope */ /* They correspond to ha ~ +6 hr and dec ~ -90 deg for southern telescope */ /* Non-zero values work better in goto routines on nexstar */ switchaz = 1.; switchalt = -1.0; /* Hardcoded defaults for homeha and homedec are overridden by prefs */ /* GEM: over the pier pointing at the pole */ /* EQFORK: pointing at the equator on the meridian */ /* ALTAZ: level and pointing north */ if ( homenow != TRUE ) { if (telmount == GEM) { if (SiteLatitude < 0.) { homedec = -89.9999; homeha = 6.; } else { homedec = 89.9999; homeha = -6.; } } else if (telmount == EQFORK) { if (SiteLatitude < 0.) { homedec = 0.; homeha = 0.; } else { homedec = 0.; homeha = 0.; } } else if (telmount == ALTAZ) { /* Set azimuth */ homeha = 0.; /* Set altitude */ homedec = 0.; } else { fprintf(stderr,"Telescope mounting must be GEM, EQFORK, or ALTAZ\n"); return; } } fprintf(stderr, "Using initial HA: %lf\n", homeha); fprintf(stderr, "Using initial Dec: %lf\n",homedec); flag = SetTelEncoders(homeha, homedec); if (flag != TRUE) { fprintf(stderr,"Initial telescope pointing request was out of range ... \n"); return; } /* Read encoders and confirm pointing */ GetTel(&homera, &homedec, RAW); fprintf(stderr, "Local latitude: %lf\n", SiteLatitude); fprintf(stderr, "Local longitude: %lf\n", SiteLongitude); fprintf(stderr, "Local sidereal time: %lf\n", LSTNow()); fprintf(stderr, "Mount type: %d\n", telmount); fprintf(stderr, "Mount now reading RA: %lf\n", homera); fprintf(stderr, "Mount now reading Dec: %lf\n", homedec); fprintf(stderr, "The telescope is running ...\n\n"); /* Flush the input buffer in case there is something left from startup */ tcflush(TelPortFD,TCIOFLUSH); }