private void downloadTrackBtn_Click(object sender, EventArgs e) { track.Clear(); trkFilter = new TrackFilter(4); InvokeSetButtonsVisibleState(false); progressBar.Maximum = trackCount; progressBar.Style = ProgressBarStyle.Continuous; port.Send(port.QueryTrackItem(0)); }
private static void Main(string[] args) { var reciever = TransponderReceiverFactory.CreateTransponderDataReceiver(); var trackfilter = new TrackFilter(reciever); while (true) { } }
public TimelineEditorComponent(MyGUIViewHost viewHost, TimelineEditorView view, SaveableClipboard clipboard) : base("Medical.GUI.Editor.TimelineEditor.TimelineEditorComponent.layout", viewHost) { Widget window = this.widget; window.RootKeyChangeFocus += new MyGUIEvent(window_RootKeyChangeFocus); this.clipboard = clipboard; this.editorController = view.EditorController; this.propEditController = view.PropEditController; this.timelineController = view.TimelineController; timelineController.TimelinePlaybackStarted += timelineController_TimelinePlaybackStarted; timelineController.TimelinePlaybackStopped += timelineController_TimelinePlaybackStopped; timelineController.TimeTicked += timelineController_TimeTicked; window.KeyButtonReleased += new MyGUIEvent(window_KeyButtonReleased); //Play Button playButton = window.findWidget("PlayButton") as Button; playButton.MouseButtonClick += new MyGUIEvent(playButton_MouseButtonClick); fastForwardButton = window.findWidget("FastForward") as Button; fastForwardButton.MouseButtonClick += new MyGUIEvent(fastForwardButton_MouseButtonClick); rewindButton = window.findWidget("Rewind") as Button; rewindButton.MouseButtonClick += new MyGUIEvent(rewindButton_MouseButtonClick); //Timeline view ScrollView timelineViewScrollView = window.findWidget("ActionView") as ScrollView; timelineView = new TimelineView(timelineViewScrollView); timelineView.KeyReleased += new EventHandler <KeyEventArgs>(timelineView_KeyReleased); timelineView.ActiveDataChanging += new EventHandler <CancelEventArgs>(timelineView_ActiveDataChanging); timelineView.MarkerMoved += new EventDelegate <TimelineView, float>(timelineView_MarkerMoved); timelineView.ActiveDataChanged += new EventHandler(timelineView_ActiveDataChanged); //Track filter ScrollView trackFilterScrollView = window.findWidget("ActionFilter") as ScrollView; actionFilter = new TrackFilter(trackFilterScrollView, timelineView); actionFilter.AddTrackItem += new AddTrackItemCallback(actionFilter_AddTrackItem); numberLine = new NumberLine(window.findWidget("NumberLine") as ScrollView, timelineView); //Add tracks to timeline. buildTrackActions(); foreach (TimelineActionPrototype action in actionDataManager.Prototypes) { timelineView.addTrack(action.TypeName); } //Enabled = false; ViewHost.Context.getModel <EditMenuManager>(EditMenuManager.DefaultName).setMenuProvider(this); }
public FormTrackFilter(TrackFilter filter) { _filter = filter; _languages = Language.AllLanguages.OrderBy(language => language.ISO_639_2).ToArray(); InitializeComponent(); Load += OnLoad; Shown += OnShown; }
public OffsetSequenceEditor(SaveableClipboard clipboard, MyGUIViewHost viewHost, OffsetSequenceEditorView view, MedicalController medicalController) : base("Medical.GUI.OffsetSequence.OffsetSequenceEditor.layout", viewHost) { this.clipboard = clipboard; this.medicalController = medicalController; this.simObjectMover = view.SimObjectMover; widget.KeyButtonReleased += new MyGUIEvent(window_KeyButtonReleased); widget.RootKeyChangeFocus += new MyGUIEvent(widget_RootKeyChangeFocus); //Remove button Button removeButton = widget.findWidget("RemoveAction") as Button; removeButton.MouseButtonClick += new MyGUIEvent(removeButton_MouseButtonClick); //Timeline view ScrollView timelineViewScrollView = widget.findWidget("ActionView") as ScrollView; timelineView = new TimelineView(timelineViewScrollView); timelineView.Duration = Duration; timelineView.KeyReleased += new EventHandler <KeyEventArgs>(timelineView_KeyReleased); timelineView.ActiveDataChanged += timelineView_ActiveDataChanged; //Properties ScrollView timelinePropertiesScrollView = widget.findWidget("ActionPropertiesScrollView") as ScrollView; actionProperties = new TimelineDataProperties(timelinePropertiesScrollView, timelineView); actionProperties.Visible = false; actionProperties.addPanel("Offset Position", new OffsetKeyframeProperties(timelinePropertiesScrollView, this, view.UICallback)); //Timeline filter ScrollView timelineFilterScrollView = widget.findWidget("ActionFilter") as ScrollView; trackFilter = new TrackFilter(timelineFilterScrollView, timelineView); trackFilter.AddTrackItem += new AddTrackItemCallback(trackFilter_AddTrackItem); numberLine = new NumberLine(widget.findWidget("NumberLine") as ScrollView, timelineView); //Add tracks to timeline. timelineView.addTrack("Offset Position"); ViewHost.Context.getModel <EditMenuManager>(EditMenuManager.DefaultName).setMenuProvider(this); Button chooseTargetButton = (Button)widget.findWidget("ChooseTargetButton"); chooseTargetButton.MouseButtonClick += chooseTargetButton_MouseButtonClick; targetLabel = (TextBox)widget.findWidget("TargetLabel"); targetLabel.Caption = DefaultTargetLabelText; CurrentSequence = view.Sequence; }
public async Task <ListResult <Track> > SearchTracks(TrackFilter filter, Page <TrackOrderColumn> page, IPrincipal principal) { var filterDo = mapper.Map <TrackFilterDo>(filter); var pageDo = mapper.Map <PagedQuery <TrackOrderColumnDo> >(page); if (filter != null && filter.PlayedByMe) { filterDo.PlayedByUserId = principal.GetUserId(); } if (filter != null && filter.IsInMyLibrary) { filterDo.IsInLibraryForUserId = principal.GetUserId(); } var tracks = (await context.TrackRepository.SearchTracks(filterDo, pageDo)).ToList(); var albumIds = tracks.Select(t => t.AlbumId).Distinct().ToList(); var trackIds = tracks.Select(t => t.Id).Distinct().ToList(); var albums = (await context.AlbumRepository.GetByIdList(albumIds)).ToDictionary(a => a.Id); var artists = await context.ArtistRepository.GetArtistsByTrackIdList(trackIds); var genres = await context.GenreRepository.GetGenresByTrackIdList(trackIds); var userTrackIds = new HashSet <int>(await context.TrackRepository.GetUserTracksByTrackIdList(trackIds, principal.GetUserId())); var count = await context.TrackRepository.CountTracks(filterDo); var items = tracks .Select(t => new Track { Id = t.Id, Album = mapper.Map <Album>(albums[t.AlbumId]), Artists = mapper.Map <List <Artist> >(artists[t.Id]), Genres = mapper.Map <List <Genre> >(genres[t.Id]), DiscNumber = t.DiscNumber, Duration = t.Duration.TotalSeconds, SavedToLibrary = userTrackIds.Contains(t.Id), Title = t.Title, TrackNumber = t.TrackNumber }) .ToList(); return(new ListResult <Track> { Items = items, Count = count }); }
public void Setup() { _transponderReceiver = Substitute.For <ITransponderReceiver>(); _aircraft = new Aircraft(0, 0, 0, DateTime.Now, "YOLO69"); _uut = new TrackFilter(_transponderReceiver, new AtmFactory()); _aircraftlist = new List <IVehicle> { _aircraft }; _transponderReceiver.TransponderDataReady += (sender, args) => _transponderWasCalled = true; _uut.AirTrackToMonitorEvent += (sender, args) => _inWasCalled = true; _uut.AirTrackOutSideMonitorEvent += (sender, args) => _outWasCalled = true; }
public MainForm() { InitializeComponent(); applySettingsBtn.Enabled = false; port = new RedNavPort(); port.ConnectionSearchingStarted += new EventHandler(port_ConnectionSearchingStarted); port.ConnectionEstablished += new EventHandler(port_ConnectionEstablished); port.PortReady += new EventHandler(port_PortReady); port.LocalDataReceived += new EventHandler <LocalDataEventArgs>(port_LocalDataReceived); port.TrackItemReceived += new EventHandler <TrackItemEventArgs>(port_TrackItemReceived); port.WaypointReceived += new EventHandler <WaypointEventArgs>(port_WaypointReceived); port.ACKReceived += new EventHandler(port_ACKReceived); port.RNDeviceInfoUpdated += new EventHandler(port_RNDeviceInfoUpdated); port.FieldValueReceived += new EventHandler <FieldValueEventArgs>(port_FieldValueReceived); trkFilter = new TrackFilter(4, 100); }
List <TrackFilter> GetActiveTrackFilters() { string sql = "select ID, FilterType, IsStrong, Word, UserID, Region from TwitterTrackFilter where IsActive;"; List <TrackFilter> activeFilters = new List <TrackFilter>(); Helpers.RunSelect(Name, sql, activeFilters, (values, reader) => { TrackFilter filter = new TrackFilter(); try { filter.ID = reader.GetInt32("ID"); filter.Type = (TrackFilter.FilterType)reader.GetByte("FilterType"); filter.IsStrong = reader.GetBoolean("IsStrong"); if (filter.Type == TrackFilter.FilterType.User) { filter.UserID = reader.GetInt64("UserID"); } else if (filter.Type == TrackFilter.FilterType.Region) { string[] coordinates = reader.GetString("Region").Split(','); filter.Longitude1 = double.Parse(coordinates[0], CultureInfo.InvariantCulture); filter.Latitude1 = double.Parse(coordinates[1], CultureInfo.InvariantCulture); filter.Longitude2 = double.Parse(coordinates[2], CultureInfo.InvariantCulture); filter.Latitude2 = double.Parse(coordinates[3], CultureInfo.InvariantCulture); } else //Word { filter.Word = reader.GetString("Word"); } values.Add(filter); } catch (Exception) { } }); return(activeFilters); }
public PropTimeline(SaveableClipboard clipboard, PropEditController propEditController, PropFactory propFactory, MyGUIViewHost viewHost) : base("Medical.GUI.Editor.PropTimeline.PropTimeline.layout", viewHost) { this.clipboard = clipboard; this.propEditController = propEditController; this.propFactory = propFactory; propEditController.ShowPropActionChanged += propEditController_ShowPropActionChanged; propEditController.DurationChanged += propEditController_DurationChanged; propEditController.MarkerMoved += propEditController_MarkerMoved; widget.KeyButtonReleased += new MyGUIEvent(window_KeyButtonReleased); widget.RootKeyChangeFocus += new MyGUIEvent(widget_RootKeyChangeFocus); //Timeline view ScrollView timelineViewScrollView = widget.findWidget("ActionView") as ScrollView; timelineView = new TimelineView(timelineViewScrollView); timelineView.Duration = 5.0f; timelineView.KeyReleased += new EventHandler <KeyEventArgs>(timelineView_KeyReleased); timelineView.ActiveDataChanged += new EventHandler(timelineView_ActiveDataChanged); //Properties timelineDataManager = new PropTimelineDataManager(); //Timeline filter ScrollView timelineFilterScrollView = widget.findWidget("ActionFilter") as ScrollView; trackFilter = new TrackFilter(timelineFilterScrollView, timelineView); trackFilter.AddTrackItem += new AddTrackItemCallback(trackFilter_AddTrackItem); numberLine = new NumberLine(widget.findWidget("NumberLine") as ScrollView, timelineView); setPropData(propEditController.CurrentShowPropAction); ViewHost.Context.getModel <EditMenuManager>(EditMenuManager.DefaultName).setMenuProvider(this); }
public APLLBLCore(Dictionary <string, SerialPortSettings> inPortSettings, double radialErrorThreshold, double simplexSize, int courseEstimatorFifoSize, int trackFilterSize) { #region misc. initialization primaryGNSSFixRMC = new AgingValue <RMCMessageEventArgs>(2, 10, x => string.Format(CultureInfo.InvariantCulture, "LAT: {0:F06}°\r\nLON: {1:F06}°\r\nSPD: {2:F01} m/s (3:F01 km/h)\r\nTRK: {4:F01}°", x.Latitude, x.Longitude, x.SpeedKmh / 3.6, x.SpeedKmh, x.TrackTrue)); meanWaterTemperatureC = new AgingValue <double>(10, 30, x => string.Format(CultureInfo.InvariantCulture, "MTW: {0:F01} °C", x)); targetFix = new AgingValue <GeoPoint3DETm>(3, 60, x => string.Format(CultureInfo.InvariantCulture, "LAT: {0:F06}°\r\nLON: {1:F06}°\r\nRER: {2:F03} m", x.Latitude, x.Longitude, x.RadialError)); targetFixFlt = new AgingValue <GeoPoint3DETm>(3, 60, x => string.Format(CultureInfo.InvariantCulture, "LAT: {0:F06}°\r\nLON: {1:F06}°", x.Latitude, x.Longitude)); targetCourse = new AgingValue <double>(4, 8, x => string.Format(CultureInfo.InvariantCulture, "CRS: {0:F01}°", x)); distanceToTarget = new AgingValue <double>(4, 8, x => string.Format(CultureInfo.InvariantCulture, "D2T: {0:F01} m", x)); forwardAzimuthToTarget = new AgingValue <double>(4, 8, x => string.Format(CultureInfo.InvariantCulture, "FAZ: {0:F01}°", x)); reverseAzimuthToTarget = new AgingValue <double>(4, 8, x => string.Format(CultureInfo.InvariantCulture, "RAZ: {0:F01}°", x)); BaseBatStates = new Dictionary <BaseIDs, AgingValue <bool> >(); BaseBatStates.Add(BaseIDs.BASE_1, new AgingValue <bool>(30, 60, x => !x ? string.Format("{0} BAT LOW!", BaseIDs.BASE_1) : string.Empty)); BaseBatStates.Add(BaseIDs.BASE_2, new AgingValue <bool>(30, 60, x => !x ? string.Format("{0} BAT LOW!", BaseIDs.BASE_1) : string.Empty)); BaseBatStates.Add(BaseIDs.BASE_3, new AgingValue <bool>(30, 60, x => !x ? string.Format("{0} BAT LOW!", BaseIDs.BASE_1) : string.Empty)); BaseBatStates.Add(BaseIDs.BASE_4, new AgingValue <bool>(30, 60, x => !x ? string.Format("{0} BAT LOW!", BaseIDs.BASE_1) : string.Empty)); dopState = new AgingValue <DOPState>(4, 10, x => x.ToString().Replace('_', ' ').ToUpperInvariant()); tbaQuality = new AgingValue <TBAQuality>(4, 10, x => x.ToString().Replace('_', ' ').ToUpperInvariant()); #endregion #region pCore trkFilter = new TrackFilter(trackFilterSize); pCore = new PCore2D <GeoPoint3DT>(radialErrorThreshold, simplexSize, Algorithms.WGS84Ellipsoid, courseEstimatorFifoSize); pCore.RadialErrorExeedsThrehsoldEventHandler += (o, e) => InfoEventHandler.Rise(this, new LogEventArgs(LogLineType.INFO, "WAYU Pinger location failed: radial error exeeds threshold")); pCore.TargetLocationUpdatedExHandler += (o, e) => { targetFix.Value = new GeoPoint3DETm(e.Location.Latitude, e.Location.Longitude, e.Location.Depth, e.Location.RadialError, e.TimeStamp); targetCourse.Value = e.Course; var fltTrk = trkFilter.Filter(e.Location.Latitude, e.Location.Longitude); targetFixFlt.Value = new GeoPoint3DETm(fltTrk.Latitude, fltTrk.Longitude, e.Location.Depth, e.Location.RadialError, e.TimeStamp); if (primaryGNSSFixRMC.IsInitializedAndNotObsolete) { UpdateTargetRelativeData(); } InfoEventHandler.Rise(this, new LogEventArgs(LogLineType.INFO, string.Format(CultureInfo.InvariantCulture, "WAYU Pinger located: {0}, Course: {1:F01}°", targetFixFlt, e.Course))); TrackUpdateHandler.Rise(this, new TrackUpdateEventArgs("WAYU (RAW)", targetFix.Value, e.Course)); TrackUpdateHandler.Rise(this, new TrackUpdateEventArgs("WAYU (FLT)", targetFixFlt.Value, e.Course)); if ((outPort != null) && (outPort.IsOpen)) { WriteOutData(targetFixFlt.Value.Latitude, targetFixFlt.Value.Longitude, 0.0, targetFix.Value.RadialError, targetCourse.Value, targetFix.Value.RadialError <= pCore.RadialErrorThreshold); } SystemUpdate(); }; pCore.BaseQualityUpdatedHandler += (o, e) => { dopState.Value = e.DopState; tbaQuality.Value = e.TBAState; }; #endregion #region basesProcessor basesProcessor = new APLBaseProcessor(4, 2.0); #endregion #region NMEA if (!nmeaSingleton) { NMEAParser.AddManufacturerToProprietarySentencesBase(ManufacturerCodes.APL); NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.APL, "A", "x,x.x,x.x,x.x,x,x.x"); nmeaSingleton = true; } #endregion #region Port dictionaries portDescrByHash = new Dictionary <int, string>(); portNameByHash = new Dictionary <int, string>(); portHashByDescr = new Dictionary <string, int>(); portTimoutFlags = new Dictionary <int, bool>(); portTSByHash = new Dictionary <int, int>(); portDescrByHash.Add(emuID, emuIDstr); portNameByHash.Add(emuID, emuIDstr); portHashByDescr.Add(emuIDstr, emuID); #endregion #region nmeaListener nmeaListener = new NMEAMultipleListener(); nmeaListener.LogEventHandler += (o, e) => InfoEventHandler.Rise(o, e); nmeaListener.NMEAIncomingMessageReceived += (o, e) => InfoEventHandler.Rise(o, new LogEventArgs(LogLineType.INFO, string.Format("{0} ({1}) >> {2}", portNameByHash[e.SourceID], portDescrByHash[e.SourceID], e.Message))); nmeaListener.RMCSentenceReceived += new EventHandler <RMCMessageEventArgs>(nmeaListener_RMCSentenceReceivedHandler); nmeaListener.MTWSentenceReceived += new EventHandler <MTWMessageEventArgs>(nmeaListener_MTWSentenceReceivedHandler); nmeaListener.NMEAProprietaryUnsupportedSentenceParsed += new EventHandler <NMEAUnsupportedProprietaryEventArgs>(nmeaListener_NMEAUnsupportedProprietaryReceivedHander); #endregion #region inPorts List <SerialPortSettings> portsList = new List <SerialPortSettings>(); foreach (var inPort in inPortSettings) { int portHash = inPort.Value.PortName.GetHashCode(); portDescrByHash.Add(portHash, inPort.Key); portNameByHash.Add(portHash, inPort.Value.PortName); portHashByDescr.Add(inPort.Key, portHash); portTimoutFlags.Add(portHash, false); portTSByHash.Add(portHash, 0); portsList.Add(inPort.Value); } inPorts = new SerialPortsPool(portsList.ToArray()); inPorts.DataReceived += (o, e) => { int portKey = e.PortName.GetHashCode(); portTSByHash[portKey] = 0; if (portTimoutFlags[portKey]) { portTimoutFlags[portKey] = false; PortStateChangedHandler.Rise(this, new EventArgs()); } nmeaListener.ProcessIncoming(portKey, e.Data); }; inPorts.ErrorReceived += (o, e) => InfoEventHandler.Rise(o, new LogEventArgs(LogLineType.ERROR, string.Format("{0} ({1}) >> {2}", e.PortName, portDescrByHash[e.PortName.GetHashCode()], e.EventType.ToString()))); #endregion #region timer timer = new PrecisionTimer(); timer.Mode = Mode.Periodic; timer.Period = 100; timer.Tick += (o, e) => { if (IsOpen) { int[] keys = new int[portTSByHash.Count]; portTSByHash.Keys.CopyTo(keys, 0); for (int i = 0; i < keys.Length; i++) { portTSByHash[keys[i]] += timerPeriodMS; if (portTSByHash[keys[i]] > portsTimeoutMS) { portTSByHash[keys[i]] = 0; if (!portTimoutFlags[keys[i]]) { portTimoutFlags[keys[i]] = true; PortStateChangedHandler.Rise(this, new EventArgs()); } } } } systemUpdateTS += timerPeriodMS; if (systemUpdateTS > systemUpdateTimeoutMS) { SystemUpdate(); } }; timer.Start(); #endregion }
public RWLT_Core(SerialPortSettings rwltPortSettings, double radialErrorThreshold, double simplexSize, int courseEstimatorFIFOSize, int trkFilterFIFOSize) { #region parameters var basesIDs = Enum.GetValues(typeof(BaseIDs)); foreach (BaseIDs baseID in basesIDs) { if (baseID != BaseIDs.BASE_INVALID) { BaseBatVoltages.Add(baseID, new AgingValue <double>(4, 10, svoltageFormatter)); BaseMSRs.Add(baseID, new AgingValue <double>(4, 10, msrFormatter)); } } HDOPState = new AgingValue <DOPState>(4, 10, x => x.ToString().ToUpperInvariant()); TBAState = new AgingValue <TBAQuality>(4, 10, x => x.ToString().Replace('_', ' ').ToUpperInvariant()); TargetLatitude = new AgingValue <double>(4, 10, latlonFormatter); TargetLongitude = new AgingValue <double>(4, 10, latlonFormatter); TargetLocationRadialError = new AgingValue <double>(4, 10, rerrFormatter); TargetPressure = new AgingValue <double>(6, 10, prsFormatter); TargetTemperature = new AgingValue <double>(60, 120, tempFormatter); TargetBatVoltage = new AgingValue <double>(30, 120, svoltageFormatter); TargetDepth = new AgingValue <double>(6, 10, dptdstFormatter); TargetAlarm = new AgingValue <PingerCodeIDs>(600, 6000, pAlmFormatter); DistanceToTarget = new AgingValue <double>(4, 10, dptdstFormatter); ForwardAzimuthToTarget = new AgingValue <double>(4, 10, courseFormatter); ReverseAzimuthToTarget = new AgingValue <double>(4, 10, courseFormatter); TargetCourse = new AgingValue <double>(4, 10, courseFormatter); AUXLatitude = new AgingValue <double>(4, 10, latlonFormatter); AUXLongitude = new AgingValue <double>(4, 10, latlonFormatter); AUXTrack = new AgingValue <double>(4, 10, courseFormatter); AUXSpeed = new AgingValue <double>(4, 10, speedFormatter); CEP = new AgingValue <double>(4, 300, x => string.Format(CultureInfo.InvariantCulture, "{0:F03} m", x)); DRMS = new AgingValue <double>(4, 300, x => string.Format(CultureInfo.InvariantCulture, "{0:F03} m", x)); DRMS2 = new AgingValue <double>(4, 300, x => string.Format(CultureInfo.InvariantCulture, "{0:F03} m", x)); DRMS3 = new AgingValue <double>(4, 300, x => string.Format(CultureInfo.InvariantCulture, "{0:F03} m", x)); #endregion #region trkFilter trkFilter = new TrackFilter(trkFilterFIFOSize); #endregion #region pCore pCore = new PCore2D <GeoPoint3DT>(radialErrorThreshold, simplexSize, Algorithms.WGS84Ellipsoid, courseEstimatorFIFOSize); pCore.RadialErrorExeedsThrehsoldEventHandler += new EventHandler(pCore_RadialErrorExeedsThresholdEventHandler); pCore.TargetLocationUpdatedExHandler += new EventHandler <TargetLocationUpdatedExEventArgs>(pCore_TargetLocationUpdatedExEventHandler); pCore.BaseQualityUpdatedHandler += new EventHandler <BaseQualityUpdatedEventArgs>(pCore_BaseQualityUpdatedEventHandler); #endregion #region basesProcessor baseProcessor = new RWLT_BaseProcessor(4, 2.0); #endregion #region NMEA if (!nmeaSingleton) { NMEAParser.AddManufacturerToProprietarySentencesBase(ManufacturerCodes.RWL); NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.RWL, "A", "x,x.x,x.x,x.x,x.x,x,x.x,x.x,x.x"); } #endregion #region inPort inPort = new NMEASerialPort(rwltPortSettings); inPort.NewNMEAMessage += (o, e) => { LogEvent.Rise(o, new LogEventArgs(LogLineType.INFO, string.Format("{0} (IN) >> {1}", inPort.PortName, e.Message))); NMEAListener.ProcessIncoming(0, e.Message); }; inPort.PortError += (o, e) => LogEvent.Rise(o, new LogEventArgs(LogLineType.ERROR, string.Format("{0} (IN) >> {1}", inPort.PortName, e.EventType.ToString()))); #endregion #region NMEAListener NMEAListener = new NMEAMultipleListener(); NMEAListener.NMEAProprietaryUnsupportedSentenceParsed += new EventHandler <NMEAUnsupportedProprietaryEventArgs>(NMEAPSentenceReceived); NMEAListener.RMCSentenceReceived += new EventHandler <RMCMessageEventArgs>(GNSS_RMCSentenceReceived); #endregion #region timer timer = new PrecisionTimer(); timer.Period = 100; timer.Tick += (o, e) => { if (++systemUpdateTS > systemUpdateLimit) { systemUpdateTS = 0; SystemUpdateEvent.Rise(this, new EventArgs()); } if (inPort.IsOpen && (++inPortTimeoutTS > inPortTimeoutLimit)) { inPortTimeoutTS = 0; InPortTimeout = true; LogEvent.Rise(this, new LogEventArgs(LogLineType.ERROR, string.Format("{0} (IN) >> TIMEOUT", inPort.PortName))); } if (AUXGNSSUsed && auxGNSSPort.IsOpen && (++AUXGNSSTimeoutTS > AUXGNSSTimeoutLimit)) { AUXGNSSTimeoutTS = 0; AUXGNSSTimeout = true; LogEvent.Rise(this, new LogEventArgs(LogLineType.ERROR, string.Format("{0} (AUX) >> TIMEOUT", auxGNSSPort.PortName))); } }; timer.Start(); #endregion statHelper = new List <GeoPoint>(); }
static void Main(string[] args) { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new ColourForm()); var midiout = new StreamWriter(@"E:\test.mid"); var midiin = new StreamReader(@"E:\Midi\Pi.mid"); MidiWriter writer = new MidiWriter(midiout.BaseStream); writer.Init(); var filter = new TrackFilter(); MidiFileInfo info = MidiFileInfo.Parse(midiin.BaseStream); writer.WriteDivision(info.Division); writer.WriteNtrks((ushort)Math.Min(info.TrackCount, 65535)); writer.WriteFormat(info.Format); for (int i = 0; i < info.TrackCount; i++) { Console.WriteLine("Priocessing track: " + i); byte[] trackbytes = new byte[info.Tracks[i].Length]; midiin.BaseStream.Position = info.Tracks[i].Start; midiin.BaseStream.Read(trackbytes, 0, (int)info.Tracks[i].Length); writer.InitTrack(); long prevtime = 0; double hue = i * 60; int d = 3; filter.MidiEventFilter = (byte[] dtimeb, int dtime, byte[] data, long time) => { byte[] e = new byte[] { 0xFF, 0x0A, 0x08, 0x00, 0x0F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFF }; //byte[] e = new byte[] { 0xFF, 0x0A, 0x0C, 0x00, 0x0F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF }; if (time - prevtime > d) { List <byte> o = new List <byte>(); long start = time - dtime; while (prevtime + d < time) { prevtime += d; int delta = (int)(prevtime - start); int r, g, b; HsvToRgb(hue, 1, 1, out r, out g, out b); hue += 1; hue = hue % 360; e[7] = (byte)r; e[8] = (byte)g; e[9] = (byte)b; //HsvToRgb(hue + 60, 1, 1, out r, out g, out b); //hue += 1; //hue = hue % 360; //e[11] = (byte)r; //e[12] = (byte)g; //e[13] = (byte)b; o.AddRange(filter.MakeVariableLen(delta)); o.AddRange(e); start += delta; } o.AddRange(filter.MakeVariableLen((int)(time - start))); o.AddRange(data); return(o.ToArray()); } return(dtimeb.Concat(data).ToArray()); }; var newtrackbytes = filter.FilterTrack(new MemoryByteReader(trackbytes)); writer.Write(newtrackbytes); writer.EndTrack(); } writer.Close(); }
public MovementSequenceEditor(MovementSequenceController movementSequenceController, SaveableClipboard clipboard, MyGUIViewHost viewHost, MovementSequenceEditorView view) : base("Medical.GUI.Editor.MovementSequence.MovementSequenceEditor.layout", viewHost) { this.clipboard = clipboard; widget.KeyButtonReleased += new MyGUIEvent(window_KeyButtonReleased); widget.RootKeyChangeFocus += new MyGUIEvent(widget_RootKeyChangeFocus); this.movementSequenceController = movementSequenceController; movementSequenceController.PlaybackStarted += movementSequenceController_PlaybackStarted; movementSequenceController.PlaybackStopped += movementSequenceController_PlaybackStopped; movementSequenceController.PlaybackUpdate += movementSequenceController_PlaybackUpdate; //Remove button Button removeButton = widget.findWidget("RemoveAction") as Button; removeButton.MouseButtonClick += new MyGUIEvent(removeButton_MouseButtonClick); //Duration Edit durationEdit = new NumericEdit(widget.findWidget("SequenceDuration") as EditBox); durationEdit.AllowFloat = true; durationEdit.ValueChanged += new MyGUIEvent(durationEdit_ValueChanged); durationEdit.MinValue = 0.0f; durationEdit.MaxValue = 600; //Play Button playButton = widget.findWidget("PlayButton") as Button; playButton.MouseButtonClick += new MyGUIEvent(playButton_MouseButtonClick); //Timeline view ScrollView timelineViewScrollView = widget.findWidget("ActionView") as ScrollView; timelineView = new TimelineView(timelineViewScrollView); timelineView.DurationChanged += new EventHandler(timelineView_DurationChanged); timelineView.Duration = 5.0f; timelineView.KeyReleased += new EventHandler <KeyEventArgs>(timelineView_KeyReleased); //Properties ScrollView timelinePropertiesScrollView = widget.findWidget("ActionPropertiesScrollView") as ScrollView; actionProperties = new TimelineDataProperties(timelinePropertiesScrollView, timelineView); actionProperties.Visible = false; actionProperties.addPanel("Muscle Position", new MovementKeyframeProperties(timelinePropertiesScrollView)); //Timeline filter ScrollView timelineFilterScrollView = widget.findWidget("ActionFilter") as ScrollView; trackFilter = new TrackFilter(timelineFilterScrollView, timelineView); trackFilter.AddTrackItem += new AddTrackItemCallback(trackFilter_AddTrackItem); numberLine = new NumberLine(widget.findWidget("NumberLine") as ScrollView, timelineView); //Add tracks to timeline. timelineView.addTrack("Muscle Position"); CurrentSequence = view.Sequence; if (view.ListenForSequenceChanges) { movementSequenceController.CurrentSequenceChanged += movementSequenceController_CurrentSequenceChanged; if (CurrentSequence == null) { CurrentSequence = movementSequenceController.CurrentSequence; } } ViewHost.Context.getModel <EditMenuManager>(EditMenuManager.DefaultName).setMenuProvider(this); }
private void utilsTrackFilteringBtn_Click(object sender, EventArgs e) { using (OpenFileDialog oDialog = new OpenFileDialog()) { oDialog.Title = "Select a KML file to filter..."; oDialog.DefaultExt = "kml"; oDialog.Filter = "KML files (*.kml)|*.kml"; if (oDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { bool isLoaded = false; KMLData kmlData = null; try { kmlData = TinyKML.Read(oDialog.FileName); isLoaded = true; } catch (Exception ex) { ProcessException(ex, true); } if (isLoaded) { TrackFilter trkFilter = new TrackFilter(8); for (int i = 0; i < kmlData.Count; i++) { if (kmlData[i].PlacemarkItem.Count > 1) { trkFilter.Reset(); for (int j = 0; j < kmlData[i].PlacemarkItem.Count; j++) { var fresult = trkFilter.Filter(kmlData[i].PlacemarkItem[j].Latitude, kmlData[i].PlacemarkItem[j].Longitude); kmlData[i].PlacemarkItem[j].Latitude = fresult.Latitude; kmlData[i].PlacemarkItem[j].Longitude = fresult.Longitude; } } } using (SaveFileDialog sDialog = new SaveFileDialog()) { sDialog.Title = "Select filename to save filtered track..."; sDialog.DefaultExt = "kml"; sDialog.Filter = "KML files (*.kml)|*.kml"; var fName = string.Format("FLT_{0}", Path.GetFileName(oDialog.FileName)); var fPath = Path.GetDirectoryName(oDialog.FileName); sDialog.FileName = Path.Combine(fPath, fName); if (sDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { bool isSaved = false; try { TinyKML.Write(kmlData, sDialog.FileName); isSaved = true; } catch (Exception ex) { ProcessException(ex, true); } if (isSaved) { MessageBox.Show("Tracks successfully saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } } } }
void Reload(object sender, System.Timers.ElapsedEventArgs args) { /* * Instead of * ID * IsActive * IsStrong * Hits1d * Discards1d * FilterType * Word * UserID * UserName * Region * * Replace with * ID * IsActive * Track * Hits1d * Discards1d * Tag * Weight * FilterType * Word * UserID * UserName * Region * */ string sql = "select FilterType, Word, UserID, Region from TwitterTrackFilter where IsActive;"; List <TrackFilter> newFilters = new List <TrackFilter>(); Helpers.RunSelect(_name, sql, newFilters, (values, reader) => { TrackFilter filter = new TrackFilter(); try { filter.Type = (TrackFilter.FilterType)reader.GetByte("FilterType"); if (filter.Type == TrackFilter.FilterType.User) { filter.UserID = reader.GetInt64("UserID"); } else if (filter.Type == TrackFilter.FilterType.Region) { string[] coordinates = reader.GetString("Region").Split(','); filter.Longitude1 = double.Parse(coordinates[0], CultureInfo.InvariantCulture); filter.Latitude1 = double.Parse(coordinates[1], CultureInfo.InvariantCulture); filter.Longitude2 = double.Parse(coordinates[2], CultureInfo.InvariantCulture); filter.Latitude2 = double.Parse(coordinates[3], CultureInfo.InvariantCulture); } else //Word { filter.Word = reader.GetString("Word"); } values.Add(filter); } catch (Exception) { } } ); if (newFilters.Count() != _filters.Count || newFilters.Where(n => _filters.Any(m => m.ID == n.ID)).Count() < newFilters.Count) { ResetFilters(newFilters); } }