//Reset the statistic's message rate for one or all of the layers in the map private void btnResetMsgRate_Click(object sender, EventArgs e) { try { ITemporalLayer temporalLayer = GetSelectedTemporalLayer(); if (temporalLayer == null) { if (m_amsWorkspaceFactory == null) { m_amsWorkspaceFactory = new AMSWorkspaceFactoryClass(); } //Get the AMS Workspace Factory Statistics interface ITemporalWorkspaceStatistics temporalWsfStatistics = (ITemporalWorkspaceStatistics)m_amsWorkspaceFactory; temporalWsfStatistics.ResetAllMessageRates(); } else { ITemporalFeatureClassStatistics temporalFCStats = (ITemporalFeatureClassStatistics)((IFeatureLayer)temporalLayer).FeatureClass; temporalFCStats.ResetMessageRate(); } } catch (Exception ex) { statusBarXY.Text = ex.Message; } }
//Set the sampling size for one or all of the layers in the map //The sampling size determines how many messages are factored into the message rate calculation. //For instance a sampling size of 500 will store the times the last 500 messages were received. //The message rate is calculated as the (oldest timestamp - current time) / number of messages private void SetSampleSize() { try { int samplingSize = Convert.ToInt32(txtSampleSize.Text); ITemporalLayer temporalLayer = GetSelectedTemporalLayer(); if (temporalLayer == null) { if (m_amsWorkspaceFactory == null) { m_amsWorkspaceFactory = new AMSWorkspaceFactoryClass(); } //Get the AMS Workspace Factory Statistics interface ITemporalWorkspaceStatistics temporalWsfStatistics = (ITemporalWorkspaceStatistics)m_amsWorkspaceFactory; temporalWsfStatistics.SetAllSampleSizes(samplingSize); } else { ITemporalFeatureClassStatistics temporalFCStats = (ITemporalFeatureClassStatistics)((IFeatureLayer)temporalLayer).FeatureClass; temporalFCStats.SampleSize = samplingSize; } } catch (Exception ex) { statusBarXY.Text = ex.Message; } }
//Refresh the statistics for all tracking layers in the map //The AMSWorkspaceFactory provides easy access to query the statistics for every layer at once private void RefreshAllStatistics() { try { object oNames, oValues; string[] sNames; if (m_amsWorkspaceFactory == null) { m_amsWorkspaceFactory = new AMSWorkspaceFactoryClass(); } //Get the AMS Workspace Factory Statistics interface ITemporalWorkspaceStatistics temporalWsfStatistics = (ITemporalWorkspaceStatistics)m_amsWorkspaceFactory; //Get the message rates for all the tracking connections in the map IPropertySet psMessageRates = temporalWsfStatistics.AllMessageRates; psMessageRates.GetAllProperties(out oNames, out oValues); sNames = (string[])oNames; object[] oaMessageRates = (object[])oValues; //Get the feature counts for all the tracking connections in the map IPropertySet psTotalFeatureCounts = temporalWsfStatistics.AllTotalFeatureCounts; psTotalFeatureCounts.GetAllProperties(out oNames, out oValues); object[] oaFeatureCounts = (object[])oValues; //Get the connection status for all the tracking connections in the map IPropertySet psConnectionStatus = temporalWsfStatistics.ConnectionStatus; psConnectionStatus.GetAllProperties(out oNames, out oValues); string[] sConnectionNames = (string[])oNames; object[] oaConnectionStatus = (object[])oValues; Hashtable htConnectionStatus = new Hashtable(sConnectionNames.Length); for (int i = 0; i < sConnectionNames.Length; ++i) { htConnectionStatus.Add(sConnectionNames[i], oaConnectionStatus[i]); } //Get the track counts for all the tracking connections in the map IPropertySet psTrackCounts = temporalWsfStatistics.AllTrackCounts; psTrackCounts.GetAllProperties(out oNames, out oValues); object[] oaTrackCounts = (object[])oValues; //Get the sample sizes for all the tracking connections in the map IPropertySet psSampleSizes = temporalWsfStatistics.AllSampleSizes; psSampleSizes.GetAllProperties(out oNames, out oValues); object[] oaSampleSizes = (object[])oValues; //Clear the existing list view items and repopulate from the collection lvStatistics.BeginUpdate(); lvStatistics.Items.Clear(); //Create list view items from statistics' IPropertySets for (int i = 0; i < sNames.Length; ++i) { ListViewItem lvItem = new ListViewItem(sNames[i]); lvItem.SubItems.Add(Convert.ToString(oaMessageRates[i])); lvItem.SubItems.Add(Convert.ToString(oaFeatureCounts[i])); string sConnName = sNames[i].Split(new Char[] { '/' })[0]; esriWorkspaceConnectionStatus eWCS = (esriWorkspaceConnectionStatus)Convert.ToInt32(htConnectionStatus[sConnName]); lvItem.SubItems.Add(eWCS.ToString()); lvItem.SubItems.Add(Convert.ToString(oaTrackCounts[i])); lvItem.SubItems.Add(Convert.ToString(oaSampleSizes[i])); lvStatistics.Items.Add(lvItem); } lvStatistics.EndUpdate(); } catch (System.Exception ex) { statusBarXY.Text = ex.Message; } }