• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Ticks类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Ticks的典型用法代码示例。如果您正苦于以下问题:C# Ticks类的具体用法?C# Ticks怎么用?C# Ticks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Ticks类属于命名空间,在下文中一共展示了Ticks类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
 }
开发者ID:rmc00,项目名称:gsf,代码行数:12,代码来源:Frame.cs


示例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;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:30,代码来源:Timestamp.cs


示例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();
 }
开发者ID:rmc00,项目名称:gsf,代码行数:11,代码来源:TimestampTest.cs


示例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;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:12,代码来源:Measurement.cs


示例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();
        }
开发者ID:GridProtectionAlliance,项目名称:gsf,代码行数:14,代码来源:FlatlineTest.cs


示例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;
        }
开发者ID:avs009,项目名称:gsf,代码行数:21,代码来源:TemporalMeasurement.cs


示例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);
            }
        }
开发者ID:sbaychev,项目名称:TelerikAcademy,代码行数:13,代码来源:Program.cs


示例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;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:20,代码来源:Frame.cs


示例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);
            }
        }
开发者ID:skyfyl,项目名称:Lean,代码行数:20,代码来源:TickDataFilteringAlgorithm.cs


示例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));
        }
开发者ID:avs009,项目名称:gsf,代码行数:32,代码来源:ConfigurationFrame.cs


示例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);
        }
开发者ID:avs009,项目名称:gsf,代码行数:54,代码来源:DataGapRecoverer.cs


示例12: OnData

 public void OnData(Ticks ticks)
 {
 }
开发者ID:kevinalexanderwong,项目名称:QCAlgorithm,代码行数:3,代码来源:1_Algorithm_BasicTemplate.cs


示例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)
 {
 }
开发者ID:rmc00,项目名称:gsf,代码行数:14,代码来源:ConfigurationFrame3.cs


示例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;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:26,代码来源:Alarm.cs


示例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;
                    }
//.........这里部分代码省略.........
开发者ID:bizcad,项目名称:LeanJJN,代码行数:101,代码来源:TimeSlice.cs


示例16: CreateSchema

        /// <summary>
        /// Creates a new COMTRADE configuration <see cref="Schema"/>.
        /// </summary>
        /// <param name="metadata">Schema <see cref="ChannelMetadata"/> records.</param>
        /// <param name="stationName">Station name for the schema.</param>
        /// <param name="deviceID">Device ID for the schema.</param>
        /// <param name="dataStartTime">Data start time.</param>
        /// <param name="sampleCount">Total data samples (i.e., total number of rows).</param>
        /// <param name="isBinary">Determines if data file should be binary or ASCII - defaults to <c>true</c> for binary.</param>
        /// <param name="timeFactor">Time factor to use in schema - defaults to 1000.</param>
        /// <param name="samplingRate">Desired sampling rate - defaults to 33.3333Hz.</param>
        /// <param name="nominalFrequency">Nominal frequency - defaults to 60Hz.</param>
        /// <param name="includeFracSecDefinition">Determines if the FRACSEC word digital definitions should be included - defaults to <c>true</c>.</param>
        /// <returns>New COMTRADE configuration <see cref="Schema"/>.</returns>
        /// <remarks>
        /// This function is primarily intended to create a configuration based on synchrophasor data
        /// (see Annex H: Schema for Phasor Data 2150 Using the COMTRADE File Standard in IEEE C37.111-2010),
        /// it may be necessary to manually create a schema object for other COMTRADE needs. You can call
        /// the <see cref="Schema.FileImage"/> property to return a string that that can be written to a file
        /// that will be the contents of the configuration file.
        /// </remarks>
        public static Schema CreateSchema(IEnumerable<ChannelMetadata> metadata, string stationName, string deviceID, Ticks dataStartTime, int sampleCount, bool isBinary = true, double timeFactor = 1.0D, double samplingRate = 30.0D, double nominalFrequency = 60.0D, bool includeFracSecDefinition = true)
        {
            Schema schema = new Schema();

            schema.StationName = stationName;
            schema.DeviceID = deviceID;

            SampleRate samplingFrequency = new SampleRate();
            samplingFrequency.Rate = samplingRate;
            samplingFrequency.EndSample = sampleCount;

            schema.SampleRates = new[] { samplingFrequency };

            Timestamp startTime;
            startTime.Value = dataStartTime;
            schema.StartTime = startTime;
            schema.TriggerTime = startTime;

            schema.FileType = isBinary ? FileType.Binary : FileType.Ascii;
            schema.TimeFactor = timeFactor;

            List<AnalogChannel> analogChannels = new List<AnalogChannel>();
            List<DigitalChannel> digitalChannels = new List<DigitalChannel>();
            int analogIndex = 1;
            int digitalIndex = 1;

            if (includeFracSecDefinition)
            {
                // Add default time quality digitals for IEEE C37.118 FRACSEC word. Note that these flags, as
                // defined in Annex H of the IEEE C37.111-2010 standard, assume full export was all from one
                // source device. This a poor assumption since data can be exported from historical data for any
                // number of points which could have come from any number of devices all with different FRACSEC
                // values. Regardless there is only one FRACSEC definition defined and, if included, it must
                // come as the first set of digitals in the COMTRADE configuration.
                for (int i = 0; i < 4; i++)
                {
                    digitalChannels.Add(new DigitalChannel
                    {
                        Index = digitalIndex,
                        Name = "TQ_CNT" + i,
                        PhaseID = "T" + digitalIndex++
                    });
                }

                digitalChannels.Add(new DigitalChannel
                {
                    Index = digitalIndex,
                    Name = "TQ_LSPND",
                    PhaseID = "T" + digitalIndex++
                });


                digitalChannels.Add(new DigitalChannel
                {
                    Index = digitalIndex,
                    Name = "TQ_LSOCC",
                    PhaseID = "T" + digitalIndex++
                });

                digitalChannels.Add(new DigitalChannel
                {
                    Index = digitalIndex,
                    Name = "TQ_LSDIR",
                    PhaseID = "T" + digitalIndex++
                });

                digitalChannels.Add(new DigitalChannel
                {
                    Index = digitalIndex,
                    Name = "RSV",
                    PhaseID = "T" + digitalIndex++
                });

                for (int i = 1; i < 9; i++)
                {
                    digitalChannels.Add(new DigitalChannel
                    {
                        Index = digitalIndex,
                        Name = "RESV" + i,
//.........这里部分代码省略.........
开发者ID:rmc00,项目名称:gsf,代码行数:101,代码来源:Writer.cs


示例17: WriteNextRecordAscii

        /// <summary>
        /// Writes next COMTRADE record in ASCII format.
        /// </summary>
        /// <param name="output">Destination stream.</param>
        /// <param name="schema">Source schema.</param>
        /// <param name="timestamp">Record timestamp (implicitly castable as <see cref="DateTime"/>).</param>
        /// <param name="values">Values to write - 16-bit digitals should exist as a word in an individual double value, method will write out bits.</param>
        /// <param name="sample">User incremented sample index.</param>
        /// <param name="injectFracSecValue">Determines if FRACSEC value should be automatically injected into stream as first digital - defaults to <c>true</c>.</param>
        /// <param name="fracSecValue">FRACSEC value to inject into output stream - defaults to 0x0000.</param>
        /// <remarks>
        /// This function is primarily intended to write COMTRADE ASCII data records based on synchrophasor data
        /// (see Annex H: Schema for Phasor Data 2150 Using the COMTRADE File Standard in IEEE C37.111-2010),
        /// it may be necessary to manually write records for other COMTRADE needs (e.g., non 16-bit digitals).
        /// </remarks>
        public static void WriteNextRecordAscii(StreamWriter output, Schema schema, Ticks timestamp, double[] values, uint sample, bool injectFracSecValue = true, ushort fracSecValue = 0x0000)
        {
            // Make timestamp relative to beginning of file
            timestamp -= schema.StartTime.Value;

            uint microseconds = (uint)(timestamp.ToMicroseconds() / schema.TimeFactor);
            double value;
            StringBuilder line = new StringBuilder();
            bool isFirstDigital = true;

            line.Append(sample);
            line.Append(',');
            line.Append(microseconds);

            for (int i = 0; i < values.Length; i++)
            {
                value = values[i];

                if (i < schema.AnalogChannels.Length)
                {
                    value -= schema.AnalogChannels[i].Adder;
                    value /= schema.AnalogChannels[i].Multiplier;

                    line.Append(',');
                    line.Append(value);
                }
                else
                {
                    if (isFirstDigital)
                    {
                        // Handle automatic injection of IEEE C37.118 FRACSEC digital value if requested
                        isFirstDigital = false;

                        if (injectFracSecValue)
                        {
                            for (int j = 0; j < 16; j++)
                            {
                                line.Append(',');
                                line.Append(fracSecValue.CheckBits(BitExtensions.BitVal(j)) ? 1 : 0);
                            }
                        }
                    }

                    ushort digitalWord = (ushort)value;

                    for (int j = 0; j < 16; j++)
                    {
                        line.Append(',');
                        line.Append(digitalWord.CheckBits(BitExtensions.BitVal(j)) ? 1 : 0);
                    }
                }
            }

            // Make sure FRACSEC values are injected
            if (isFirstDigital && injectFracSecValue)
            {
                for (int j = 0; j < 16; j++)
                {
                    line.Append(',');
                    line.Append(fracSecValue.CheckBits(BitExtensions.BitVal(j)) ? 1 : 0);
                }
            }

            output.WriteLine(line.ToString());
        }
开发者ID:rmc00,项目名称:gsf,代码行数:80,代码来源:Writer.cs


示例18: PublishFrame

        /// <summary>
        /// Process frame of time-aligned measurements that arrived within the defined lag time.
        /// </summary>
        /// <param name="frame"><see cref="IFrame"/> of measurements that arrived within lag time and are ready for processing.</param>
        /// <param name="index">Index of <see cref="IFrame"/> within one second of data ranging from zero to frames per second - 1.</param>
        protected override void PublishFrame(IFrame frame, int index)
        {
            Ticks timestamp = frame.Timestamp;
            ConcurrentDictionary<MeasurementKey, IMeasurement> measurements = frame.Measurements;

            if (measurements.Count > 0)
            {
                lock (m_fileDataLock)
                {
                    IMeasurement measurement;
                    MeasurementKey inputMeasurementKey;
                    SignalType signalType;
                    double measurementValue;

                    if ((object)m_fileData == null)
                    {
                        m_fileData = new StringBuilder();
                        m_startTime = timestamp;
                        m_rowCount = 0;
                    }

                    m_fileData.AppendFormat("{0}", timestamp.ToString("dd-MMM-yyyy HH:mm:ss.fff"));

                    // Export all defined input measurements
                    for (int i = 0; i < InputMeasurementKeys.Length; i++)
                    {
                        m_fileData.Append(',');
                        inputMeasurementKey = InputMeasurementKeys[i];
                        signalType = InputMeasurementKeyTypes[i];

                        // Get measurement for this frame, falling back on latest value
                        measurementValue = measurements.TryGetValue(inputMeasurementKey, out measurement) ? measurement.AdjustedValue : LatestMeasurements[inputMeasurementKey];

                        // Export measurement value making any needed adjustments based on signal type
                        if (signalType == SignalType.VPHM)
                        {
                            // Convert voltages to base units
                            m_fileData.Append(measurementValue / SI.Kilo);
                        }
                        else
                        {
                            // Export all other types of measurements as their raw value
                            m_fileData.Append(measurementValue);
                        }
                    }

                    // Terminate line
                    m_fileData.AppendLine();
                    m_rowCount++;
                }
            }

            // Only publish when the export interval time has passed
            if ((timestamp - m_startTime).ToMilliseconds() > m_exportInterval)
                m_fileExport.TryRunOnceAsync();
        }
开发者ID:GridProtectionAlliance,项目名称:gsf,代码行数:61,代码来源:FileExporter.cs


示例19: UnixTimeTag

 /// <summary>
 /// Creates a new <see cref="UnixTimeTag"/>, given specified <see cref="Ticks"/>.
 /// </summary>
 /// <param name="timestamp">Timestamp in <see cref="Ticks"/> to create Unix timetag from (minimum valid date is 1/1/1970).</param>
 /// <remarks>
 /// This constructor will accept a <see cref="DateTime"/> parameter since <see cref="Ticks"/> is implicitly castable to a <see cref="DateTime"/>.
 /// </remarks>
 public UnixTimeTag(Ticks timestamp)
     : base(BaseTicks, timestamp)
 {
 }
开发者ID:avs009,项目名称:gsf,代码行数:11,代码来源:UnixTimeTag.cs


示例20: Run

        /********************************************************
        * CLASS METHODS
        *********************************************************/
        /// <summary>
        /// Launch the algorithm manager to run this strategy
        /// </summary>
        /// <param name="job">Algorithm job</param>
        /// <param name="algorithm">Algorithm instance</param>
        /// <param name="feed">Datafeed object</param>
        /// <param name="transactions">Transaction manager object</param>
        /// <param name="results">Result handler object</param>
        /// <param name="setup">Setup handler object</param>
        /// <param name="realtime">Realtime processing object</param>
        /// <remarks>Modify with caution</remarks>
        public static void Run(AlgorithmNodePacket job, IAlgorithm algorithm, IDataFeed feed, ITransactionHandler transactions, IResultHandler results, ISetupHandler setup, IRealTimeHandler realtime)
        {
            //Initialize:
            var backwardsCompatibilityMode = false;
            var tradebarsType = typeof (TradeBars);
            var ticksType = typeof(Ticks);
            var startingPerformance = setup.StartingCapital;
            var backtestMode = (job.Type == PacketType.BacktestNode);
            var methodInvokers = new Dictionary<Type, MethodInvoker>();

            //Initialize Properties:
            _frontier = setup.StartingDate;
            _runtimeError = null;
            _algorithmId = job.AlgorithmId;
            _algorithmState = AlgorithmStatus.Running;
            _previousTime = setup.StartingDate.Date;

            //Create the method accessors to push generic types into algorithm: Find all OnData events:

            //Algorithm 1.0 Data Accessors.
            //If the users defined these methods, add them in manually. This allows keeping backwards compatibility to algorithm 1.0.
            var oldTradeBarsMethodInfo = (algorithm.GetType()).GetMethod("OnTradeBar",   new[] { typeof(Dictionary<string, TradeBar>) });
            var oldTicksMethodInfo = (algorithm.GetType()).GetMethod("OnTick", new[] { typeof(Dictionary<string, List<Tick>>) });

            //Algorithm 2.0 Data Generics Accessors.
            //New hidden access to tradebars with custom type.
            var newTradeBarsMethodInfo = (algorithm.GetType()).GetMethod("OnData", new[] { tradebarsType });
            var newTicksMethodInfo = (algorithm.GetType()).GetMethod("OnData", new[] { ticksType });

            if (newTradeBarsMethodInfo == null && newTicksMethodInfo == null)
            {
                backwardsCompatibilityMode = true;
                if (oldTradeBarsMethodInfo != null) methodInvokers.Add(tradebarsType, oldTradeBarsMethodInfo.DelegateForCallMethod());
                if (oldTradeBarsMethodInfo != null) methodInvokers.Add(ticksType, oldTicksMethodInfo.DelegateForCallMethod());
            }
            else
            {
                backwardsCompatibilityMode = false;
                if (newTradeBarsMethodInfo != null) methodInvokers.Add(tradebarsType, newTradeBarsMethodInfo.DelegateForCallMethod());
                if (newTicksMethodInfo != null) methodInvokers.Add(ticksType, newTicksMethodInfo.DelegateForCallMethod());
            }

            //Go through the subscription types and create invokers to trigger the event handlers for each custom type:
            foreach (var config in feed.Subscriptions)
            {
                //If type is a tradebar, combine tradebars and ticks into unified array:
                if (config.Type.Name != &q 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TiffTag类代码示例发布时间:2022-05-24
下一篇:
C# TicketStatus类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap