public TimeStamp GetCurrentTimeReference() { var inputs = Data.Where(d => d.Visible).OfType <ITimeData>(); if (!inputs.Any()) { return(TimeStamp.Zero); } // 0. if there are 1D signals, sync to them // TODO: feels like a bad idea if (inputs.Any(i => i is DataLine1D)) { inputs = inputs.OfType <DataLine1D>(); } // 1. get biggest length ITimeData biggestData = inputs.First(); foreach (var input in inputs) { if (input.Duration.Begin.AsSeconds() > biggestData.Duration.Begin.AsSeconds()) { biggestData = input; } } // 2. get its time point at 0 return(AlignLines ? biggestData.Duration.Begin : TimeStamp.Zero); }
protected override void OnClick() { IMxDocument pMxDoc = ArcMap.Document; IMap pMap = pMxDoc.FocusMap; string sampeMapFileName = "BasicHurricanes.mxd"; if (pMap.LayerCount < 1) { MessageBox.Show("Before running this sample, load the associated file \'" + sampeMapFileName + "\'"); return; } if (pMap.get_Layer(0).Name != "atlantic_hurricanes_2000") { MessageBox.Show("Before running this sample, load the associated file \'" + sampeMapFileName + "\'"); return; } ITimeZoneFactory pTZFac = new TimeZoneFactoryClass(); //making the first layer of the focused map time-aware IFeatureLayer pFLyr = pMap.get_Layer(0) as IFeatureLayer; ITimeData pTimeData = pFLyr as ITimeData; String localTimeZoneId = pTZFac.QueryLocalTimeZoneWindowsID(); ITimeReference timeRef = pTZFac.CreateTimeReferenceFromWindowsID(localTimeZoneId); if (pTimeData.SupportsTime) { pTimeData.UseTime = true; ITimeTableDefinition pTimeDataDef = pFLyr as ITimeTableDefinition; pTimeDataDef.StartTimeFieldName = "Date_Time"; pTimeDataDef.TimeReference = timeRef; ITimeDataDisplay pTimeAnimProp = pFLyr as ITimeDataDisplay; pTimeAnimProp.TimeIntervalUnits = esriTimeUnits.esriTimeUnitsHours; pTimeAnimProp.TimeInterval = 12.0; } // IActiveView pActiveView = pMap as IActiveView; IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay; ITimeDisplay pTimeDisplay = pScreenDisplay as ITimeDisplay; pTimeDisplay.TimeReference = timeRef; ITime pStartTime = new TimeClass(); pStartTime.Year = 2000; pStartTime.Month = 9; pStartTime.Day = 25; ITime pEndTime = new TimeClass(); pEndTime.Year = 2000; pEndTime.Month = 9; pEndTime.Day = 30; ITimeExtent pTimeExt = new TimeExtentClass(); pTimeExt.StartTime = pStartTime; pTimeExt.EndTime = pEndTime; pTimeDisplay.TimeValue = pTimeExt as ITimeValue; pActiveView.ContentsChanged(); }
public void Init(IServiceLocator serviceLocator) { ServiceLocator = serviceLocator; dataController = ServiceLocator.GetService <IDataController>(); timeData = ((DataController)dataController).GetComponent <ITimeData>(); timers = new List <Timer>(GameObject.FindObjectsOfType <Timer>()); DontDestroyOnLoad(this); LoadTime(timeData); }
protected override void OnClick() { IMxDocument pMxDoc = ArcMap.Document; IMap pMap = pMxDoc.FocusMap; string filename = "TimeAwareHurricanes.mxd"; if (pMap.LayerCount < 1) { MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'"); return; } if (pMap.get_Layer(0).Name != "atlantic_hurricanes_2000") { MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'"); return; } ILayer selectedLayer = ArcMap.Document.SelectedLayer; if (selectedLayer == null) { MessageBox.Show("There is no selected layer. Select a time-aware layer"); return; } ITimeZoneFactory pTZFac = new TimeZoneFactoryClass(); IFeatureLayer pFLyr = selectedLayer as IFeatureLayer; ITimeData pTimeData = pFLyr as ITimeData; //making the first layer of the focused map time-aware if (pTimeData.SupportsTime) { pTimeData.UseTime = true; ITimeDataDisplay pTimeAnimProp = pFLyr as ITimeDataDisplay; pTimeAnimProp.TimeOffsetUnits = esriTimeUnits.esriTimeUnitsYears; pTimeAnimProp.TimeOffset = System.DateTime.Now.Year - 2000; } else { MessageBox.Show("Before running this sample, load the associated file \'" + filename + "\'"); return; } IActiveView pActiveView = pMap as IActiveView; pActiveView.Refresh(); }
// SYSTEMTIME structure used by SetSystemTime //[StructLayoutAttribute(LayoutKind.Sequential)] //private struct SYSTEMTIME // { // public short year; // public short month; // public short dayOfWeek; // public short day; // public short hour; // public short minute; // public short second; // public short milliseconds; // } //[DllImport("kernel32.dll")] // static extern bool SetLocalTime(ref SYSTEMTIME time); /// <summary> /// Определяем, надо ли нам обновить системное время. Если да, то обновляем его. Аналог NNTP только через MNO /// </summary> /// <param name="aDate">Время от базовой станции </param> private static void SetLocalTime(ITimeData aDate) { if (Math.Abs(DateTime.Now.Subtract(aDate.LocalTime).TotalSeconds) < 3) { return; } // [MMddHHmm[[CC]YY][.ss]] try { //[[[[[YY]YY]MM]DD]hh]mm[.ss] Console.WriteLine(aDate.LocalTime.ToString("yyyyMMddHHmm.ss")); if (aDate.LocalTime.Year < 2013) { return; } var process = Process.Start(@"/bin/date", aDate.LocalTime.ToString("yyyyMMddHHmm.ss")); if (process == null) { return; } process.WaitForExit(); process = Process.Start(@"/sbin/hwclock", " -w"); if (process == null) { return; } process.WaitForExit(); // TODO: add code for timezone syncro } catch (FileNotFoundException) { } catch (InvalidOperationException) { } }
private void LoadTime(ITimeData data) { DateTime unlockTime; try { foreach (Timer timer in timers) { switch (timer.GetComponentInParent <IButton>().Type) { case ButtonTypes.AddCurrency100: unlockTime = Convert.ToDateTime(data.UnlockTimeAdd100); break; case ButtonTypes.MultiplierX2: unlockTime = Convert.ToDateTime(data.UnlockTimeX2); break; default: unlockTime = Convert.ToDateTime(data.UnlockTimeAdd100); break; } if (unlockTime > DateTime.Now) { var deltaUnlockTime = (unlockTime - DateTime.Now); timer.StartTimer(deltaUnlockTime); } } Debug.Log("Time loaded"); } catch { Debug.Log("Time not loaded"); } }
protected override void OnClick() { if (!m_bIsConnected) { try { //open the shapefile with the recorded data IFeatureClass featureClass = openPlaybackData(); if (null == featureClass) { return; } //get the map container object mapObj = ArcMap.Application; //load the Tracking Analyst extension ITrackingEnvironment3 trackingEnv = setupTrackingEnv(ref mapObj); //set the mode to historic, since you need to do playback trackingEnv.DefaultTemporalReference.TemporalMode = enumTemporalMode.enumHistoric; //set the units of the temporal period to days trackingEnv.DefaultTemporalReference.TemporalPeriodUnits = enumTemporalUnits.enumDays; //set the update mode to manual so that it will be controlled by the application trackingEnv.DisplayManager.ManualUpdate = true; //set the temporal perspective to Aug 03 2000 7PM. trackingEnv.DefaultTemporalReference.TemporalPerspective = "8/3/2000 7:0:00 PM"; // Stop using the map's time to allow the layer to draw based on it's TemporalPerspective ITimeData timeData = m_temporalLayer as ITimeData; timeData.UseTime = false; //create a temporal operator that will serve as a base time for the tracking environment ITemporalOperator3 temporalOpBaseTime = new TemporalOperatorClass() as ITemporalOperator3; //set the base time to 6PM, Aug 3 2000 temporalOpBaseTime.SetDateTime(2000, 8, 3, 18, 0, 0, 0); //create the renderer for the temporal layer ITemporalRenderer temporalRenderer = setRenderer(featureClass, "DATE_TIME", "EVENTID"); //create the temporal layer for the playback data m_temporalLayer = new TemporalFeatureLayerClass(); //assign the featureclass for the layer ((IFeatureLayer)m_temporalLayer).FeatureClass = featureClass; //set the base time to initialize the time window of the layer m_temporalLayer.RelativeTimeOperator = (ITemporalOperator)temporalOpBaseTime; //set the renderer for the temporal layer m_temporalLayer.Renderer = temporalRenderer as IFeatureRenderer; //set the flag in order to display the track of previous locations m_temporalLayer.DisplayOnlyLastKnownEvent = false; //initialize labels for the event name setupLayerLabels(m_temporalLayer, "EVENTID"); m_activeView = ArcMap.Document.ActiveView; m_temporalEnv = trackingEnv; m_baseTime = temporalOpBaseTime; //add the temporal layer to the map ArcMap.Document.FocusMap.AddLayer((ILayer)m_temporalLayer); //enable the timer m_timer.Enabled = true; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } } else { //disable the timer m_timer.Enabled = false; if (null == m_temporalLayer) { return; } //remove the layer ArcMap.Document.FocusMap.DeleteLayer((ILayer)m_temporalLayer); m_temporalLayer = null; } m_bIsConnected = !m_bIsConnected; m_docEvent = ArcMap.Document as IDocumentEvents_Event; m_docEvent.CloseDocument += new IDocumentEvents_CloseDocumentEventHandler(docEvent_CloseDocument); ArcMap.Application.CurrentTool = null; }
protected override void OnClick() { IMxDocument pMxDoc = ArcMap.Document; if (pMxDoc.SelectedLayer == null) { MessageBox.Show("There is no layer selected. First select a time-aware layer."); return; } IFeatureLayer pFLyr = pMxDoc.SelectedLayer as IFeatureLayer; ITimeData pTimeData = pFLyr as ITimeData; if (!pTimeData.SupportsTime) { MessageBox.Show("Select a time-aware layer first."); return; } m_myLayerTimeExtent = pTimeData.GetFullTimeExtent(); ITimeDataDisplay pTimeDataDisplayProperties = pFLyr as ITimeDataDisplay; esriTimeUnits LayerIntervalUnits = pTimeDataDisplayProperties.TimeIntervalUnits; double LayerInterval = pTimeDataDisplayProperties.TimeInterval; ITime startTime = m_myLayerTimeExtent.StartTime; ITime endTime = (ITime)((IClone)startTime).Clone(); switch (LayerIntervalUnits) { case esriTimeUnits.esriTimeUnitsYears: ((ITimeOffsetOperator)endTime).AddYears(LayerInterval, false, true); break; case esriTimeUnits.esriTimeUnitsMonths: ((ITimeOffsetOperator)endTime).AddMonths(LayerInterval, false, true); break; case esriTimeUnits.esriTimeUnitsDays: ((ITimeOffsetOperator)endTime).AddDays(LayerInterval); break; case esriTimeUnits.esriTimeUnitsHours: ((ITimeOffsetOperator)endTime).AddHours(LayerInterval); break; case esriTimeUnits.esriTimeUnitsMinutes: ((ITimeOffsetOperator)endTime).AddMinutes(LayerInterval); break; case esriTimeUnits.esriTimeUnitsSeconds: ((ITimeOffsetOperator)endTime).AddSeconds(LayerInterval); break; } ITimeExtent pTimeExt = new TimeExtentClass(); pTimeExt.SetExtent(startTime, endTime); m_layerInterval = pTimeExt.QueryTimeDuration(); m_sliderDlg = new TimeSliderDialog(this); m_sliderDlg.Show(); }