Beispiel #1
0
            public TraceLogBlock(FeatureId featureId, FunctionId functionId, string message, int uniquePairId, CancellationToken cancellationToken)
            {
                this.featureId = featureId;
                this.functionId = functionId;
                this.uniquePairId = uniquePairId;
                this.cancellationToken = cancellationToken;

                this.watch = Stopwatch.StartNew();
                Trace.WriteLine(string.Format("[{0}] Start({1}) : {2}/{3} - {4}", Thread.CurrentThread.ManagedThreadId, uniquePairId, featureId.ToString(), functionId.ToString(), message));
            }
Beispiel #2
0
        public bool IsEnabled(FunctionId functionId)
        {
            if (!_enabled)
            {
                return(false);
            }

            // Limit logged function IDs to keep a reasonable log file size.
            var str = functionId.ToString();

            return(str.StartsWith("Diagnostic") ||
                   str.StartsWith("CodeAnalysisService") ||
                   str.StartsWith("Workspace") ||
                   str.StartsWith("WorkCoordinator") ||
                   str.StartsWith("IncrementalAnalyzerProcessor") ||
                   str.StartsWith("ExternalErrorDiagnosticUpdateSource"));
        }
        /// <summary>
        /// MemoizerConfiguration hash code format: 5 digits with function ID + 5 digits hash of the rest.
        /// 2^31 == 2 147 483 648 == 21474 83648 => max 21474 different Funcs, and 83648 different expiration configurations...
        /// This has clearly limitations, but it's OK as a proof-of-concept, I guess - it's fixable :-)
        /// </summary>
        public override int GetHashCode()
        {
            if (FunctionId > 21474)
            {
                throw new InvalidOperationException("Memoizer.NET only supports 21474 different Func references at the moment...");
            }
            string funcId = FunctionId.ToString();

            //int expirationConfigHash = MemoizerHelper.PRIMES[15] + ExpirationType.GetHashCode();
            //expirationConfigHash = expirationConfigHash * MemoizerHelper.PRIMES[11] + ExpirationValue.GetHashCode();
            //expirationConfigHash = expirationConfigHash * MemoizerHelper.PRIMES[7] + ExpirationTimeUnit.GetHashCode();
            int expirationConfigHash = HashHelper.PRIMES[15] + ExpirationType.GetHashCode();

            expirationConfigHash = expirationConfigHash * HashHelper.PRIMES[11] + ExpirationValue.GetHashCode();
            expirationConfigHash = expirationConfigHash * HashHelper.PRIMES[7] + ExpirationTimeUnit.GetHashCode();

            expirationConfigHash = expirationConfigHash % 83648;

            return(Convert.ToInt32(funcId + expirationConfigHash));
        }
        public void LogBlockEnd(FunctionId functionId, LogMessage logMessage, int uniquePairId, int delta, CancellationToken cancellationToken)
        {
            var functionString = functionId.ToString() + (cancellationToken.IsCancellationRequested ? " Canceled" : string.Empty);

            roslynLog.WriteLine(string.Format("[{0}] End({1}) : [{2}ms] {3}", Thread.CurrentThread.ManagedThreadId, uniquePairId, delta, functionString));
        }
 public void LogBlockStart(FunctionId functionId, LogMessage logMessage, int uniquePairId, CancellationToken cancellationToken)
 {
     roslynLog.WriteLine(string.Format("[{0}] Start({1}) : {2} - {3}", Thread.CurrentThread.ManagedThreadId, uniquePairId, functionId.ToString(), logMessage.GetMessage()));
 }
 public void Log(FunctionId functionId, LogMessage logMessage)
 {
     roslynLog.WriteLine(string.Format("[{0}] {1} - {2}", Thread.CurrentThread.ManagedThreadId, functionId.ToString(), logMessage.GetMessage()));
 }
Beispiel #7
0
 public void LogBlockEnd(FunctionId functionId, LogMessage logMessage, int uniquePairId, int delta, CancellationToken cancellationToken)
 {
     var functionString = functionId.ToString() + (cancellationToken.IsCancellationRequested ? " Canceled" : string.Empty);
     Trace.WriteLine(string.Format("[{0}] End({1}) : [{2}ms] {3}", Thread.CurrentThread.ManagedThreadId, uniquePairId, delta, functionString));
 }
Beispiel #8
0
 public void LogBlockStart(FunctionId functionId, LogMessage logMessage, int uniquePairId, CancellationToken cancellationToken)
 {
     Trace.WriteLine(string.Format("[{0}] Start({1}) : {2} - {3}", Thread.CurrentThread.ManagedThreadId, uniquePairId, functionId.ToString(), logMessage.GetMessage()));
 }
Beispiel #9
0
 public void Log(FunctionId functionId, LogMessage logMessage)
 {
     Trace.WriteLine(string.Format("[{0}] {1} - {2}", Thread.CurrentThread.ManagedThreadId, functionId.ToString(), logMessage.GetMessage()));
 }
Beispiel #10
0
 public void Log(FeatureId featureId, FunctionId functionId, string message)
 {
     Trace.WriteLine(string.Format("[{0}] {1}/{2} - {3}", Thread.CurrentThread.ManagedThreadId, featureId.ToString(), functionId.ToString(), message));
 }
Beispiel #11
0
 public void LogBlockStart(FunctionId functionId, LogMessage logMessage, int uniquePairId, CancellationToken cancellationToken)
 {
     // Fixme at some point
     LoggingService.LogError("Roslyn error: {0} {1}", functionId.ToString(), logMessage?.GetMessage());
 }
Beispiel #12
0
 public void Log(FunctionId functionId, LogMessage logMessage)
 {
     LoggingService.LogError("Roslyn error: {0} {1}", functionId.ToString(), logMessage?.GetMessage());
 }
Beispiel #13
0
        unsafe private void timer_Tick(object sender, EventArgs e)
        {
            UInt32 res = new UInt32();

            res = VCI_Receive(CANLib.USB_CAN2, 0, SelectedCanChannel, ref CanReceivedrecobj[0], CANLib.MAX_RECEVIEDPACKETS, 100);
            string str = "";

            byte[] data = new byte[8];
            for (UInt32 i = 0; i < res; i++)
            {
                if (CanReceivedrecobj[i].RemoteFlag == 1)
                {
                    continue;
                }

                ListViewItem item = new ListViewItem();
                if (CanReceivedrecobj[i].ExternFlag == 1)
                {
                    item.Text = "Ext";
                }
                else
                {
                    item.Text = "Std";
                }
                if (IsCaptureCanPackets)
                {
                    item.SubItems.Add("0x" + CanReceivedrecobj[i].ID.ToString("X8"));
                }

                byte len = (byte)(CanReceivedrecobj[i].DataLen % 9);
                byte j   = 0;
                str = "";
                fixed(VCI_CAN_OBJ *m_recobj1 = &CanReceivedrecobj[i])
                {
                    if (j++ < len)
                    {
                        str += String.Format("{0:X2}", (int)m_recobj1->Data[0]);
                    }
                    if (j++ < len)
                    {
                        str += String.Format(" {0:X2}", (int)m_recobj1->Data[1]);
                    }
                    if (j++ < len)
                    {
                        str += String.Format(" {0:X2}", (int)m_recobj1->Data[2]);
                    }
                    if (j++ < len)
                    {
                        str += String.Format(" {0:X2}", (int)m_recobj1->Data[3]);
                    }
                    if (j++ < len)
                    {
                        str += String.Format(" {0:X2}", (int)m_recobj1->Data[4]);
                    }
                    if (j++ < len)
                    {
                        str += String.Format(" {0:X2}", (int)m_recobj1->Data[5]);
                    }
                    if (j++ < len)
                    {
                        str += String.Format(" {0:X2}", (int)m_recobj1->Data[6]);
                    }
                    if (j++ < len)
                    {
                        str += String.Format(" {0:X2}", (int)m_recobj1->Data[7]);
                    }
                }

                if (IsCaptureCanPackets)
                {
                    item.SubItems.Add(str); //Data field.
                    int TargetId = (int)((CanReceivedrecobj[i].ID & 0x00ff0000) >> 16);
                    item.SubItems.Add("0x" + TargetId.ToString("X2"));
                    int SourceId = (int)((CanReceivedrecobj[i].ID & 0x0000ff00) >> 8);
                    item.SubItems.Add("0x" + SourceId.ToString("X2"));
                }



                int funcId = (int)(CanReceivedrecobj[i].ID & 0x000000ff);
                BOOTLOADER_FUNCTIONS FunctionId;
                try
                {
                    FunctionId = (BOOTLOADER_FUNCTIONS)funcId;
                }
                catch
                {
                    FunctionId = BOOTLOADER_FUNCTIONS.FUNCTION_CUSTIOM;
                }
                str = AnalysisPacketContents(funcId, str);
                if (IsCanFirmwareDownloading)
                {
                }
                else if (IsCaptureCanPackets)
                {
                    item.SubItems.Add("0x" + funcId.ToString("X2") + ":" + FunctionId.ToString());
                    item.SubItems.Add(str);
                    lstReceivedMessage.Items.Add(item);
                    lstReceivedMessage.Items[lstReceivedMessage.Items.Count - 1].EnsureVisible();
                }
            }
        }