Example #1
0
 public bool TryAnalysisReslut()
 {
     // 还没发送
     if (!IsSent)
     {
         return(false);
     }
     if ((DateTime.Now - SendTime).TotalMilliseconds > (Timeout != 0 ? Timeout : 3000))
     {
         if (CmdActions.ContainsKey(CmdKey))
         {
             ReadTime = DateTime.Now;
             Log.debug("告知" + CmdKey + "处理函数超时!");
             CmdActions[CmdKey](this);
         }
         return(true);
     }
     // 正确获得结果
     if (ResultString.StartsWith("TS->"))
     {
         ResultStringList.Add(ResultString);
         Log.shell(ResultString.Replace("\r", ""));
         ResultByte.Clear();
         IsRead = true;
         if (CmdActions.ContainsKey(CmdKey))
         {
             Log.debug("执行" + CmdKey + "的结果分析");
             CmdActions[CmdKey](this);
         }
         return(true);
     }
     return(false);
 }
        /// <summary>
        ///     获取Token
        /// </summary>
        /// <returns></returns>
        public static string GetAdminToken()
        {
            var          organizationApiProvider = new OrganizationApiProvider();
            ResultString resultToken             =
                organizationApiProvider.UserLoginImpersonate(2);

            return(resultToken.ResultValue);
        }
Example #3
0
        private void DeleteLastSymbol()
        {
            if (ResultString.Length == 1)
            {
                return;
            }

            InputString    = InputString.Remove(InputString.Length - 1);
            ResultString   = ResultString.Remove(ResultString.Length - 1);
            _stringBuilder = _stringBuilder.Remove(_stringBuilder.Length - 1, 1);
        }
        public async Task <(List <ResultString>, int)> Search(string term, int desiredAmount)
        {
            var service     = new CustomsearchService();
            var listRequest = service.Cse.List();

            listRequest.Key = ApiKey;
            listRequest.Cx  = Cx;
            listRequest.Q   = term;

            Google.Apis.Customsearch.v1.Data.Search search = await listRequest.ExecuteAsync();

            int.TryParse(search.SearchInformation.TotalResults, out var total);
            var results = new List <ResultString>();

            while (results.Count != desiredAmount)
            {
                for (int i = 0; i < search.Items.Count; i++)
                {
                    if (results.Count == desiredAmount)
                    {
                        break;
                    }
                    var item = search.Items[i];

                    var obj = new ResultString()
                    {
                        Title   = item.Title,
                        Link    = item.Link,
                        Snippet = item.Snippet
                    };
                    results.Add(obj);
                }

                if (results.Count != desiredAmount)
                {
                    var index = results.Count + 1;
                    if (index > 91)
                    {
                        break;
                    }
                    listRequest.Start = index;
                    search            = await listRequest.ExecuteAsync();
                }
            }

            return(results, total);
        }
        public void CalculatorButtonClicked(object keyData)
        {
            CalculatorKeyData calculatorKeyData = (CalculatorKeyData)keyData;
            var value = calculatorKeyData.KeyName;

            if (operationStringArr.Any(x => ResultString.EndsWith(x) && ResultString.EndsWith(value)))
            {
                return;
            }
            if (value == "C")
            {
                ResultString = "0";
                return;
            }
            if (ResultString == "0" || ResultString == "E")
            {
                ResultString = "";
            }
            //restricts the calculator input to max of 15 character length
            if (ResultString.Length >= 15 && !operationStringArr.Any(x => ResultString.Contains(x)))
            {
                return;
            }
            else if (ResultString.Length >= 15 && value != "=")
            {
                return;
            }
            ResultString += Convert.ToString(value);
            if (value == "=")
            {
                try{
                    ResultString = new DataTable().Compute(ResultString.TrimEnd('='), null).ToString();
                }
                catch (Exception ex) {
                    //returns error to user if any operation in the screen results in and error during parsing and computation
                    ResultString = "E";
                }
            }
        }
Example #6
0
 public void SaveResult(byte ReadByte)
 {
     ResultByte.Add(ReadByte);
     if (RawCmdKey.Contains(CmdKey))
     {
         if (ReadByte <= 0x7f)
         {
             AsciiCount++;
         }
         else
         {
             AsciiCount = 0;
         }
         if (ReadByte == '\n' && AsciiCount >= 3 && AsciiCount == ResultByte.Count)
         {
             ResultStringList.Add(ResultString.Replace("\r", ""));
             Log.shell(ResultString.Replace("\r", ""));
             ResultByte.Clear();
             AsciiCount = 0;
         }
         else if (ResultString.EndsWith("TS->") && ResultByte.Count > 4)
         {
             ResultByteList.Add(ResultByte.Take(ResultByte.Count - 4).ToArray());
             ResultStringList.Add("RawData Saved\n");
             ResultByte.RemoveRange(0, ResultByte.Count - 4);
             Log.shell(ResultStringList.Last());
             AsciiCount = 0;
         }
     }
     else if (ReadByte == '\n')
     {
         ResultStringList.Add(ResultString);
         Log.shell(ResultString.Replace("\r", ""));
         ResultByte.Clear();
     }
     ReadTime = DateTime.Now;
 }
Example #7
0
        public string[,] CollectSimulationResults()
        {
            string ResultsSectionHeader = "Конфигурация сети на кристалле:";

            int PacketsGenerationPeriodAvgLine  = 40;
            int PacketsGenerationPeriodAvgIndex = 0;

            int ModellingTimeLine  = 83;
            int ModellingTimeIndex = 1;

            int PacketsSentLine  = 91;
            int PacketsSentIndex = 2;

            int PacketsReceivedLine  = 97;
            int PacketsReceivedIndex = 3;

            int PacketGenerationErrorsLine  = 103;
            int PacketGenerationErrorsIndex = 4;

            int PacketGenerationSpeedLine  = 111;
            int PacketGenerationSpeedIndex = 5;

            int FlitsGenerationSpeedLine  = 117;
            int FlitsGenerationSpeedIndex = 6;

            int FlitsSendingSpeedLine  = 123;
            int FlitsSendingSpeedIndex = 7;

            int PacketsDeliveryTimeLine  = 129;
            int PacketsDeliveryTimeIndex = 8;

            int PacketsHopsLine  = 135;
            int PacketsHopsIndex = 9;

            int NetworkThroughoutLine  = 143;
            int NetworkThroughoutIndex = 10;

            int RouterThroughoutLine  = 149;
            int RouterThroughoutIndex = 11;

            int CoreReceivingBuffersLoadLine  = 157;
            int CoreReceivingBuffersLoadIndex = 12;

            int CoreSendingBuffersLoadLine  = 163;
            int CoreSendingBuffersLoadIndex = 13;

            int RouterReceivingBuffersLoadLine  = 171;
            int RouterReceivingBuffersLoadIndex = 14;

            int RouterSendingBuffersLoadLine  = 177;
            int RouterSendingBuffersLoadIndex = 15;

            int BuffersLoadLine  = 185;
            int BuffersLoadIndex = 16;

            int PhysicChannelsLoadLine  = 191;
            int PhysicChannelsLoadIndex = 17;

            int CharacteristicsAmount = 18;


            int SectionsAmount = 0;

            string[] ResultSections = File.ReadAllLines(ResultsDirectoryPath + "\\" + DefaultResultFileName);
            foreach (string ResultString in ResultSections)
            {
                if (ResultString.Contains(ResultsSectionHeader))
                {
                    SectionsAmount++;
                }
            }
            string[,] Result = new string[SectionsAmount, CharacteristicsAmount];

            int SectionIndex     = -1;
            int SectionLineIndex = 0;

            foreach (string ResultString in ResultSections)
            {
                if (ResultString.Contains(ResultsSectionHeader))
                {
                    SectionIndex++;
                    SectionLineIndex = 0;
                }
                else if (SectionLineIndex == PacketsGenerationPeriodAvgLine)
                {
                    Result[SectionIndex, PacketsGenerationPeriodAvgIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == ModellingTimeLine)
                {
                    Result[SectionIndex, ModellingTimeIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == PacketsSentLine)
                {
                    Result[SectionIndex, PacketsSentIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == PacketsReceivedLine)
                {
                    Result[SectionIndex, PacketsReceivedIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == PacketGenerationErrorsLine)
                {
                    Result[SectionIndex, PacketGenerationErrorsIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == PacketGenerationSpeedLine)
                {
                    Result[SectionIndex, PacketGenerationSpeedIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == FlitsGenerationSpeedLine)
                {
                    Result[SectionIndex, FlitsGenerationSpeedIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == FlitsSendingSpeedLine)
                {
                    Result[SectionIndex, FlitsSendingSpeedIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == PacketsDeliveryTimeLine)
                {
                    Result[SectionIndex, PacketsDeliveryTimeIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == PacketsHopsLine)
                {
                    Result[SectionIndex, PacketsHopsIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == NetworkThroughoutLine)
                {
                    Result[SectionIndex, NetworkThroughoutIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == RouterThroughoutLine)
                {
                    Result[SectionIndex, RouterThroughoutIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == CoreReceivingBuffersLoadLine)
                {
                    Result[SectionIndex, CoreReceivingBuffersLoadIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == CoreSendingBuffersLoadLine)
                {
                    Result[SectionIndex, CoreSendingBuffersLoadIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == RouterReceivingBuffersLoadLine)
                {
                    Result[SectionIndex, RouterReceivingBuffersLoadIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == RouterSendingBuffersLoadLine)
                {
                    Result[SectionIndex, RouterSendingBuffersLoadIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == BuffersLoadLine)
                {
                    Result[SectionIndex, BuffersLoadIndex] = Common.ExtractValue(ResultString);
                }
                else if (SectionLineIndex == PhysicChannelsLoadLine)
                {
                    Result[SectionIndex, PhysicChannelsLoadIndex] = Common.ExtractValue(ResultString);
                }

                SectionLineIndex++;
            }

            return(Result);
        }
Example #8
0
        public string[,] CollectSimulationResults()
        {
            int CharacteristicsAmount = 15;

            int TotalProducedFlitsLine  = 2;
            int TotalProducedFlitsIndex = 0;

            int TotalAcceptedFlitsLine  = 3;
            int TotalAcceptedFlitsIndex = 1;

            int TotalReceivedFlitsLine  = 4;
            int TotalReceivedFlitsIndex = 2;

            int NetworkProductionLine  = 5;
            int NetworkProductionIndex = 3;

            int NetworkAcceptanceLine  = 6;
            int NetworkAcceptanceIndex = 4;

            int NetworkThroughputLine  = 7;
            int NetworkThroughputIndex = 5;

            int IpThroughputLine  = 8;
            int IpThroughputIndex = 6;

            int LastTimeFlitReceivedLine  = 9;
            int LastTimeFlitReceivedIndex = 7;

            int MaxBufferStuckDelayLine  = 10;
            int MaxBufferStuckDelayIndex = 8;

            int MaxTimeFlitInNetworkLine  = 11;
            int MaxTimeFlitInNetworkIndex = 9;

            int TotalReceivedPacketsLine  = 12;
            int TotalReceivedPacketsIndex = 10;

            int TotalFlitsLostLine  = 13;
            int TotalFlitsLostIndex = 11;

            int GlobalAverageDelayLine  = 14;
            int GlobalAverageDelayIndex = 12;

            int MaxDelayLine  = 15;
            int MaxDelayIndex = 13;

            int AverageBufferUtilizationLine  = 16;
            int AverageBufferUtilizationIndex = 14;

            int SectionsAmount = 0;

            string[] ResultSections = File.ReadAllLines(ResultsDirectoryPath + "\\" + DefaultResultFileName);
            foreach (string ResultString in ResultSections)
            {
                if (ResultString.Contains(ResultSectionHeader))
                {
                    SectionsAmount++;
                }
            }
            string[,] Result = new string[SectionsAmount, CharacteristicsAmount];

            int  SectionIndex     = -1;
            int  SectionLineIndex = 0;
            bool InSection        = false;

            foreach (string ResultString in ResultSections)
            {
                if (ResultString.Contains(ResultSectionHeader))
                {
                    SectionIndex++;
                    SectionLineIndex = 0;
                    InSection        = true;
                }
                else if (SectionLineIndex == TotalProducedFlitsLine && InSection)
                {
                    Result[SectionIndex, TotalProducedFlitsIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == TotalAcceptedFlitsLine && InSection)
                {
                    Result[SectionIndex, TotalAcceptedFlitsIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == TotalReceivedFlitsLine && InSection)
                {
                    Result[SectionIndex, TotalReceivedFlitsIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == NetworkProductionLine && InSection)
                {
                    Result[SectionIndex, NetworkProductionIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == NetworkAcceptanceLine && InSection)
                {
                    Result[SectionIndex, NetworkAcceptanceIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == NetworkThroughputLine && InSection)
                {
                    Result[SectionIndex, NetworkThroughputIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == IpThroughputLine && InSection)
                {
                    Result[SectionIndex, IpThroughputIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == LastTimeFlitReceivedLine && InSection)
                {
                    Result[SectionIndex, LastTimeFlitReceivedIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == MaxBufferStuckDelayLine && InSection)
                {
                    Result[SectionIndex, MaxBufferStuckDelayIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == MaxTimeFlitInNetworkLine && InSection)
                {
                    Result[SectionIndex, MaxTimeFlitInNetworkIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == TotalReceivedPacketsLine && InSection)
                {
                    Result[SectionIndex, TotalReceivedPacketsIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == TotalFlitsLostLine && InSection)
                {
                    Result[SectionIndex, TotalFlitsLostIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == GlobalAverageDelayLine && InSection)
                {
                    Result[SectionIndex, GlobalAverageDelayIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == MaxDelayLine && InSection)
                {
                    Result[SectionIndex, MaxDelayIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == AverageBufferUtilizationLine && InSection)
                {
                    Result[SectionIndex, AverageBufferUtilizationIndex] = ExtractValue(ResultString);
                    InSection = false;
                }

                SectionLineIndex++;
            }

            return(Result);
        }
Example #9
0
        public string[,] CollectSimulationResults()
        {
            int CharacteristicsAmount = 11;

            int PacketLatencyAverageLine  = 2;
            int PacketLatencyAveraveIndex = 0;

            int NetworkLatencyAverageLine  = 5;
            int NetworkLatencyAverageIndex = 1;

            int FlitLatencyAverageLine  = 8;
            int FlitLatencyAverageIndex = 2;

            int FragmentationAverageLine  = 11;
            int FragmentationAverageIndex = 3;

            int InjectedPacketRateAverageLine  = 14;
            int InjectedPacketRateAverageIndex = 4;

            int AcceptedPacketRateAverageLine  = 17;
            int AcceptedPacketRateAverageIndex = 5;

            int InjectedFlitRateAverageLine  = 20;
            int InjectedFlitRateAverageIndex = 6;

            int AcceptedFlitRateAverageLine  = 23;
            int AcceptedFlitRateAverageIndex = 7;

            int InjectedPacketSizeAverageLine  = 26;
            int InjectedPacketSizeAverageIndex = 8;

            int AcceptedPacketSizeAverageLine  = 27;
            int AcceptedPacketSizeAverageIndex = 9;

            int HopsAverageLine  = 28;
            int HopsAverageIndex = 10;

            int SectionsAmount = 0;

            string[] ResultSections = File.ReadAllLines(ResultsDirectoryPath + "\\" + DefaultResultFileName);
            foreach (string ResultString in ResultSections)
            {
                if (ResultString.Contains(SectionHeader))
                {
                    SectionsAmount++;
                }
            }
            string[,] Result = new string[SectionsAmount, CharacteristicsAmount];

            int  SectionIndex     = -1;
            int  SectionLineIndex = 0;
            bool InSection        = false;

            foreach (string ResultString in ResultSections)
            {
                if (ResultString.Contains(SectionHeader))
                {
                    SectionIndex++;
                    SectionLineIndex = 0;
                    InSection        = true;
                }
                else if (SectionLineIndex == PacketLatencyAverageLine && InSection)
                {
                    Result[SectionIndex, PacketLatencyAveraveIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == NetworkLatencyAverageLine && InSection)
                {
                    Result[SectionIndex, NetworkLatencyAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == FlitLatencyAverageLine && InSection)
                {
                    Result[SectionIndex, FlitLatencyAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == FragmentationAverageLine && InSection)
                {
                    Result[SectionIndex, FragmentationAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == InjectedPacketRateAverageLine && InSection)
                {
                    Result[SectionIndex, InjectedPacketRateAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == AcceptedPacketRateAverageLine && InSection)
                {
                    Result[SectionIndex, AcceptedPacketRateAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == InjectedFlitRateAverageLine && InSection)
                {
                    Result[SectionIndex, InjectedFlitRateAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == AcceptedFlitRateAverageLine && InSection)
                {
                    Result[SectionIndex, AcceptedFlitRateAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == InjectedPacketSizeAverageLine && InSection)
                {
                    Result[SectionIndex, InjectedPacketSizeAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == AcceptedPacketSizeAverageLine && InSection)
                {
                    Result[SectionIndex, AcceptedPacketSizeAverageIndex] = ExtractValue(ResultString);
                }
                else if (SectionLineIndex == HopsAverageLine && InSection)
                {
                    Result[SectionIndex, HopsAverageIndex] = ExtractValue(ResultString);
                    InSection = false;
                }

                SectionLineIndex++;
            }

            return(Result);
        }