예제 #1
0
		public ManagedDataSource( SpectrumSource source )
		{
			this.source = source;

            chromatogramListForm = new ChromatogramListForm();
            chromatogramListForm.Text = source.Name + " chromatograms";
            chromatogramListForm.TabText = source.Name + " chromatograms";
            chromatogramListForm.ShowIcon = false;

            CVID nativeIdFormat = CVID.MS_scan_number_only_nativeID_format;
            foreach (SourceFile f in source.MSDataFile.fileDescription.sourceFiles)
            {
                // the first one in the list isn't necessarily useful - could be Agilent MSCalibration.bin or the like
                nativeIdFormat = f.cvParamChild(CVID.MS_native_spectrum_identifier_format).cvid;
                if (CVID.MS_no_nativeID_format != nativeIdFormat)
                    break;
            }
            spectrumListForm = new SpectrumListForm( nativeIdFormat );
            spectrumListForm.Text = source.Name + " spectra";
            spectrumListForm.TabText = source.Name + " spectra";
            spectrumListForm.ShowIcon = false;

            spectrumDataProcessing = new DataProcessing();
            //chromatogramDataProcessing = new DataProcessing();
			//graphInfoMap = new GraphInfoMap();
		}
예제 #2
0
        //public Thread UpdateChart;


        public PrimaryForm(DataProcessing dataProcessing, DataCalculation dataCalculation)
        {
            InitializeComponent();

            _dataProcessing  = dataProcessing;
            _dataCalculation = dataCalculation;

            //currentBuisnessLogic = buisnessLogic;

            //_dataProcessing = new DataProcessing();
            //_dataCalculation = new DataCalculation(_dataProcessing);
        }
예제 #3
0
        private void StartBtn_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridViewUtils.ArrayToGrid <double>(gridView, DataProcessing.ListToArray(DataProcessing.ColumEject(DataProcessing.Array2ToList2(DataGridViewUtils.GridToArray2 <double>(gridView)))));
            }

            catch (Exception exc)
            {
                MessageBsc.ShowError(exc.Message);
            }
        }
예제 #4
0
        private void doTakeSnapshot(
            IGridEditableData fileGroup,
            IEnumerable <string> languageCodes,
            BackgroundWorker bw)
        {
            //var fgi = fileGroup.GetFileByLanguageCode(Project, languageCode);

            var table = new DataProcessing(fileGroup).GetDataTableFromResxFiles(Project, true);

            var lcs = new List <string>(languageCodes);

            for (var i = 0; i < lcs.Count; i++)
            {
                lcs[i] = lcs[i].ToLowerInvariant();
            }

            var rowIndex = 0;

            foreach (DataRow row in table.Rows)
            {
                if (rowIndex % 25 == 0 && (bw?.CancellationPending ?? false))
                {
                    throw new OperationCanceledException();
                }

                // Column 0=FileGroup checksum, column 1=Tag name.
                var baseKey = MakeBaseKey(row[0], row[1]);

                for (var sourceColumnIndex = 2;
                     sourceColumnIndex < table.Columns.Count - 1; // Subtract 1, because last column is ALWAYS the comment.
                     ++sourceColumnIndex)
                {
                    var languageValue = row[sourceColumnIndex] as string;
                    var languageCode  =
                        ExcelExportController.IsFileName(table.Columns[sourceColumnIndex].ColumnName)
                            ? new LanguageCodeDetection(Project)
                        .DetectLanguageCodeFromFileName(
                            fileGroup.ParentSettings,
                            table.Columns[sourceColumnIndex].ColumnName)
                            : table.Columns[sourceColumnIndex].ColumnName;
                    languageCode = languageCode.ToLowerInvariant();

                    if (/*lcs.Contains(languageCode.Substring(0, 2))||*/
                        lcs.Contains(languageCode))
                    {
                        var key = MakeFullKey(baseKey, languageCode);
                        PutSettingValue(key, languageValue);
                    }
                }

                rowIndex++;
            }
        }
예제 #5
0
        /// <summary>
        /// Processes one data source.
        /// </summary>
        /// <typeparam name="T">Type of data.</typeparam>
        /// <param name="dataList">List where should data be added.</param>
        /// <param name="url">URL to data.</param>
        /// <param name="index">Internal identifier for creating temporary folders.</param>
        /// <param name="urlsLength">Count of data feeds to process.</param>
        private static void ProcessData <T>(IList <IDataFeed> dataList, string url, int index = 0, int urlsLength = 1) where T : IDataFeed
        {
            try
            {
                DataProcessing?.Invoke($"Trying to download data from URL { url }.");

                Downloader.GetDataFeed($"{ index }_temp_data/", url, index);

                LoadingProgress?.Invoke("Part of the data successfully downloaded.", 20 / urlsLength);

                DataProcessing?.Invoke($"Data from URL { url } downloaded successfully.");

                DataProcessing?.Invoke($"Trying to parse data downloaded from { url }.");

                IDataFeed data = (T)Activator.CreateInstance(typeof(T), (string)$"{ index }_temp_data/");

                lock (dataList)
                {
                    dataList.Add(data);
                }

                LoadingProgress?.Invoke("Part of the data successfully parsed.", 40 / urlsLength);

                DataProcessing?.Invoke($"The data downloaded from { url } parsed successfully.");
            }
            catch (Exception ex)
            {
                if (ex is System.Reflection.TargetInvocationException)
                {
                    ex = ex.InnerException;
                }

                if (ex is UriFormatException)
                {
                    DataProcessing?.Invoke($"The URL { url } is invalid.");
                }

                else if (ex is System.Net.WebException)
                {
                    DataProcessing?.Invoke($"There was a problem downloading file { url }. Server may be inacessible or you are missing internet connection.");
                }

                else if (ex is FormatException)
                {
                    DataProcessing?.Invoke($"The data downloaded from { url } are not well-formed.");
                }
#if !DEBUG
                else
                {
                    DataProcessing?.Invoke($@"Parsing of data located in { url } ended with an unknown error.
Error: { ex.Message } Type of { ex.GetType() }.");
                }
예제 #6
0
 static void Main(string[] args)
 {
     try
     {
         DataProcessing data = new DataProcessing();
         data.SetInfo();
         data.EnterCommand();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
예제 #7
0
 public async Task <IEnumerable <Job> > Get()
 {
     try
     {
         DataProcessing dtProcessor = new DataProcessing(_config);
         return(await dtProcessor.SearchOpenPosition());
     }
     catch
     {
         //Write Log
         return(new List <Job>());
     }
 }
예제 #8
0
        public UnitTest1()
        {
            //_mockConfig = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            var myConfiguration = new Dictionary <string, string>
            {
                { "GetCandidateUri", "http://private-76432-jobadder1.apiary-mock.com/candidates" },
                { "GetJobUri", "http://private-76432-jobadder1.apiary-mock.com/jobs" },
                { "Timeout", "60" }
            };

            _mockConfig  = new ConfigurationBuilder().AddInMemoryCollection(myConfiguration).Build();
            _dtProcessor = new DataProcessing(_mockConfig);
        }
예제 #9
0
        public void DecExec_DP_Imm_Mov_Success()
        {
            //e3a02030 mov r2, #48
            Memory regs = new Memory(regsize);
            //using not on original command code because c# won't let me alter the sign bit.
            int            r    = ~0x1C5FDFCF; //Original command: e3a02030
            DataProcessing inst = new DataProcessing(r, ref regs);

            inst.Decode();
            inst.Execute();

            Assert.IsTrue(inst.ToString() == "mov r2, #48");
            Assert.IsTrue(regs.ReadWord(Reg.R2) == 48);
        }
예제 #10
0
        static void Main(string[] args)
        {
            var fileName = "/Users/paul/Desktop/Files/ж1_1.wav";
            var dataFile = "/Users/paul/Desktop/freqs.txt";

            FileProcessing.PutFreqStatToFile(fileName, dataFile);

            var result = DataProcessing.GetSpectrumFromDataFile(dataFile);

            foreach (var pair in result)
            {
                Console.WriteLine(pair.Key + " " + pair.Value);
            }

            var octaveBands = OctaveBandsProcessing.GetOctaveBandsData(result,
                                                                       DefaultParameters.StartFreq,
                                                                       DefaultParameters.HighFreqs,
                                                                       DefaultParameters.RootFreqs,
                                                                       DefaultParameters.NormalizeLevel);

            var speech = new double[octaveBands.Count];

            Console.WriteLine("");
            Console.WriteLine("Нормализованные уровни для речи:");
            for (int i = 0; i < speech.Length; i++)
            {
                Console.WriteLine(octaveBands[i].NormalizedLevel);
                speech[i] = octaveBands[i].NormalizedLevel;
            }

            Console.WriteLine("");
            Console.WriteLine("Разборчивость:");

            var testW = Intelligibility.GetWRange(speech,
                                                  DefaultParameters.WhiteNoiseLevels,
                                                  DefaultParameters.k,
                                                  DefaultParameters.deltaA,
                                                  -30,
                                                  30);

            foreach (var w in testW)
            {
                Console.WriteLine(w);
            }


            Console.WriteLine("");
            Console.WriteLine("Разборчивость напрямую:");
        }
예제 #11
0
        public void DecExecDP_Imm_MOV_Success()
        {
            Memory regs = new Memory(regsize);

            //  mov     r1, #-1593835520
            uint u = 0xe3a014a1;
            int  r = Convert.ToInt32(~u);

            r = ~r; DataProcessing inst = new DataProcessing(r, ref regs);
            inst.Decode();
            inst.Execute();

            Assert.IsTrue(regs.ReadWord(Reg.R1) == -1593835520);
            Assert.IsTrue(inst.ToString() == "mov r1, #-1593835520");
        }
예제 #12
0
        public void TestMethodMaxIndex()
        {
            DataProcessing lineMax = new DataProcessing();

            Dictionary <int, double> count = new Dictionary <int, double>(5)
            {
                { 1, -22.00 }, { 2, -0.05 }, { 3, 0.00 }, { 4, -10.00 }, { 5, -11.00 }
            };

            int expected = 0;

            double result = lineMax.MaxIndex(count);

            Assert.AreEqual(expected, result);
        }
예제 #13
0
        public void updateRow(ChromatogramDataSet.ChromatogramTableRow row, Chromatogram chromatogram)
        {
            chromatogramList[chromatogram.Index] = chromatogram;

            pwiz.CLI.msdata.Chromatogram c = chromatogram.Element;
            DataProcessing dp = chromatogram.DataProcessing;

            if (dp == null)
            {
                dp = c.dataProcessing;
            }

            row.Type       = c.cvParamChild(CVID.MS_chromatogram_type).name;
            row.DataPoints = c.defaultArrayLength;
            row.DpId       = (dp == null || dp.id.Length == 0 ? "unknown" : dp.id);
        }
예제 #14
0
        public void DecExec_DP_Imm_Mov2_Success()
        {
            // mov     r0, #724
            uint u = 0xe3a00fb5;
            int  r = Convert.ToInt32(~u);

            r = ~r;
            Memory         regs = new Memory(regsize);
            DataProcessing inst = new DataProcessing(r, ref regs);

            inst.Decode();
            inst.Execute();

            Assert.IsTrue(regs.ReadWord(Reg.R0) == 724);
            Assert.IsTrue(inst.ToString() == "mov r0, #724");
        }
예제 #15
0
        /// <summary>
        /// Produce plots for graphical display.
        /// NOTE: The threshold can be changed later.
        /// </summary>
        /// <returns>A list of graphical plots.</returns>
        private static List <Plot> GetPlots(Dictionary <string, double[]> contentDictionary)
        {
            double threshold    = 0.25;
            var    plotDict     = DataProcessing.ConvertArraysToPlots(contentDictionary, threshold);
            var    contentPlots = DataProcessing.ConvertPlotDictionaryToPlotList(plotDict);

            // convert scores to z-scores
            //contentPlots = DataProcessing.SubtractMeanPlusSd(contentPlots);

            //the following did not work as well.
            //contentPlots = DataProcessing.SubtractModeAndSd(contentPlots);

            // Use percentile thresholding followed by normalize in 0,1.
            contentPlots = DataProcessing.PercentileThresholding(contentPlots, 90);
            return(contentPlots);
        }
예제 #16
0
        public MainViewModel()
        {
            Logger.InitLogger();
            if (string.IsNullOrWhiteSpace(Properties.Resources.DataConnection))
            {
                Logger.Log.Error("Data connection not found!");
                throw new ArgumentNullException("Data connection not found!");
            }

            if (string.IsNullOrWhiteSpace(Properties.Resources.DALAssembly))
            {
                Logger.Log.Error("DALAssembly setting not found!");
                throw new ArgumentNullException("DALAssembly setting not found!");
            }


            if (string.IsNullOrWhiteSpace(Properties.Resources.ReaderType))
            {
                Logger.Log.Error("ReaderType setting not found!");
                throw new ArgumentNullException("ReaderType setting not found!");
            }

            //REVIEW: Тут вполне может что-то отвалиться с NRE или чем-то ещё. Надо обработать.
            try
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(
                    Assembly.GetExecutingAssembly().Location);
            }
            catch (NullReferenceException ex)
            {
                Logger.Log.Error("File not found!");
                throw new NullReferenceException("File not found");
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Wrong path!");
                throw new ArgumentException("Wrong path!");
            }
            Config cfg = new Config();

            cfg.DataPath           = Path.GetFullPath(Properties.Settings.Default.DataConnection);
            cfg.DataReaderAssembly = Path.GetFullPath(Properties.Settings.Default.DALAssembly);
            cfg.DataReader         = Path.GetFullPath(Properties.Settings.Default.ReaderType);

            dataProcessing = new DataProcessing(cfg);
            InitCollection(dataProcessing.GetNotes());
        }
예제 #17
0
 private void buttonStart_Click(object sender, EventArgs e)
 {
     labelNowTime.Text   = DataProcessing.currentTime.ToShortTimeString();
     buttonStart_clicked = true;
     changeVisibleButtons();
     DataProcessing.readDurations();
     if (buttonGenerateSchedule_clicked)
     {
         DataProcessing.generateSchedule();
         DataProcessing.init_correct();
         fill_separeted_schedules();
         fill_runways_page();
         fill_queues();
         if (comboBoxModulationMode.SelectedIndex == 0)
         {
             timerNextStep.Interval = 3000; // in milliseconds
             timerNextStep.Enabled  = true;
             // timerNextStep.Tick += new EventHandler(timerNextStep_Tick);
         }
     }
     else if (buttonManualShedule_clicked)
     {
         DataProcessing.readSchedule();
         if (!DataProcessing.isOkShedule())
         {
             MessageBox.Show("The schedule is impracticable, it needs changing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             buttonManualShedule_clicked      = false;
             buttonTypesWithDurations.Enabled = false;
             buttonStart_clicked = false;
             changeVisibleButtons();
         }
         else
         {
             DataProcessing.init_correct();
             fill_separeted_schedules();
             fill_runways_page();
             fill_queues();
             if (comboBoxModulationMode.SelectedIndex == 0)
             {
                 timerNextStep.Interval = 3000; // in milliseconds
                 timerNextStep.Enabled  = true;
                 //timerNextStep.Tick += new EventHandler(timerNextStep_Tick);
             }
         }
     }
 }
예제 #18
0
        public IHttpActionResult GetBooksOfAllTransacts()
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            //var a = new BookSearch();
            Book[] books = DataProcessing.GetBooksOfAllTransacts();
            if (books.Length == 0)
            {
                return(BadRequest("No Books Found"));
            }

            return(Ok(books));
        }
예제 #19
0
        // > 버튼 번호를 증가시키며 검사
        private void ForwardBox_Click(object sender, EventArgs e)
        {
            int testDataNumber = mangeFile.NumberOfFile(Property.TestFolderPath);

            TestDataNumBox.Text = Convert.ToString(testDataNumber);
            DataProcessing  DataShipping = new DataProcessing();
            CalculateOutput calculate    = new CalculateOutput();

            try
            {
                if (OutputTextBox.Text == "")
                {
                    OutputTextBox.Text = "1." + calculate.CalculateKNN(DataShipping.TestDataShipping(1));

                    ImageBox.Load(Property.testDataPath + Convert.ToString(1) + ").bmp");
                }
                else if (OutputTextBox.Text.Contains("True")) //true.
                {
                    if (testDataNumber > Convert.ToInt32(OutputTextBox.Text.Substring(0, OutputTextBox.Text.Length - 5)))
                    {
                        int    RunNumber = int.Parse(OutputTextBox.Text.Substring(0, OutputTextBox.Text.Length - 5));
                        string output    = calculate.CalculateKNN(DataShipping.TestDataShipping(RunNumber + 1));

                        OutputTextBox.Text = Convert.ToString(RunNumber + 1) + "." + output;

                        ImageBox.Load(Property.testDataPath + Convert.ToString(RunNumber + 1) + ").bmp");
                    }
                }
                else if (OutputTextBox.Text.Contains("False"))//false.
                {
                    if (testDataNumber > Convert.ToInt32(OutputTextBox.Text.Substring(0, OutputTextBox.Text.Length - 6)))
                    {
                        int    RunNumber = int.Parse(OutputTextBox.Text.Substring(0, OutputTextBox.Text.Length - 6));
                        string output    = calculate.CalculateKNN(DataShipping.TestDataShipping(RunNumber + 1));

                        OutputTextBox.Text = Convert.ToString(RunNumber + 1) + "." + output;

                        ImageBox.Load(Property.testDataPath + Convert.ToString(RunNumber + 1) + ").bmp");
                    }
                }
            }
            catch
            {
                MessageBox.Show("데이터를 학습시키오.");
            }
        }
예제 #20
0
        public void Test1()
        {
            //Arrange
            List <HighSpeedData> highSpeedData = new List <HighSpeedData> {
                new HighSpeedData {
                    Lane_Id   = 1,
                    HSData_DT = new DateTime(2020, 10, 2, 0, 0, 0),
                },
                new HighSpeedData {
                    Lane_Id   = 2,
                    HSData_DT = new DateTime(2020, 10, 2, 0, 0, 0),
                },
                new HighSpeedData {
                    Lane_Id   = 3,
                    HSData_DT = new DateTime(2020, 10, 2, 0, 0, 0),
                },
                new HighSpeedData {
                    Lane_Id   = 3,
                    HSData_DT = new DateTime(2020, 10, 2, 0, 0, 0),
                },
                new HighSpeedData {
                    Lane_Id   = 4,
                    HSData_DT = new DateTime(2020, 10, 2, 0, 0, 0),
                },
                new HighSpeedData {
                    Lane_Id   = 4,
                    HSData_DT = new DateTime(2020, 10, 2, 0, 0, 0),
                },
                new HighSpeedData {
                    Lane_Id   = 4,
                    HSData_DT = new DateTime(2020, 10, 2, 0, 0, 0),
                },
            };
            var laneText       = "1,2,3,4";
            var startDataTime  = new DateTime(2020, 10, 1, 0, 0, 0);
            var finishDataTime = new DateTime(2020, 11, 1, 0, 0, 0);
            Expression <Func <HighSpeedData, bool> > dataPredicate = x => x.HSData_DT >= startDataTime && x.HSData_DT < finishDataTime;


            //Act
            var Lane_Dist = DataProcessing.GetLaneDist(laneText, dataPredicate, highSpeedData.AsQueryable()).ToList();

            //Assert
            Assert.Equal(2, Lane_Dist[2]);
            Assert.Equal(3, Lane_Dist[3]);
        }
예제 #21
0
        //데이터가 학습 되었을 때 번호를 1씩 증가시키며 검사
        private void RL_ForwardBox_Click(object sender, EventArgs e)
        {
            int testDataNumber = mangeFile.NumberOfFile(Property.TestFolderPath);

            TestDataNumBox.Text = Convert.ToString(testDataNumber);
            DataProcessing DataShipping = new DataProcessing();

            try
            {
                if (RL_LabelOutPutTextBox.Text == "")
                {
                    RL_LabelOutPutTextBox.Text = "1." + Property.logistic.DesideRefression(DataShipping.TestDataShipping(1));

                    RL_ImageBox.Load(Property.testDataPath + Convert.ToString(1) + ").bmp");
                }
                else if (RL_LabelOutPutTextBox.Text.Contains("True")) //true.
                {
                    if (testDataNumber > Convert.ToInt32(RL_LabelOutPutTextBox.Text.Substring(0, RL_LabelOutPutTextBox.Text.Length - 5)))
                    {
                        int    RunNumber = int.Parse(RL_LabelOutPutTextBox.Text.Substring(0, RL_LabelOutPutTextBox.Text.Length - 5));
                        string output    = Property.logistic.DesideRefression(DataShipping.TestDataShipping(RunNumber + 1));

                        RL_LabelOutPutTextBox.Text = Convert.ToString(RunNumber + 1) + "." + output;

                        RL_ImageBox.Load(Property.testDataPath + Convert.ToString(RunNumber + 1) + ").bmp");
                    }
                }
                else if (RL_LabelOutPutTextBox.Text.Contains("False"))//false.
                {
                    if (testDataNumber > Convert.ToInt32(RL_LabelOutPutTextBox.Text.Substring(0, RL_LabelOutPutTextBox.Text.Length - 6)))
                    {
                        int    RunNumber = int.Parse(RL_LabelOutPutTextBox.Text.Substring(0, RL_LabelOutPutTextBox.Text.Length - 6));
                        string output    = Property.logistic.DesideRefression(DataShipping.TestDataShipping(RunNumber + 1));

                        RL_LabelOutPutTextBox.Text = Convert.ToString(RunNumber + 1) + "." + output;

                        RL_ImageBox.Load(Property.testDataPath + Convert.ToString(RunNumber + 1) + ").bmp");
                    }
                }
            }
            catch
            {
                MessageBox.Show("데이터를 학습시키오.");
            }
        }
예제 #22
0
파일: KnxRouting.cs 프로젝트: tomyqg/ms-iot
        private byte[] CreateActionDatagram(string destinationAddress, byte[] data)
        {
            var dataLength = DataProcessing.GetDataLength(data);

            // HEADER
            var datagram = new byte[6];

            datagram[0] = 0x06;
            datagram[1] = 0x10;
            datagram[2] = 0x05;
            datagram[3] = 0x30;
            var totalLength = BitConverter.GetBytes(dataLength + 16);

            datagram[4] = totalLength[1];
            datagram[5] = totalLength[0];

            return(DatagramProcessing.CreateActionDatagramCommon(destinationAddress, data, datagram, ActionMessageCode));
        }
예제 #23
0
        public override void BeforeAnalyze(AnalysisSettings analysisSettings)
        {
            // Read in the functional templates file. These doe the content description.
            var cdConfiguration   = (CdConfig)analysisSettings.Configuration;
            var cdConfigFile      = analysisSettings.ConfigFile;
            var configDirectory   = cdConfigFile.DirectoryName ?? throw new ArgumentNullException(nameof(cdConfigFile), "Null value");
            var templatesFileName = cdConfiguration.TemplatesList;
            var templatesFile     = new FileInfo(Path.Combine(configDirectory, templatesFileName));

            this.functionalTemplates = Json.Deserialize <FunctionalTemplate[]>(templatesFile);
            if (this.functionalTemplates == null)
            {
                throw new NullReferenceException(message: $"Array of functional templates was not read correctly from file: <{templatesFile}>");
            }

            // extract the template definitions as a dictionary. Each definition is itself a dictionary.
            this.templatesAsDictionary = DataProcessing.ExtractDictionaryOfTemplateDictionaries(this.functionalTemplates);
        }
예제 #24
0
        public void CzyMaWyposazenieTest()
        {
            List <Samochod>    auta = Dane.Dane.Samochody;
            List <Wyposazenie> elementyWyposazenia = Dane.Dane.DostepneWyposazenie;

            DataProcessing dp     = new DataProcessing();
            bool           result = dp.CzyMaWyposazenie(auta[0], elementyWyposazenia[2]);

            Assert.IsTrue(result);

            Wyposazenie radio = new Wyposazenie()
            {
                Nazwa = "Radio", Cena = 2000, CzyStandard = true
            };

            result = dp.CzyMaWyposazenie(auta[0], radio);
            Assert.IsTrue(result);
        }
예제 #25
0
        public void String2CharArrayTestPart1()                                 //	String2CharArrayTestPart1方法
        {                                                                       //	進入String2CharArrayTestPart1方法
            DataProcessing DataProcessing1 = new DataProcessing();              //	建立DataProcessing1物件
            string         TestData1       = "12345";                           //	宣告測試資料TestData1

            char[] expected = new char[5];;                                     //	宣告預期輸出資料expected
            expected[0] = '1';                                                  //	設定預期輸出
            expected[1] = '2';                                                  //	設定預期輸出
            expected[2] = '3';                                                  //	設定預期輸出
            expected[3] = '4';                                                  //	設定預期輸出
            expected[4] = '5';                                                  //	設定預期輸出
            char[] actual;                                                      //	宣告actual(實際輸出)
            actual = DataProcessing1.String2CharArray(TestData1);               //	執行String2CharArray方法
            for (int LoopNum = 0; LoopNum < 5; LoopNum++)                       //	以for迴圈依序比對期望輸出與實際輸出
            {                                                                   //	進入for迴圈
                Assert.AreEqual(expected[LoopNum], actual[LoopNum]);            //	比對期望輸出與實際輸出
            }                                                                   //	結束for迴圈
        }                                                                       //	結束String2CharArrayTestPart1方法
예제 #26
0
        // AJ CHANGE
        private static bool doesAutomaticTranslationsExist(
            Project project,
            DataRow row,
            CommentVisibilityScope commentVisibilityScope)
        {
            // Column 0=FileGroup checksum, column 1=Tag name.
            for (var i = 2; i < row.Table.Columns.Count -
                 (DataProcessing.CommentsAreVisible(project, row, commentVisibilityScope) ? 1 : 0); ++i)
            {
                var s = ConvertHelper.ToString(row[i], string.Empty);
                if (s.StartsWith(DefaultTranslatedPrefix))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #27
0
        public void DecExecDP_RegImm_MOV_Success()
        {
            Memory regs = new Memory(regsize);

            // mov     r0, #724
            regs.WriteWord(Reg.R2, 4);
            regs.WriteWord(Reg.R0, 3);

            uint u = 0xe1a02000;
            int  r = Convert.ToInt32(~u);

            r = ~r; DataProcessing inst = new DataProcessing(r, ref regs);
            inst.Decode();
            inst.Execute();

            Assert.IsTrue(regs.ReadWord(Reg.R2) == 3);
            Assert.IsTrue(inst.ToString() == "mov r2, r0");
        }
예제 #28
0
        /*Раздел 9 номер 4(console)
         * 4.	Создать новый двумерный массив, исключив из переданного массива совпадающие столбцы.
         * (Совпадающие столбцы – столбцы, у которых все соответствующие элементы равны друз другу).
         * При формировании нового массива оставить только первый из каждого набора совпадающих столбцов.
         */
        //ЗАДАЧА РЕШЕНА

        static void Main(string[] args)
        {
            Console.WriteLine("Прочитать данные из файла? (ответ - yes/no)");

            switch (Console.ReadLine())
            {
            case "yes":
                string fileName = Inp_Out.ReadValueFromConsole("имя файла");

                List <List <double> > data = Inp_Out.InpTXT(fileName);

                Console.WriteLine("Исходные данные:");
                Inp_Out.Arr2Print_Console <double>(DataProcessing.ListToArray(data));

                Console.WriteLine("Обработанный массив:");
                Inp_Out.Arr2Print_Console <double>(DataProcessing.ListToArray(DataProcessing.ColumEject(data)));
                break;

            case "no":
                Console.WriteLine("Введите количество строк массива:");
                int rowCount = int.Parse(Console.ReadLine());

                Console.WriteLine("Введите двухмерный массив (через пробел или запятую) по строкам:");
                List <List <double> > consData = new List <List <double> >();

                int i = 0;
                while (i <= rowCount)
                {
                    consData.Add(DataProcessing.ArrayToList(Inp_Out.StrToArray <double>(Console.ReadLine())));
                    i++;
                }
                Console.WriteLine("Обработанный массив:");
                Inp_Out.Arr2Print_Console <double>(DataProcessing.ListToArray(DataProcessing.ColumEject(consData)));

                break;

            default:
                Console.WriteLine("команда не распoзнана");
                break;
            }

            Console.ReadKey();
        }
예제 #29
0
        //private FileInformation getFfiForFilePath( string filePath )
        //{
        //    var fileName = Path.GetFileName( filePath );

        //    foreach ( var ffi in this )
        //    {
        //        if ( string.Compare( ffi.File.Name, fileName, true ) == 0 )
        //        {
        //            return ffi;
        //        }
        //    }

        //    return null;
        //}

        private void clearAllTexts(FileInformation ffi)
        {
            var tmpFileGroup = new FileGroup(Project);

            tmpFileGroup.AddFileInfo(ffi);

            var data  = new DataProcessing(tmpFileGroup);
            var table = data.GetDataTableFromResxFiles(Project);

            foreach (DataRow row in table.Rows)
            {
                // Clear.
                // Column 0=FileGroup checksum, column 1=Tag name.
                row[2] = null;
            }

            // Write back.
            data.SaveDataTableToResxFiles(Project, table, false, false);
        }
예제 #30
0
        public void NormalizeDataSetOutputs(DataSet[] dataset, bool setSetMaxMin = true)
        {
            int outputsCount = dataset[0].Outputs.Count;

            if (setSetMaxMin)
            {
                maxOutputs = new double[OutputNeuronNames.Count];
                minOutputs = new double[OutputNeuronNames.Count];

                for (int i = 0; i < outputsCount; i++) //Initialize Max & Min Outputs array
                {
                    maxOutputs[i] = dataset[0].Outputs[i];
                    minOutputs[i] = dataset[0].Outputs[i];
                }

                foreach (var item in dataset)
                {
                    for (int i = 0; i < outputsCount; i++)
                    {
                        double outputVal = item.Outputs[i];

                        if (outputVal > maxOutputs[i])
                        {
                            maxOutputs[i] = outputVal;
                        }

                        if (outputVal < minOutputs[i])
                        {
                            minOutputs[i] = outputVal;
                        }
                    }
                }
            }

            foreach (var item in dataset)
            {
                for (int i = 0; i < outputsCount; i++)
                {
                    item.Outputs[i] = DataProcessing.Normalize(item.Outputs[i], maxOutputs[i], minOutputs[i]);
                }
            }
        }
예제 #31
0
        private static bool hasPlaceholderMismatch(
            Project project,
            DataRow row,
            CommentVisibilityScope commentVisibilityScope)
        {
            // 2011-11-17, Uwe Keim.
            var neutralCode        = project == null ? @"en-US" : project.NeutralLanguageCode;
            var neutralColumnIndex = findColumnIndex(row.Table, neutralCode, 2);

            var columnCount = row.Table.Columns.Count;

            var s0 =
                columnCount > 0
                // Column 0=FileGroup checksum, column 1=Tag name.
                    ? ConvertHelper.ToString(row[neutralColumnIndex], string.Empty)
                    : string.Empty;
            var firstPlaceholderCount = ExtractPlaceholders(s0);

            // AJ CHANGE, skip the comments column
            // Column 0=FileGroup checksum, column 1=Tag name.
            for (var i = 2; i < columnCount -
                 (DataProcessing.CommentsAreVisible(project, row, commentVisibilityScope) ? 1 : 0); ++i)
            {
                if (i != neutralColumnIndex)
                {
                    var s = ConvertHelper.ToString(row[i], string.Empty);

                    // 2011-11-16, Uwe Keim: Only check if non-empty, non-default-language.
                    if (!string.IsNullOrEmpty(s))
                    {
                        var other = ExtractPlaceholders(s);

                        if (other != firstPlaceholderCount)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
예제 #32
0
        public Manager( DockPanel dockPanel )
        {
            this.dockPanel = dockPanel;
            dataSourceMap = new DataSourceMap();

            DockPanel.ActivePaneChanged += new EventHandler( form_GotFocus );

            spectrumProcessingForm = new SpectrumProcessingForm();
            spectrumProcessingForm.ProcessingChanged += new EventHandler( spectrumProcessingForm_ProcessingChanged );
            //spectrumProcessingForm.GlobalProcessingOverrideButton.Click += new EventHandler( processingOverrideButton_Click );
            //spectrumProcessingForm.RunProcessingOverrideButton.Click += new EventHandler( processingOverrideButton_Click );
            spectrumProcessingForm.GotFocus += new EventHandler( form_GotFocus );
            spectrumProcessingForm.HideOnClose = true;

            spectrumAnnotationForm = new SpectrumAnnotationForm();
            spectrumAnnotationForm.AnnotationChanged += new EventHandler( spectrumAnnotationForm_AnnotationChanged );
            spectrumAnnotationForm.GotFocus += new EventHandler( form_GotFocus );
            spectrumAnnotationForm.HideOnClose = true;

            spectrumGlobalDataProcessing = new DataProcessing();

            ShowChromatogramListForNewSources = true;
            ShowSpectrumListForNewSources = true;

            OpenFileUsesCurrentGraphForm = false;
            OpenFileGivesFocus = true;

            LoadDefaultAnnotationSettings();
        }
예제 #33
0
파일: Manager.cs 프로젝트: hap-adong/SeeMS
        public ManagedDataSource( SpectrumSource source )
        {
            this.source = source;

            chromatogramListForm = new ChromatogramListForm();
            chromatogramListForm.Text = source.Name + " chromatograms";
            chromatogramListForm.TabText = source.Name + " chromatograms";
            chromatogramListForm.ShowIcon = false;

            CVID nativeIdFormat = source.MSDataFile.fileDescription.sourceFiles[0].cvParamChild( CVID.MS_native_spectrum_identifier_format ).cvid;
            spectrumListForm = new SpectrumListForm( nativeIdFormat );
            spectrumListForm.Text = source.Name + " spectra";
            spectrumListForm.TabText = source.Name + " spectra";
            spectrumListForm.ShowIcon = false;

            spectrumDataProcessing = new DataProcessing();
            //chromatogramDataProcessing = new DataProcessing();
            //graphInfoMap = new GraphInfoMap();
        }
		private void doTakeSnapshot(
			IGridEditableData fileGroup,
			IEnumerable<string> languageCodes,
			BackgroundWorker bw)
		{
			//var fgi = fileGroup.GetFileByLanguageCode(Project, languageCode);

			var table = new DataProcessing(fileGroup).GetDataTableFromResxFiles(Project, true);

			var lcs = new List<string>(languageCodes);
			for (var i = 0; i < lcs.Count; i++)
			{
				lcs[i] = lcs[i].ToLowerInvariant();
			}

			var rowIndex = 0;
			foreach (DataRow row in table.Rows)
			{
				if (rowIndex % 25 == 0)
				{
					if (bw.CancellationPending)
					{
						throw new OperationCanceledException();
					}
				}

				// Column 0=FileGroup checksum, column 1=Tag name.
				var baseKey = MakeBaseKey(row[0], row[1]);

				for (var sourceColumnIndex = 2;
					sourceColumnIndex < table.Columns.Count - 1; // Subtract 1, because last column is ALWAYS the comment.
					++sourceColumnIndex)
				{
					var languageValue = row[sourceColumnIndex] as string;
					var languageCode =
						ExcelExportController.IsFileName(table.Columns[sourceColumnIndex].ColumnName)
							? new LanguageCodeDetection(Project)
								.DetectLanguageCodeFromFileName(
									fileGroup.ParentSettings,
									table.Columns[sourceColumnIndex].ColumnName)
							: table.Columns[sourceColumnIndex].ColumnName;
					languageCode = languageCode.ToLowerInvariant();

					if (/*lcs.Contains(languageCode.Substring(0, 2))||*/
						lcs.Contains(languageCode))
					{
						var key = MakeFullKey(baseKey, languageCode);
						PutSettingValue(key, languageValue);
					}
				}

				rowIndex++;
			}
		}
예제 #35
0
        static void Redacted() 
        //static void Main(string[] args)
        {
            string FileNameOdds;
            string FileNameStats;
            string projdir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;

            DataProcessing dp = new DataProcessing();

            //fileName nflodds2015weekX and nflstats2015weekX
            int currentWeek = 13;

            for (int i = 1; i < currentWeek + 1; ++i)
            {
                FileNameOdds = "nflodds2015week" + i + ".csv";
                FileNameStats = "nflstats2015week" + i + ".csv";

                string FullPath = projdir + "\\" + FileNameOdds;      //ROOT

                using (var csvC = new CsvReader(File.OpenText(FullPath)))
                {
                    csvC.Configuration.IgnoreHeaderWhiteSpace = true;
                    csvC.Configuration.TrimFields = true;

                    dp.addOdds(csvC.GetRecords<OddsData>().ToList());
                }

                FullPath = projdir + "\\" + FileNameStats;        //ROOT

                using (var csvC = new CsvReader(File.OpenText(FullPath)))
                {
                    csvC.Configuration.IgnoreHeaderWhiteSpace = true; ;
                    csvC.Configuration.TrimFields = true;
                    csvC.Configuration.RegisterClassMap<CustomClassMap>();

                    dp.addStats(csvC.GetRecords<GameData>().ToList());
                }
            }



            dp.getoddsandscore();
            for (int i = 0; i < dp.ListAllStats.Count(); ++i) {
                foreach (GameData g in dp.ListAllStats[i]) {
                    Console.WriteLine("{0} {1, -2} {2, -10} {3,-4} {4, -6} {5, -7} {6, -10} {7} {8} {9}", "Week", i + 1, g.Home.HomeName, g.Home.HScore, g.HomeSpread, g.Home.HTrueOdds, g.Visitor.VisName, g.Visitor.VScore, g.VisSpread, g.Visitor.VTrueOdds);
                }

                  
            }
            dp.SortWinLost(currentWeek);     //Do Sort for Weeks 1-11 HINT:Array based 0 = week 1
            List<Rank> TR = new List<Rank>();
            TR = dp.PowerRankings(currentWeek);
            Console.WriteLine("{0, -10} {1, -5} {2, -5} {3, -5} {4, -5} {5, -5} {6, -7} {7}", "TeamName", "RYA", "AYA", "IPA", "TPAA", "TE", "TrueScore", "Total");

            List<Rank> PRTotal = new List<Rank>();  //total in list with teamname and total
            foreach (Rank r in TR)
            {
                Console.Write("{0, -10} {1:0.000} {2:0.000} {3:0.000} {4:0.000} {5,-6:0.000} {6, 5} {7}", r.mTeamName, r.mRYA, r.mAYA, r.mIPA, r.mTPAA, r.mTE, r.mTrueScore, "  ");
                double total = r.mRYA + r.mAYA + r.mIPA + r.mTPAA + r.mTE;
                Console.WriteLine("{0:0.000}", total);

                Rank t = new Rank();
                t.mTeamName = r.mTeamName;
                t.mTrueScore = (decimal)total;
                PRTotal.Add(t);
            }



            string fileName13 = "nflodds2015week13.csv";
            string path13 = projdir + "\\" + fileName13;
            List<OddsData> week13Data = new List<OddsData>();
            //week 13 odds
            using (var csvC = new CsvReader(File.OpenText(path13)))
            {
                csvC.Configuration.IgnoreHeaderWhiteSpace = true;
                csvC.Configuration.TrimFields = true;

                while (csvC.Read())
                    week13Data.Add(csvC.GetRecord<OddsData>());
            }

            //List<Rank> LastWeek = new List<Rank>();
            //LastWeek = dp.GetLastWeekTrueScore(11, 1);

            //var home = from a in PRTotal
            //             join b in week13Data on a.mTeamName equals b.HomeTeam
            //             select new { a, b };   //common a truescore, common b spread

            //var away = from a in PRTotal
            //                      join b in week13Data on a.mTeamName equals b.VisTeam
            //                      select new { a, b };   //common a truescore, common b spread
            Console.WriteLine("{0, -10} {1, 5:0.000} {2, 5:0.000} {3, 5:0.000} {4,5:0.000} {5,-6:0.000} {6, 5:0.000} {7:0.000}",
                        "HomeTeam", "HPwrRate", "HomeSprd", "VisTeam", "VPRate", "VisSprd", "TPRate", "totPwrRate+3");
            foreach (OddsData o in week13Data)
            {
                if (o != null)
                {
                    var homeTotal = PRTotal.Find(h => h.mTeamName == o.HomeTeam);
                    var awayTotal = PRTotal.Find(v => v.mTeamName == o.VisTeam);
                    var homeweek13 = week13Data.Find(h => h.HomeTeam == o.HomeTeam);
                    var awayweek13 = week13Data.Find(v => v.VisTeam == o.VisTeam);

                    var homePR = homeTotal.mTrueScore;
                    var awayPR = awayTotal.mTrueScore;
                    var homespread = Convert.ToDecimal(homeweek13.HomeSpread);
                    var awayspread = Convert.ToDecimal(awayweek13.VisSpread);

                    decimal totalPR;
                    decimal totalPR3 = 0;
                    if (homePR > awayPR)
                    {
                        totalPR = homePR - awayPR;
                        totalPR3 = totalPR + 3;
                    }
                    else
                        totalPR = awayPR - homePR;
                    
                    Console.WriteLine("{0, -10} {1,5:0.000} {2,-8:0.000} {3,-8:0.000} {4,5:0.000} {5,-6:0.000} {6, -9:0.000} {7,-8:0.000}",
                        o.HomeTeam, homePR, homespread, o.VisTeam, awayPR, awayspread, totalPR, totalPR3);
                }
            }
        }
		/// <summary>
		/// Does the load files.
		/// </summary>
		internal void DoLoadFiles(
			IGridEditableData gridEditableData,
			ILanguageColumnFilter filter)
		{
			closeDataGrid();

			GridEditableData = gridEditableData;
			_data = new DataProcessing(gridEditableData);

			// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
			if (gridEditableData.GetFileInformationsSorted().Length > 0)
			// ReSharper restore ConvertIfStatementToConditionalTernaryExpression
			{
				fileNameTextEdit.Text = gridEditableData.FolderPath.FullName;
			}
			else
			{
				fileNameTextEdit.Text = null;
			}

			tabControl1.TabPages.Clear();

			var table = _data.GetDataTableFromResxFiles(gridEditableData.Project);

			if (table == null)
			{
				CloseAndSaveDataGrid();
			}
			else
			{
				// Column 0=FileGroup checksum, column 1=Tag name.
				for (var i = 2; i < table.Columns.Count; ++i)
				{
					var imageIndex =
						DataProcessing.CommentsAreVisible(
							gridEditableData.Project,
							table,
							CommentVisibilityScope.VisualGrid) &&
						i == table.Columns.Count - 1
							? 1
							: 0;

					addDetailTabPage(
						filter,
						imageIndex,
						imageIndex == 1
							? Resources.SR_ColumnCaption_Comment
							: table.Columns[i].Caption,
						imageIndex == 1
							? string.Empty
							: DataProcessing.ExtractCultureNameFromColumnCaption(table.Columns[i].Caption));
				}
			}

			// --

			mainDataGrid.DataSource = table;
			mainDataGrid.MainView.PopulateColumns();
			filterColumns(
				filter,
				DataProcessing.CommentsAreVisible(
					gridEditableData.Project,
					table,
					CommentVisibilityScope.VisualGrid));
			postpareStructure();

			FormBase.RestoreState(tabControl1);

			UpdateUI();

			restoreGridLayout();
			restoreSplitterState();

			// Initially.
			markGridContentAsUnmodified();
			markDetailsContentAsUnmodified();
			_currentRowIndex = -1;
			_canSaveGridLayout = true;

			// --

			updateStateImage();
		}
		/// <summary>
		/// Save the files and clear the Grid and the other resources.
		/// </summary>
		private void closeDataGrid()
		{
			if (GridEditableData != null)
			{
				saveSplitterState();
				saveGridLayout();

				GridEditableData = null;
				_data = null;

				mainDataGrid.DataSource = null;
				mainDataGrid.Refresh();

				UpdateUI();
			}

			fileNameTextEdit.Text = null;
		}