本文整理汇总了C#中Ticks类的典型用法代码示例。如果您正苦于以下问题:C# Ticks类的具体用法?C# Ticks怎么用?C# Ticks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ticks类属于命名空间,在下文中一共展示了Ticks类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Frame
/// <summary>
/// Constructs a new <see cref="Frame"/> given the specified parameters.
/// </summary>
/// <param name="timestamp">Timestamp, in ticks, for this <see cref="Frame"/>.</param>
/// <param name="measurements">Initial set of measurements to load into the <see cref="Frame"/>, if any.</param>
public Frame(Ticks timestamp, IDictionary<MeasurementKey, IMeasurement> measurements)
{
m_timestamp = timestamp;
m_receivedTimestamp = DateTime.UtcNow.Ticks;
m_measurements = new ConcurrentDictionary<MeasurementKey, IMeasurement>(measurements);
m_sortedMeasurements = -1;
}
示例2: Timestamp
/// <summary>
/// Creates a new instance of the <see cref="Timestamp"/> from an existing line image.
/// </summary>
/// <param name="lineImage">Line image to parse.</param>
public Timestamp(string lineImage)
{
string[] parts = lineImage.Split(':');
double seconds;
double milliseconds = 0.0D;
if (parts.Length == 4)
{
double.TryParse(parts[parts.Length - 1], out milliseconds);
parts = new[] { parts[0], parts[1], parts[2] };
}
double.TryParse(parts[parts.Length - 1], out seconds);
seconds += milliseconds;
parts[parts.Length - 1] = seconds.ToString("00.000000");
lineImage = string.Join(":", parts).RemoveWhiteSpace();
DateTime result;
DateTime.TryParseExact(lineImage, new[] {"d/M/yyyy,H:mm:ss.ffffff", "M/d/yyyy,H:mm:ss.ffffff"}, CultureInfo.InvariantCulture, DateTimeStyles.None, out result);
Value = result.Ticks;
}
示例3: TimestampTest
/// <summary>
/// Initializes a new instance of the <see cref="TimestampTest"/> class.
/// </summary>
public TimestampTest()
{
m_badTimestampMeasurements = new Dictionary<Ticks, LinkedList<IMeasurement>>();
m_timeToPurge = Ticks.FromSeconds(1.0);
m_warnInterval = Ticks.FromSeconds(4.0);
m_purgeTimer = new Timer();
m_warningTimer = new Timer();
}
示例4: Measurement
/// <summary>
/// Constructs a new <see cref="Measurement"/> using default settings.
/// </summary>
public Measurement()
{
#if UseHighResolutionTime
m_receivedTimestamp = PrecisionTimer.UtcNow.Ticks;
#else
m_receivedTimestamp = DateTime.UtcNow.Ticks;
#endif
m_multiplier = 1.0D;
}
示例5: FlatlineTest
/// <summary>
/// Creates a new instance of the <see cref="FlatlineTest"/> class.
/// </summary>
public FlatlineTest()
{
m_minFlatline = Ticks.FromSeconds(4);
m_warnInterval = Ticks.FromSeconds(4);
m_emailInterval = Ticks.FromSeconds(3600);
m_smtpServer = Mail.DefaultSmtpServer;
m_lastChange = new Dictionary<MeasurementKey, IMeasurement>();
m_lastNotified = new Dictionary<MeasurementKey, Ticks>();
m_warningTimer = new Timer();
}
示例6: TemporalMeasurement
/// <summary>
/// Constructs a new <see cref="TemporalMeasurement"/> given the specified parameters.
/// </summary>
/// <param name="id">Numeric ID of the <see cref="TemporalMeasurement"/>.</param>
/// <param name="source">Source of the <see cref="TemporalMeasurement"/>(e.g., name of archive).</param>
/// <param name="value">Value of the <see cref="TemporalMeasurement"/>.</param>
/// <param name="timestamp">Timestamp of the <see cref="TemporalMeasurement"/>.</param>
/// <param name="lagTime">Past time deviation tolerance, in seconds - this becomes the amount of time to wait before publishing begins.</param>
/// <param name="leadTime">Future time deviation tolerance, in seconds - this becomes the tolerated +/- accuracy of the local clock to real-time.</param>
public TemporalMeasurement(uint id, string source, double value, Ticks timestamp, double lagTime, double leadTime)
: base(id, source, value, timestamp)
{
if (lagTime <= 0)
throw new ArgumentOutOfRangeException("lagTime", "lagTime must be greater than zero, but it can be less than one");
if (leadTime <= 0)
throw new ArgumentOutOfRangeException("leadTime", "leadTime must be greater than zero, but it can be less than one");
m_lagTime = lagTime;
m_leadTime = leadTime;
}
示例7: Main
static void Main(string[] args)
{
//Using delegates write a class Timer that has can execute certain method at each t seconds.
Timer objct = new Timer();
Ticks timer = new Ticks(objct.Ticksing);//the delegate calls the method
while (true)
{
Thread.Sleep(60);//every 60 ms a number is printed
timer(10);
}
}
示例8: Frame
/// <summary>
/// Constructs a new <see cref="Frame"/> given the specified parameters.
/// </summary>
/// <param name="timestamp">Timestamp, in ticks, for this <see cref="Frame"/>.</param>
/// <param name="expectedMeasurements">Expected number of measurements for the <see cref="Frame"/>.</param>
public Frame(Ticks timestamp, int expectedMeasurements)
{
m_timestamp = timestamp;
#if UseHighResolutionTime
m_receivedTimestamp = PrecisionTimer.UtcNow.Ticks;
#else
m_receivedTimestamp = DateTime.UtcNow.Ticks;
#endif
if (expectedMeasurements > 0)
m_measurements = new ConcurrentDictionary<MeasurementKey, IMeasurement>(s_defaultConcurrencyLevel, expectedMeasurements * 2);
else
m_measurements = new ConcurrentDictionary<MeasurementKey, IMeasurement>();
m_sortedMeasurements = -1;
}
示例9: OnData
/// <summary>
/// Data arriving here will now be filtered.
/// </summary>
/// <param name="data">Ticks data array</param>
public void OnData(Ticks data)
{
if (!data.ContainsKey("SPY")) return;
var spyTickList = data["SPY"];
//Ticks return a list of ticks this second
foreach (var tick in spyTickList)
{
Log(tick.Exchange);
}
if (!Portfolio.Invested)
{
SetHoldings("SPY", 1);
}
}
示例10: ConfigurationFrame
/// <summary>
/// Creates a new <see cref="ConfigurationFrame"/> from specified parameters.
/// </summary>
/// <param name="idCode">The ID code of this <see cref="ConfigurationFrame"/>.</param>
/// <param name="timestamp">The exact timestamp, in <see cref="Ticks"/>, of the data represented by this <see cref="ConfigurationFrame"/>.</param>
/// <param name="frameRate">The defined frame rate of this <see cref="ConfigurationFrame"/>.</param>
/// <param name="nominalFrequency">The nominal <see cref="LineFrequency"/> of this <see cref="ConfigurationFrame"/>.</param>
/// <param name="timeOffset">The time offset of F-NET device in <see cref="Ticks"/>.</param>
/// <param name="stationName">The station name of the F-NET device.</param>
/// <remarks>
/// This constructor is used by a consumer to generate an F-NET configuration frame.
/// </remarks>
public ConfigurationFrame(ushort idCode, Ticks timestamp, ushort frameRate, LineFrequency nominalFrequency, Ticks timeOffset, string stationName)
: base(idCode, new ConfigurationCellCollection(), timestamp, frameRate)
{
ConfigurationCell configCell = new ConfigurationCell(this, nominalFrequency, timeOffset);
// FNet protocol sends data for one device
Cells.Add(configCell);
// Assign station name
if (string.IsNullOrEmpty(stationName))
configCell.StationName = "F-NET Unit-" + idCode;
else
configCell.StationName = stationName;
// Add a single frequency definition
configCell.FrequencyDefinition = new FrequencyDefinition(configCell, "Line frequency");
// Add a single phasor definition
configCell.PhasorDefinitions.Add(new PhasorDefinition(configCell, "120V Phasor", PhasorType.Voltage, null));
}
示例11: ProcessDataGap
// Any exceptions in this handler will be exposed through ProcessException event and cause OutageLogProcessor
// to requeue the data gap outage so it will be processed again (could be that remote system is offline).
private void ProcessDataGap(Outage dataGap)
{
// Establish start and stop time for temporal session
m_subscriptionInfo.StartTime = dataGap.Start.ToString(OutageLog.DateTimeFormat, CultureInfo.InvariantCulture);
m_subscriptionInfo.StopTime = dataGap.End.ToString(OutageLog.DateTimeFormat, CultureInfo.InvariantCulture);
OnStatusMessage("Starting data gap recovery for period \"{0}\" - \"{1}\"...", m_subscriptionInfo.StartTime, m_subscriptionInfo.StopTime);
// Enable data monitor
m_dataStreamMonitor.Enabled = true;
// Reset measurement counters
m_measurementsRecoveredForDataGap = 0;
m_measurementsRecoveredOverLastInterval = 0;
// Reset processing fields
m_mostRecentRecoveredTime = dataGap.Start.Ticks;
m_abnormalTermination = false;
// Reset process completion wait handle
m_dataGapRecoveryCompleted.Reset();
// Start temporal data recovery session
m_temporalSubscription.Subscribe(m_subscriptionInfo);
// Wait for process completion - success or fail
m_dataGapRecoveryCompleted.Wait();
// If temporal session failed to connect, retry data recovery for this outage
if (m_abnormalTermination)
{
// Make sure any data recovered so far doesn't get unnecessarily re-recovered, this requires that source historian report data in time-sorted order
dataGap = new Outage(new DateTime(GSF.Common.Max((Ticks)dataGap.Start.Ticks, m_mostRecentRecoveredTime - (m_subscriptionInfo.UseMillisecondResolution ? Ticks.PerMillisecond : 1L)), DateTimeKind.Utc), dataGap.End);
// Re-insert adjusted data gap at the top of the processing queue
m_dataGapLog.Insert(0, dataGap);
FlushLogAsync();
if (m_measurementsRecoveredForDataGap == 0)
OnStatusMessage("WARNING: Failed to establish temporal session. Data recovery for period \"{0}\" - \"{1}\" will be re-attempted.", m_subscriptionInfo.StartTime, m_subscriptionInfo.StopTime);
else
OnStatusMessage("WARNING: Temporal session was disconnected during recovery operation. Data recovery for adjusted period \"{0}\" - \"{1}\" will be re-attempted.", dataGap.Start.ToString(OutageLog.DateTimeFormat, CultureInfo.InvariantCulture), m_subscriptionInfo.StopTime);
}
// Disconnect temporal session
m_temporalSubscription.Stop();
// Disable data monitor
m_dataStreamMonitor.Enabled = false;
OnStatusMessage("{0}Recovered {1} measurements for period \"{2}\" - \"{3}\".", m_measurementsRecoveredForDataGap == 0 ? "WARNING: " : "", m_measurementsRecoveredForDataGap, m_subscriptionInfo.StartTime, m_subscriptionInfo.StopTime);
}
示例12: OnData
public void OnData(Ticks ticks)
{
}
示例13: ConfigurationFrame3
/// <summary>
/// Creates a new <see cref="ConfigurationFrame3"/> from specified parameters.
/// </summary>
/// <param name="timebase">Timebase to use for fraction second resolution.</param>
/// <param name="idCode">The ID code of this <see cref="ConfigurationFrame3"/>.</param>
/// <param name="timestamp">The exact timestamp, in <see cref="Ticks"/>, of the data represented by this <see cref="ConfigurationFrame3"/>.</param>
/// <param name="frameRate">The defined frame rate of this <see cref="ConfigurationFrame3"/>.</param>
/// <remarks>
/// This constructor is used by a consumer to generate an IEEE C37.118 configuration frame, type 3.
/// </remarks>
public ConfigurationFrame3(uint timebase, ushort idCode, Ticks timestamp, ushort frameRate)
: base(timebase, idCode, timestamp, frameRate)
{
}
示例14: CheckDelay
// Keeps track of the signal's timestamps to determine whether a given
// measurement is eligible to raise the alarm based on the delay.
private bool CheckDelay(IMeasurement measurement, bool raiseCondition)
{
Ticks dist;
if (!raiseCondition)
{
// Keep track of the last time
// the signal failed the raise test
m_lastNegative = measurement.Timestamp;
}
else
{
// Get the amount of time since the last
// time the signal failed the raise test
dist = measurement.Timestamp - m_lastNegative;
// If the amount of time is larger than
// the delay threshold, raise the alarm
if (dist >= Ticks.FromSeconds(m_delay.GetValueOrDefault()))
return true;
}
return false;
}
示例15: Create
/// <summary>
/// Creates a new <see cref="TimeSlice"/> for the specified time using the specified data
/// </summary>
/// <param name="utcDateTime">The UTC frontier date time</param>
/// <param name="algorithmTimeZone">The algorithm's time zone, required for computing algorithm and slice time</param>
/// <param name="cashBook">The algorithm's cash book, required for generating cash update pairs</param>
/// <param name="data">The data in this <see cref="TimeSlice"/></param>
/// <param name="changes">The new changes that are seen in this time slice as a result of universe selection</param>
/// <returns>A new <see cref="TimeSlice"/> containing the specified data</returns>
public static TimeSlice Create(DateTime utcDateTime, DateTimeZone algorithmTimeZone, CashBook cashBook, List<KeyValuePair<Security, List<BaseData>>> data, SecurityChanges changes)
{
int count = 0;
var security = new List<KeyValuePair<Security, BaseData>>();
var custom = new List<KeyValuePair<Security, List<BaseData>>>();
var consolidator = new List<KeyValuePair<SubscriptionDataConfig, List<BaseData>>>();
var allDataForAlgorithm = new List<BaseData>(data.Count);
var cash = new List<KeyValuePair<Cash, BaseData>>(cashBook.Count);
var cashSecurities = new HashSet<Symbol>();
foreach (var cashItem in cashBook.Values)
{
cashSecurities.Add(cashItem.SecuritySymbol);
}
Split split;
Dividend dividend;
Delisting delisting;
SymbolChangedEvent symbolChange;
var algorithmTime = utcDateTime.ConvertFromUtc(algorithmTimeZone);
var tradeBars = new TradeBars(algorithmTime);
var ticks = new Ticks(algorithmTime);
var splits = new Splits(algorithmTime);
var dividends = new Dividends(algorithmTime);
var delistings = new Delistings(algorithmTime);
var symbolChanges = new SymbolChangedEvents(algorithmTime);
foreach (var kvp in data)
{
var list = kvp.Value;
var symbol = kvp.Key.Symbol;
// keep count of all data points
if (list.Count == 1 && list[0] is BaseDataCollection)
{
count += ((BaseDataCollection) list[0]).Data.Count;
}
else
{
count += list.Count;
}
BaseData update = null;
var consolidatorUpdate = new List<BaseData>(list.Count);
for (int i = 0; i < list.Count; i++)
{
var baseData = list[i];
if (!kvp.Key.SubscriptionDataConfig.IsInternalFeed)
{
// this is all the data that goes into the algorithm
allDataForAlgorithm.Add(baseData);
if (kvp.Key.SubscriptionDataConfig.IsCustomData)
{
// this is all the custom data
custom.Add(kvp);
}
}
// don't add internal feed data to ticks/bars objects
if (baseData.DataType != MarketDataType.Auxiliary)
{
if (!kvp.Key.SubscriptionDataConfig.IsInternalFeed)
{
// populate ticks and tradebars dictionaries with no aux data
if (baseData.DataType == MarketDataType.Tick)
{
List<Tick> ticksList;
if (!ticks.TryGetValue(symbol, out ticksList))
{
ticksList = new List<Tick> {(Tick) baseData};
ticks[symbol] = ticksList;
}
ticksList.Add((Tick) baseData);
}
else if (baseData.DataType == MarketDataType.TradeBar)
{
tradeBars[symbol] = (TradeBar) baseData;
}
// this is data used to update consolidators
consolidatorUpdate.Add(baseData);
}
// this is the data used set market prices
update = baseData;
}
// include checks for various aux types so we don't have to construct the dictionaries in Slice
else if ((delisting = baseData as Delisting) != null)
{
delistings[symbol] = delisting;
}
//.........这里部分代码省略.........