Beispiel #1
1
        public void AppendOneToFile()
        {
            engine = new FileHelperEngine(typeof (SampleType));

            SampleType[] res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now.Date;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"test.txt", res);

            SampleType record = new SampleType();

            record.Field1 = DateTime.Now.Date;
            record.Field2 = "h2";
            record.Field3 = 2;

            engine.AppendToFile(@"test.txt", record);

            SampleType[] res2 = (SampleType[]) engine.ReadFile(@"test.txt");

            Assert.AreEqual(3, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);
            Assert.AreEqual(res[1].Field1, res2[1].Field1);
            Assert.AreEqual(DateTime.Now.Date, res2[2].Field1);
        }
		public void WriteStream()
		{
			engine = new FileHelperEngine(typeof (SampleType));

			SampleType[] res = new SampleType[2];

			res[0] = new SampleType();
			res[1] = new SampleType();

			res[0].Field1 = DateTime.Now.AddDays(1);
			res[0].Field2 = "je";
			res[0].Field3 = 0;

			res[1].Field1 = DateTime.Now;
			res[1].Field2 = "ho";
			res[1].Field3 = 2;

			StringBuilder sb = new StringBuilder();
			StringWriter writer = new StringWriter(sb);
			engine.WriteStream(writer, res, 1);

			Assert.AreEqual(14 + 2, sb.ToString().Length);
			Assert.AreEqual(sb.ToString(0, 8), DateTime.Now.AddDays(1).ToString("ddMMyyyy"));

		}
		public void WriteEvents()
		{
			before = 0;
			after = 0;

            engine = new FileHelperEngine<SampleType>();

            engine.BeforeWriteRecord += engine_BeforeWriteRecord;
			engine.AfterWriteRecord += engine_AfterWriteRecord;

            SampleType[] res = new SampleType[2];

			res[0] = new SampleType();
			res[1] = new SampleType();

			res[0].Field1 = DateTime.Now.AddDays(1);
			res[0].Field2 = "je";
			res[0].Field3 = 0;

			res[1].Field1 = DateTime.Now;
			res[1].Field2 = "ho";
			res[1].Field3 = 2;

			engine.WriteString(res);

			Assert.AreEqual(2, engine.TotalRecords);
			Assert.AreEqual(2, before);
			Assert.AreEqual(2, after);

		}
Beispiel #4
0
        public void WriteFileNotifyPercent()
        {
            actualPerc = 0;
            actualAdd = 50;

            var engine = new FileHelperEngine<SampleType>();
            engine.Progress += ProgressChangePercent;

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile("prog1.txt", res);
            if (File.Exists("prog1.txt"))
                File.Delete("prog1.txt");
        }
        public void AppendToFile()
        {
            var engine = new FileHelperEngine<SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now.Date;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"test.txt", res);
            engine.AppendToFile(@"test.txt", res);

            var res2 = (SampleType[]) engine.ReadFile(@"test.txt");

            Assert.AreEqual(4, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);
            Assert.AreEqual(res[1].Field1, res2[1].Field1);
            Assert.AreEqual(res[0].Field1, res2[2].Field1);
            Assert.AreEqual(res[1].Field1, res2[3].Field1);
        }
        public void WriteFile2()
        {
            var engine = new FileHelperEngine<SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"miprueba.txt", res, -10);

            res = (SampleType[]) engine.ReadFile(@"miprueba.txt");

            if (File.Exists(@"miprueba.txt"))
                File.Delete(@"miprueba.txt");

            Assert.AreEqual(2, res.Length);
        }
 /// <summary>
 /// Construct a set of doubles from min to max
 /// </summary>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <param name="count"></param>
 public RandomAttribute(double min, double max, int count)
 {
     this.count = count;
     this.dmin = min;
     this.dmax = max;
     this.sampleType = SampleType.DoubleRange;
 }
 /// <summary>
 /// Construct a set of ints from min to max
 /// </summary>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <param name="count"></param>
 public RandomAttribute(int min, int max, int count)
 {
     this.count = count;
     this.min = min;
     this.max = max;
     this.sampleType = SampleType.IntRange;
 }
 public SampleDefinition(string name, Type pageType, SampleType sampleType, SampleCategory sampleArea)
 {
     _name           = name;
     _pageType       = pageType;
     _sampleType     = sampleType;
     _sampleCategory = sampleArea;
 }
Beispiel #10
0
        public P25Decoder(int sampleRate, SampleType sampleType)
            : base(sampleType)
        {
            if (sampleType == SampleType.COMPLEX) //JG This is used when listening to the raw feed, not demodulated.
            {
                mBasebandFilter = new DSP.Filter.ComplexFIRFilter(DSP.Filter.FilterFactory.getLowPass(sampleRate, 5000, 31, WindowType.HAMMING), 1.0);
                this.addComplexListener(mBasebandFilter);
                mBasebandFilter.SetListener(mDemodulator);
                mDemodulator.setListener(getRealReceiver());
            }

            mSymbolFilter = new DSP.Filter.C4FMSymbolFilter(sampleRate);
            addRealSampleListener(mSymbolFilter);
            mSymbolFilter.SetOutputListener(mSlicer);

            mMessageProcessor = new DSP.FSK.P25MessageProcessor();
            
            mNormalFramer = new DSP.FSK.P25MessageFramer(P25.FrameSync.P25_PHASE1.getSync(), 64, false);
            mSlicer.AddListener(mNormalFramer);
            mNormalFramer.setListener(mMessageProcessor);

            mInvertedFramer = new DSP.FSK.P25MessageFramer(P25.FrameSync.P25_PHASE1_INVERTED.getSync(), 64, true);
            mSlicer.AddListener(mInvertedFramer);
            mInvertedFramer.setListener(mMessageProcessor);

            mMessageProcessor.addMessageListener(this);
        }
        public void InsMethodOverload()
        {
            SampleType x = new SampleType();

            Assert.That(
                MethodCall.Invoke(x, "XBaseInsMethod", 10),
                Is.EqualTo("XBaseInsMethod(int i)"));
        }
Beispiel #12
0
        public FormAddNew(SampleType table)
        {
            InitializeComponent();
            InitializeOpenFileDialog();

            _tableType = table;
            tables = new DataGridView[] { dataGridViewNew, dataGridViewMil, dataGridViewMed, dataGridViewPsy, dataGridViewFamily, dataGridViewSocial, dataGridViewStudy, dataGridViewWork };
            FillTable();
        }
        public void InsProp()
        {
            SampleType x = new SampleType();

            MethodCall.SetProp(x, "XBaseInsProp", "zoo");

            Assert.That(
                MethodCall.GetProp(x, "XBaseInsProp"),
                Is.EqualTo("zoo"));
        }
        public void InsField()
        {
            SampleType x = new SampleType();

            MethodCall.SetField(x, "baseInsField", "la la");

            Assert.That(
                MethodCall.GetField(x, "baseInsField"),
                Is.EqualTo("la la"));
        }
Beispiel #15
0
		public Histogram(SampleType type)
		{
			switch(type)
			{
				case SampleType.BIASED:
					_sample = new ExponentiallyDecayingSample();
					break;
				case SampleType.UNIFORM:
					_sample = new UniformSample();
					break;
				default:  
			        throw new ArgumentException("Unknown enum value found."); 
			}
		}
Beispiel #16
0
        public void WriteFileStatic()
        {
            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            CommonEngine.WriteFile(@"prueba.txt", res);

            if (File.Exists(@"prueba.txt"))
                File.Delete(@"prueba.txt");
        }
        public void WriteNull()
        {
            var engine = new FileHelperEngine<SampleType>();

            SampleType[] res = new SampleType[3];
            res[0] = new SampleType();
            res[1] = new SampleType();
            res[2] = new SampleType();

            string tempo = engine.WriteString(res);
            res = engine.ReadString(tempo);

            Assert.AreEqual(3, res.Length);
            Assert.AreEqual(3, engine.TotalRecords);
            Assert.AreEqual(0, engine.ErrorManager.ErrorCount);

            Assert.AreEqual(DateTime.MinValue, res[0].Field1);
            Assert.AreEqual("", res[0].Field2);
            Assert.AreEqual(0, res[0].Field3);
        }
Beispiel #18
0
        public void WriteNull()
        {
            var engine = new FileHelperEngine <SampleType>();

            SampleType[] res = new SampleType[3];
            res[0] = new SampleType();
            res[1] = new SampleType();
            res[2] = new SampleType();

            string tempo = engine.WriteString(res);

            res = engine.ReadString(tempo);

            Assert.AreEqual(3, res.Length);
            Assert.AreEqual(3, engine.TotalRecords);
            Assert.AreEqual(0, engine.ErrorManager.ErrorCount);

            Assert.AreEqual(DateTime.MinValue, res[0].Field1);
            Assert.AreEqual("", res[0].Field2);
            Assert.AreEqual(0, res[0].Field3);
        }
Beispiel #19
0
        public override SampleDataChangeMergeResult MergeWith(SampleDataChange newerChange, out SampleDataChange mergedChange)
        {
            SamplePropertyTypeOrFormatChanged typeOrFormatChanged = newerChange as SamplePropertyTypeOrFormatChanged;

            if (typeOrFormatChanged != null)
            {
                if (this.SampleProperty.DeclaringSampleType != typeOrFormatChanged.SampleProperty.DeclaringSampleType || this.SampleProperty.Name != typeOrFormatChanged.SampleProperty.Name)
                {
                    mergedChange = (SampleDataChange)null;
                    return(SampleDataChangeMergeResult.CouldNotMerge);
                }
                SampleType newType = typeOrFormatChanged.NewType;
                if (this.OldType == typeOrFormatChanged.NewType && this.OldFormat == typeOrFormatChanged.NewFormat && this.OldFormatParameters == typeOrFormatChanged.NewFormatParameters)
                {
                    mergedChange = (SampleDataChange)null;
                    return(SampleDataChangeMergeResult.MergedIntoNothing);
                }
                mergedChange = (SampleDataChange) new SamplePropertyTypeOrFormatChanged(typeOrFormatChanged.SampleProperty, this.OldType, this.OldFormat, this.OldFormatParameters)
                {
                    NewType             = typeOrFormatChanged.NewType,
                    NewFormat           = typeOrFormatChanged.NewFormat,
                    NewFormatParameters = typeOrFormatChanged.NewFormatParameters
                };
                return(SampleDataChangeMergeResult.MergedIntoOneUnit);
            }
            if (this.Entity != newerChange.Entity)
            {
                mergedChange = (SampleDataChange)null;
                return(SampleDataChangeMergeResult.CouldNotMerge);
            }
            SamplePropertyDeleted samplePropertyDeleted = newerChange as SamplePropertyDeleted;

            if (samplePropertyDeleted != null)
            {
                mergedChange = (SampleDataChange)samplePropertyDeleted;
                return(SampleDataChangeMergeResult.MergedIntoOneUnit);
            }
            mergedChange = (SampleDataChange)null;
            return(SampleDataChangeMergeResult.CouldNotMerge);
        }
Beispiel #20
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                SampleType    entity  = (SampleType)p_BE;
                SampleTypeCtl control = new SampleTypeCtl(sqlTrans);
                string        sql     = "";
                //string sql = "SELECT Code FROM Enum_SampleType WHERE Code=" + SysString.ToDBString(entity.Code);

                //DataTable dt = sqlTrans.Fill(sql);
                //if (dt.Rows.Count != 0)
                //{
                //    throw new Exception("编码已经存在,请重新输入!");
                //}
                sql = "SELECT ID FROM Enum_SampleType WHERE ID=" + SysString.ToDBString(entity.ID);
                DataTable dt2 = sqlTrans.Fill(sql);
                dt2 = sqlTrans.Fill(sql);
                if (dt2.Rows.Count != 0)
                {
                    throw new Exception("ID已经存在,请重新输入!");
                }
                sql = "SELECT Name FROM Enum_SampleType WHERE Name=" + SysString.ToDBString(entity.Name);
                DataTable dt3 = sqlTrans.Fill(sql);
                dt3 = sqlTrans.Fill(sql);
                if (dt3.Rows.Count != 0)
                {
                    throw new Exception("名称已经存在,请重新输入!");
                }
                control.AddNew(entity);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Beispiel #21
0
        public void WriteString()
        {
            var engine = new FileHelperEngine <SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            string resStr = engine.WriteString(res);

            Assert.AreEqual(14 + newLineLen + 14 + newLineLen, resStr.Length);
            Assert.AreEqual(resStr.Substring(0, 8), DateTime.Now.AddDays(1).ToString("ddMMyyyy"));
        }
Beispiel #22
0
        public void WriteFileStatic()
        {
            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            CommonEngine.WriteFile(@"prueba.txt", res);

            if (File.Exists(@"prueba.txt"))
            {
                File.Delete(@"prueba.txt");
            }
        }
Beispiel #23
0
        public void WriteString()
        {
            engine = new FileHelperEngine(typeof(SampleType));

            SampleType[] res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            string resStr = engine.WriteString(res, 1);

            Assert.AreEqual(14 + 2, resStr.Length);
            Assert.AreEqual(resStr.Substring(0, 8), DateTime.Now.AddDays(1).ToString("ddMMyyyy"));
        }
        public void WriteString()
        {
            var engine = new FileHelperEngine<SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            string resStr = engine.WriteString(res, 1);

            Assert.AreEqual(14 + newLineLen, resStr.Length);
            Assert.AreEqual(resStr.Substring(0, 8), DateTime.Now.AddDays(1).ToString("ddMMyyyy"));
        }
Beispiel #25
0
        public HitSampleEvent(LogFileReader reader)
        {
            TimeDiff = reader.ReadULeb128();
            //			SampleType = (SampleType) reader.ReadULeb128 ();
            SampleType = (SampleType)reader.ReadByte();
            //Timestamp = reader.ReadULeb128 ();
            Thread = reader.ReadSLeb128();
            ulong count = reader.ReadULeb128();

            InstructionPointers = new long [count];
            for (uint n = 0; n < count; n++)
            {
                InstructionPointers [n] = reader.ReadSLeb128();
            }

            //Xamarin.Profiler 0.34 doesn't generate data below?

            //ulong mcount = reader.ReadULeb128();
            //Methods = new long[mcount];
            //for (uint n = 0; n < mcount; n++)
            //    Methods[n] = reader.ReadSLeb128();
        }
Beispiel #26
0
    public void LoadData(string data)
    {
        // get lines
        Match m = Regex.Match(data, "LINES = (?<a>[0-9]+)");

        lines = int.Parse(m.Groups["a"].Value);

        // get line sample
        m          = Regex.Match(data, "LINE_SAMPLES = (?<a>[0-9]+)");
        lineSample = int.Parse(m.Groups["a"].Value);

        // get line sample
        m             = Regex.Match(data, "SCALING_FACTOR = (?<a>[.0-9]+)");
        scalingFactor = float.Parse(m.Groups["a"].Value);

        // get dummy
        m     = Regex.Match(data, "DUMMY = (?<a>-?[0-9]+)");
        dummy = int.Parse(m.Groups["a"].Value);

        // get maximum
        m       = Regex.Match(data, " MAXIMUM = (?<a>-?[0-9]+)");
        maximum = int.Parse(m.Groups["a"].Value);

        // get minimum
        m       = Regex.Match(data, " MINIMUM = (?<a>-?[0-9]+)");
        minimum = int.Parse(m.Groups["a"].Value);

        // get sample type
        m = Regex.Match(data, "SAMPLE_TYPE = (?<a>[A-Z_]+)");
        string sampleTypeStr = m.Groups["a"].Value;

        foreach (SampleType type in Enum.GetValues(typeof(SampleType)))
        {
            if (sampleTypeStr == type.ToString())
            {
                sampleType = type;
            }
        }
    }
Beispiel #27
0
        public void WriteFile()
        {
            var engine = new FileHelperEngine<SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"prueba.txt", res);

            if (File.Exists(@"prueba.txt"))
                File.Delete(@"prueba.txt");
        }
Beispiel #28
0
        public void AppendToEmpty()
        {
            File.Copy(TestCommon.GetPath("Good", "TestEmpty.txt"), "tempEmpty.txt", true);

            engine = new FileHelperEngine(typeof (SampleType));

            SampleType[] res = new SampleType[1];

            res[0] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            engine.AppendToFile(@"tempEmpty.txt", res);

            SampleType[] res2 = (SampleType[]) engine.ReadFile(@"tempEmpty.txt");

            Assert.AreEqual(1, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);

            if (File.Exists("tempEmpty.txt")) File.Delete("tempEmpty.txt");
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="TestNameOrTestContext">When running from MSTest, the TestContext can be used to get TestName as well as various other properties. When run from VSix, the compiled code test name
        ///         When run from command line there will be no TestContext</param>
        ///<param name="stressUtilOptions">Set of options to use</param>
        /// <param name="sampleType"></param>
        public MeasurementHolder(object TestNameOrTestContext,
                                 StressUtilOptions stressUtilOptions,
                                 SampleType sampleType)
        {
            if (TestNameOrTestContext is TestContextWrapper)
            {
                this.testContext = TestNameOrTestContext as TestContextWrapper;
                this.TestName    = testContext.TestName;
                this.testContext.Properties[StressUtil.PropNameListFileResults] = lstFileResults;
            }
            else
            {
                this.TestName = TestNameOrTestContext as string;
            }
            this.stressUtilOptions = stressUtilOptions;
            this.sampleType        = sampleType;

            foreach (var entry in stressUtilOptions.lstPerfCountersToUse)
            {
                measurements[entry.perfCounterType] = new List <uint>();
            }
            IsMeasuringCurrentProcess = LstPerfCounterData[0].ProcToMonitor.Id == Process.GetCurrentProcess().Id;
        }
Beispiel #30
0
        public static IReadOnlyCollection <string> GetSamples(SampleType type)
        {
            switch (type)
            {
            case SampleType.ReferenceLikeText:
                return(ReferenceLikeText);

            case SampleType.AmbigiousDelimiters:
                return(AmbigiousDelimiters);

            case SampleType.Reference:
                return(References);

            case SampleType.BlockComment:
                return(BlockComments);

            case SampleType.LineComment:
                return(SingleLineComments);

            default:
                throw new ArgumentOutOfRangeException(nameof(type));
            }
        }
        public void WriteEventsNonGeneric()
        {
            var engine = new FileHelperEngine(typeof(SampleType));

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteString(res);

            Assert.AreEqual(2, engine.TotalRecords);
            Assert.AreEqual(true, res[0].BeforeWriteNotif);
            Assert.AreEqual(true, res[1].BeforeWriteNotif);
        }
        public void WriteEvents()
        {
            var engine = new FileHelperEngine <SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteString(res);

            Assert.AreEqual(2, engine.TotalRecords);
            Assert.AreEqual(true, res[0].BeforeWriteNotif);
            Assert.AreEqual(true, res[1].BeforeWriteNotif);
        }
Beispiel #33
0
        public void WriteFile()
        {
            engine = new FileHelperEngine(typeof(SampleType));

            SampleType[] res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"prueba.txt", res);

            if (File.Exists(@"prueba.txt"))
            {
                File.Delete(@"prueba.txt");
            }
        }
Beispiel #34
0
        public void WriteNull()
        {
            engine = new FileHelperEngine(typeof(SampleType));

            SampleType[] res = new SampleType[3];
            res[0] = new SampleType();
            res[1] = new SampleType();
            res[2] = new SampleType();

            engine.WriteFile("tempNull.txt", res);
            res = (SampleType[])engine.ReadFile("tempNull.txt");

            Assert.AreEqual(3, res.Length);
            Assert.AreEqual(3, engine.TotalRecords);
            Assert.AreEqual(0, engine.ErrorManager.ErrorCount);

            Assert.AreEqual(DateTime.MinValue, res[0].Field1);
            Assert.AreEqual("", res[0].Field2);
            Assert.AreEqual(0, res[0].Field3);
            if (File.Exists("tempNull.txt"))
            {
                File.Delete("tempNull.txt");
            }
        }
Beispiel #35
0
        public void WriteStream()
        {
            var engine = new FileHelperEngine<SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1);
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            var sb = new StringBuilder();
            var writer = new StringWriter(sb);
            engine.WriteStream(writer, res);

            Assert.AreEqual(14 + newLineLen + 14 + newLineLen, sb.ToString().Length);
            Assert.AreEqual(sb.ToString(0, 8), DateTime.Now.AddDays(1).ToString("ddMMyyyy"));
        }
Beispiel #36
0
 public ActionResult SampleType(SampleType obj)
 {
     try
     {
         BL_SampleType sampletype2 = new BL_SampleType();
         if (sampletype2.CheckSampleType(obj.SampleTypeID, obj.SampleTypeName))
         {
             if (sampletype2.SampleType(obj))
             {
                 if (obj.SampleTypeID > 0)
                 {
                     ModelState.Clear();
                     //ViewData["flag"] = "SampleType Save Successfully";
                     TempData["msg"] = "SampleType Update Successfully";
                     return(RedirectToAction("SampleType", "SampleType"));
                 }
                 else
                 {
                     ModelState.Clear();
                     //ViewData["flag"] = "SampleType Save Successfully";
                     TempData["msg"] = "SampleType Saved Successfully";
                     return(RedirectToAction("SampleType", "SampleType"));
                 }
             }
         }
         else
         {
             TempData["msg"] = "SampleType Already Exist's";
         }
         return(View());
     }
     catch (Exception)
     {
         return(View());
     }
 }
        public void AppendToEmptyAsync()
        {
            var engineOld = new FileHelperEngine<SampleType>();
            var engine = new FileHelperAsyncEngine<SampleType>();

            SampleType rec = new SampleType();

            rec.Field1 = DateTime.Now.AddDays(1).Date;
            rec.Field2 = "je";
            rec.Field3 = 0;

            File.Copy(TestCommon.GetPath("Good", "TestEmpty.txt"), "tempEmpty.txt", true);

            engine.BeginAppendToFile(@"tempEmpty.txt");
            engine.WriteNext(rec);
            engine.Close();

            SampleType[] res2 = (SampleType[]) engineOld.ReadFile(@"tempEmpty.txt");

            Assert.AreEqual(1, res2.Length);
            Assert.AreEqual(rec.Field1, res2[0].Field1);

            if (File.Exists("tempEmpty.txt")) File.Delete("tempEmpty.txt");
        }
Beispiel #38
0
        private SampleType GetType(int wellID)
        {
            SampleType type = SampleType.Empty;

            switch (plate2Show)
            {
            case Plate2Show.reaction:
                type = dilutionInfos.Where(x => x.destWellID == wellID).First().type;
                break;

            case Plate2Show.dilution1:
            case Plate2Show.dilution2:
                var plateBuffer = plate2Show == Plate2Show.dilution1 ? firstPlateBuffer : secondPlateBuffer;
                if (plateBuffer.Exists(x => x.dstWellID == wellID))
                {
                    type = plateBuffer.Where(x => x.dstWellID == wellID).First().type;
                }
                break;

            default:
                throw new Exception("Not supported plate drawing.");
            }
            return(type);
        }
Beispiel #39
0
        private BASSFlag SampleTypeToBASSFlag(SampleType sampleType)
        {
            BASSFlag flags;

            switch (sampleType)
            {
            case SampleType.Sample8Bit:
                flags = BASSFlag.BASS_RECORD_PAUSE | BASSFlag.BASS_SAMPLE_8BITS;
                break;

            case SampleType.Sample16Bit:
                flags = BASSFlag.BASS_RECORD_PAUSE;
                break;

            case SampleType.Sample32Bit:
                flags = BASSFlag.BASS_RECORD_PAUSE | BASSFlag.BASS_SAMPLE_FLOAT;
                break;

            default:
                throw new NotImplementedException($"未实现的采样类型:{sampleType.ToString()}");
            }

            return(flags);
        }
Beispiel #40
0
 /// <summary>
 /// Get the specified data type from the specified sample
 /// </summary>
 /// <param name="sample">The sample instance of interest</param>
 /// <param name="type">The data type to be extracted from the sample</param>
 /// <returns>A double value representing the requested data</returns>
 public double GetValue( Sample sample, SampleType type )
 {
     switch ( type )
     {
         case SampleType.Position:
             return sample.Position;
         case SampleType.Time:
             return sample.Time.ToOADate();
         case SampleType.TimeDiff:
             return sample.Time.ToOADate() - ( (Sample)list[0] ).Time.ToOADate();
         case SampleType.VelocityAvg:
             double timeDiff = sample.Time.ToOADate() - ( (Sample)list[0] ).Time.ToOADate();
             if ( timeDiff <= 0 )
                 return PointPair.Missing;
             else
                 return ( sample.Position - ( (Sample)list[0] ).Position ) / timeDiff;
         case SampleType.VelocityInst:
             return sample.Velocity;
         default:
             return PointPair.Missing;
     }
 }
Beispiel #41
0
        /// <summary>
        /// copy constructor -- this returns a copy of the structure,
        /// but it does not duplicate the data (it just keeps a reference to the original)
        /// </summary>
        /// <param name="rhs">The SamplePointList to be copied</param>
        public SamplePointList( SamplePointList rhs )
        {
            XType = rhs.XType;
            YType = rhs.YType;

            // Don't duplicate the data values, just copy the reference to the ArrayList
            this.list = rhs.list;

            //foreach ( Sample sample in rhs )
            //	list.Add( sample );
        }
Beispiel #42
0
 /// <summary>
 /// default constructor
 /// </summary>
 public SamplePointList()
 {
     XType = SampleType.Time;
     YType = SampleType.Position;
     list = new ArrayList();
 }
Beispiel #43
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     SampleType entity = (SampleType)p_BE;
 }
 private void onRBMiddleSampleChecked(object sender, RoutedEventArgs e)
 {
     this.mSampleType = SampleType.MIDDLE;
 }
Beispiel #45
0
 internal SegmentOutline(SampleType sampleType, int numSamples, Allocator allocator = Allocator.Temp)
 {
     this.sampleType = sampleType;
     samples         = new NativeList <PointSampleGlobal>(numSamples, allocator);
 }
Beispiel #46
0
    /// <summary>
    /// Calculates the statistical parameters for the current trial and <see cref="SampleType"/>
    /// </summary>
    /// <param name="sampleType">
    /// The <see cref="SampleType"/> of which the data should be used.
    /// </param>
    public void CalculateAOIStatistics(SampleType sampleType)
    {
      this.aoiStatistics = new Dictionary<string, AOIStatistic>();
      foreach (VGElement aoi in this.AoiCollection)
      {
        var aoiStatistic = new AOIStatistic();
        var aoiContainer = new VGElementCollection();
        aoiContainer.Add(aoi);

        switch (sampleType)
        {
          case SampleType.Gaze:
            aoiStatistic = Statistics.Statistic.CalcAOIStatistic(this.GazeFixationsView, aoiContainer);
            break;
          case SampleType.Mouse:
            aoiStatistic = Statistics.Statistic.CalcAOIStatistic(this.MouseFixationsView, aoiContainer);
            break;
        }

        if (!this.aoiStatistics.ContainsKey(aoi.Name))
        {
          this.aoiStatistics.Add(aoi.Name, aoiStatistic);
        }
      }
    }
 private void onRBBigSampleChecked(object sender, RoutedEventArgs e)
 {
     this.mSampleType = SampleType.BIG;
 }
 /// <summary>
 /// Construct a set of doubles from 0.0 to 1.0,
 /// specifying only the count.
 /// </summary>
 /// <param name="count"></param>
 public RandomAttribute(int count)
 {
     this.count = count;
     this.sampleType = SampleType.Raw;
 }
 private static IParsingResult <SmallPedigreeSampleOptions> Parse(IFileLocation bam, SampleType sampleType, string sampleName)
 {
     if (sampleName == null)
     {
         Action a = () =>
         {
             BamReader.WrapException(bam, reader =>
             {
                 sampleName = reader.GetReadGroupSample();
             });
         };
         if (!a.Try(out Exception e))
         {
             return(ParsingResult <SmallPedigreeSampleOptions> .FailedResult(e.Message));
         }
     }
     return(ParsingResult <SmallPedigreeSampleOptions> .SuccessfulResult(new SmallPedigreeSampleOptions(sampleName, sampleType, bam)));
 }
 public static extern void EndSample(SampleType type);
Beispiel #51
0
 /// <summary>
 /// default constructor
 /// </summary>
 public SamplePointList()
 {
     XType = SampleType.Time;
     YType = SampleType.Position;
     list  = new ArrayList();
 }
Beispiel #52
0
    /// <summary>
    /// This method draws the statistic bubbles and transisiton arrows
    ///   of given <see cref="SampleType"/> in given <see cref="VisualizationModes"/>.
    /// </summary>
    /// <param name="mode">
    /// The <see cref="VisualizationModes"/> to be used.
    /// </param>
    /// <param name="sampleType">
    /// The <see cref="SampleType"/> of the data.
    /// </param>
    public void DrawAOIStatistics(VisualizationModes mode, SampleType sampleType)
    {
      // Skip if no data available
      if (this.aoiStatistics == null)
      {
        return;
      }

      // Get all statistical elements
      var statisticalElements = this.Elements.FindAllGroupMembers(VGStyleGroup.AOI_STATISTICS_ARROW);
      statisticalElements.AddRange(this.Elements.FindAllGroupMembers(VGStyleGroup.AOI_STATISTICS_BUBBLE));

      this.Elements.RemoveAll(statisticalElements);

      var distances = new List<int>();

      var aoisWithoutSearchRects = new VGElementCollection();
      foreach (VGElement aoi in this.AoiCollection)
      {
        if (aoi.StyleGroup != VGStyleGroup.AOI_SEARCHRECT)
        {
          aoisWithoutSearchRects.Add(aoi);
        }
      }

      foreach (VGElement aoi in aoisWithoutSearchRects)
      {
        if (!this.aoiStatistics.ContainsKey(aoi.Name))
        {
          continue;
        }

        var aoiStatistic = this.aoiStatistics[aoi.Name];
        if ((mode & VisualizationModes.FixationTime) == VisualizationModes.FixationTime)
        {
          if (aoiStatistic.SumOfTimeOfAllFixations > 0)
          {
            var bounds = this.GetCircleBounds(aoi.Center, aoiStatistic.SumOfTimeOfAllFixations, mode);
            var ellipse = new VGEllipse(
              this.BubbleDrawAction, 
              this.BubblePen, 
              this.BubbleBrush, 
              this.BubbleFont, 
              this.BubbleFontColor, 
              bounds, 
              VGStyleGroup.AOI_STATISTICS_BUBBLE, 
              aoiStatistic.SumOfTimeOfAllFixations + " ms", 
              string.Empty);

            ellipse.TextAlignment = this.BubbleTextAlignment;
            distances.Add((int)(bounds.Width / 2));
            this.Elements.Add(ellipse);
          }
        }

        if ((mode & VisualizationModes.NumberOfFixations) == VisualizationModes.NumberOfFixations)
        {
          if (aoiStatistic.FixationCount > 0)
          {
            var bounds = this.GetCircleBounds(aoi.Center, aoiStatistic.FixationCount, mode);
            var ellipse = new VGEllipse(
              this.BubbleDrawAction, 
              this.BubblePen, 
              this.BubbleBrush, 
              this.BubbleFont, 
              this.BubbleFontColor, 
              bounds, 
              VGStyleGroup.AOI_STATISTICS_BUBBLE, 
              aoiStatistic.FixationCount.ToString(CultureInfo.InvariantCulture), 
              string.Empty);

            ellipse.TextAlignment = this.BubbleTextAlignment;
            distances.Add((int)(bounds.Width / 2));
            this.Elements.Add(ellipse);
          }
        }

        if ((mode & VisualizationModes.AverageFixationDuration) == VisualizationModes.AverageFixationDuration)
        {
          if (aoiStatistic.FixationDurationMean > 0)
          {
            var bounds = this.GetCircleBounds(aoi.Center, aoiStatistic.FixationDurationMean, mode);
            var ellipse = new VGEllipse(
              this.BubbleDrawAction, 
              this.BubblePen, 
              this.BubbleBrush, 
              this.BubbleFont, 
              this.BubbleFontColor, 
              bounds, 
              VGStyleGroup.AOI_STATISTICS_BUBBLE, 
              aoiStatistic.FixationDurationMean.ToString("N0") + " ms", 
              string.Empty);
            ellipse.TextAlignment = this.BubbleTextAlignment;
            distances.Add((int)(bounds.Width / 2));
            this.Elements.Add(ellipse);
          }
        }
      }

      // Check for absolute or relative transition values
      var absolute = (mode & VisualizationModes.AbsoluteTransitions) == VisualizationModes.AbsoluteTransitions;

      if ((mode & VisualizationModes.RelativeTransitions) == VisualizationModes.RelativeTransitions
          || (mode & VisualizationModes.AbsoluteTransitions) == VisualizationModes.AbsoluteTransitions)
      {
        DataView trialsFixations = null;

        // Get filtered fixations data view
        switch (sampleType)
        {
          case SampleType.Gaze:
            trialsFixations = this.GazeFixationsView;
            break;
          case SampleType.Mouse:
            trialsFixations = this.MouseFixationsView;
            break;
        }

        var transitions = Statistics.Statistic.CreateTransitionMatrixForSingleAOIs(
          trialsFixations, 
          aoisWithoutSearchRects);

        float transitionSum = 0;

        // Calculate transition total sum only if relative values are requested.
        if (!absolute)
        {
          for (var i = 0; i <= transitions.GetUpperBound(0); i++)
          {
            // Skip nowhere transitions
            if (i == 0)
            {
              continue;
            }

            for (var j = 0; j <= transitions.GetUpperBound(1); j++)
            {
              // Only take values outside the diagonal
              if (i == j || j == 0)
              {
                continue;
              }

              transitionSum += (int)transitions.GetValue(i, j);
            }
          }
        }

        // Write transitionMatrix to dgv
        for (var i = transitions.GetLowerBound(0); i <= transitions.GetUpperBound(0); i++)
        {
          // Skip nowhere transitions
          if (i == 0)
          {
            continue;
          }

          for (var j = transitions.GetLowerBound(1); j <= transitions.GetUpperBound(1); j++)
          {
            // Only take values above the diagonal
            if (i >= j)
            {
              continue;
            }

            float transAtoB;
            float transBtoA;
            if (absolute)
            {
              transAtoB = (int)transitions.GetValue(i, j);
              transBtoA = (int)transitions.GetValue(j, i);
            }
            else
            {
              transAtoB = (float)Math.Round((int)transitions.GetValue(i, j) / transitionSum * 100, 1);
              transBtoA = (float)Math.Round((int)transitions.GetValue(j, i) / transitionSum * 100, 1);
            }

            if (transAtoB > 0 || transBtoA > 0)
            {
              var showNumbers = false;
              if ((this.ArrowDrawAction & ShapeDrawAction.Name) == ShapeDrawAction.Name)
              {
                this.ArrowDrawAction |= ~ShapeDrawAction.Name;
                showNumbers = true;
              }

              var arrow = new VGArrow(this.ArrowDrawAction, this.ArrowPen);
              arrow.Brush = this.ArrowBrush;
              if (!showNumbers)
              {
                arrow.HideWeights = true;
              }

              var location1 = aoisWithoutSearchRects[i - 1].Center;
              var location2 = aoisWithoutSearchRects[j - 1].Center;
              var distanceFirst = distances.Count >= i ? distances[i - 1] : 15;
              var distanceSecond = distances.Count >= j ? distances[j - 1] : 15;
              if (location1.X <= location2.X)
              {
                arrow.FirstPoint = location1;
                arrow.SecondPoint = location2;
                arrow.FirstPointDistance = distanceFirst;
                arrow.SecondPointDistance = distanceSecond;
                arrow.FirstPointWeight = transBtoA;
                arrow.SecondPointWeight = transAtoB;
              }
              else
              {
                arrow.FirstPoint = location2;
                arrow.SecondPoint = location1;
                arrow.FirstPointDistance = distanceSecond;
                arrow.SecondPointDistance = distanceFirst;
                arrow.FirstPointWeight = transAtoB;
                arrow.SecondPointWeight = transBtoA;
              }

              arrow.FormatString = "N0";
              if (!absolute)
              {
                if (arrow.FirstPointWeight < 1 && arrow.SecondPointWeight < 1)
                {
                  arrow.FormatString = "N1";
                }

                arrow.AddOnString = "%";
              }

              arrow.WeightFont = this.ArrowFont;
              arrow.WeightFontColor = this.ArrowFontColor;
              arrow.ScaleFactor = this.ArrowFactor;
              arrow.StyleGroup = VGStyleGroup.AOI_STATISTICS_ARROW;
              arrow.TextAlignment = this.ArrowTextAlignment;
              this.Elements.Add(arrow);
            }
          }
        }
      }

      this.DrawForeground(true);
    }
Beispiel #53
0
        /// <summary>
        /// This method draws the statistic bubbles and transisiton arrows
        ///   of given <see cref="SampleType"/> in given <see cref="VisualizationModes"/>.
        /// </summary>
        /// <param name="mode">
        /// The <see cref="VisualizationModes"/> to be used.
        /// </param>
        /// <param name="sampleType">
        /// The <see cref="SampleType"/> of the data.
        /// </param>
        public void DrawAOIStatistics(VisualizationModes mode, SampleType sampleType)
        {
            // Skip if no data available
            if (this.aoiStatistics == null)
            {
                return;
            }

            // Get all statistical elements
            var statisticalElements = this.Elements.FindAllGroupMembers(VGStyleGroup.AOI_STATISTICS_ARROW);

            statisticalElements.AddRange(this.Elements.FindAllGroupMembers(VGStyleGroup.AOI_STATISTICS_BUBBLE));

            this.Elements.RemoveAll(statisticalElements);

            var distances = new List <int>();

            var aoisWithoutSearchRects = new VGElementCollection();

            foreach (VGElement aoi in this.AoiCollection)
            {
                if (aoi.StyleGroup != VGStyleGroup.AOI_SEARCHRECT)
                {
                    aoisWithoutSearchRects.Add(aoi);
                }
            }

            foreach (VGElement aoi in aoisWithoutSearchRects)
            {
                if (!this.aoiStatistics.ContainsKey(aoi.Name))
                {
                    continue;
                }

                var aoiStatistic = this.aoiStatistics[aoi.Name];
                if ((mode & VisualizationModes.FixationTime) == VisualizationModes.FixationTime)
                {
                    if (aoiStatistic.SumOfTimeOfAllFixations > 0)
                    {
                        var bounds  = this.GetCircleBounds(aoi.Center, aoiStatistic.SumOfTimeOfAllFixations, mode);
                        var ellipse = new VGEllipse(
                            this.BubbleDrawAction,
                            this.BubblePen,
                            this.BubbleBrush,
                            this.BubbleFont,
                            this.BubbleFontColor,
                            bounds,
                            VGStyleGroup.AOI_STATISTICS_BUBBLE,
                            aoiStatistic.SumOfTimeOfAllFixations + " ms",
                            string.Empty);

                        ellipse.TextAlignment = this.BubbleTextAlignment;
                        distances.Add((int)(bounds.Width / 2));
                        this.Elements.Add(ellipse);
                    }
                }

                if ((mode & VisualizationModes.NumberOfFixations) == VisualizationModes.NumberOfFixations)
                {
                    if (aoiStatistic.FixationCount > 0)
                    {
                        var bounds  = this.GetCircleBounds(aoi.Center, aoiStatistic.FixationCount, mode);
                        var ellipse = new VGEllipse(
                            this.BubbleDrawAction,
                            this.BubblePen,
                            this.BubbleBrush,
                            this.BubbleFont,
                            this.BubbleFontColor,
                            bounds,
                            VGStyleGroup.AOI_STATISTICS_BUBBLE,
                            aoiStatistic.FixationCount.ToString(CultureInfo.InvariantCulture),
                            string.Empty);

                        ellipse.TextAlignment = this.BubbleTextAlignment;
                        distances.Add((int)(bounds.Width / 2));
                        this.Elements.Add(ellipse);
                    }
                }

                if ((mode & VisualizationModes.AverageFixationDuration) == VisualizationModes.AverageFixationDuration)
                {
                    if (aoiStatistic.FixationDurationMean > 0)
                    {
                        var bounds  = this.GetCircleBounds(aoi.Center, aoiStatistic.FixationDurationMean, mode);
                        var ellipse = new VGEllipse(
                            this.BubbleDrawAction,
                            this.BubblePen,
                            this.BubbleBrush,
                            this.BubbleFont,
                            this.BubbleFontColor,
                            bounds,
                            VGStyleGroup.AOI_STATISTICS_BUBBLE,
                            aoiStatistic.FixationDurationMean.ToString("N0") + " ms",
                            string.Empty);
                        ellipse.TextAlignment = this.BubbleTextAlignment;
                        distances.Add((int)(bounds.Width / 2));
                        this.Elements.Add(ellipse);
                    }
                }
            }

            // Check for absolute or relative transition values
            var absolute = (mode & VisualizationModes.AbsoluteTransitions) == VisualizationModes.AbsoluteTransitions;

            if ((mode & VisualizationModes.RelativeTransitions) == VisualizationModes.RelativeTransitions ||
                (mode & VisualizationModes.AbsoluteTransitions) == VisualizationModes.AbsoluteTransitions)
            {
                DataView trialsFixations = null;

                // Get filtered fixations data view
                switch (sampleType)
                {
                case SampleType.Gaze:
                    trialsFixations = this.GazeFixationsView;
                    break;

                case SampleType.Mouse:
                    trialsFixations = this.MouseFixationsView;
                    break;
                }

                var transitions = Statistics.Statistic.CreateTransitionMatrixForSingleAOIs(
                    trialsFixations,
                    aoisWithoutSearchRects);

                float transitionSum = 0;

                // Calculate transition total sum only if relative values are requested.
                if (!absolute)
                {
                    for (var i = 0; i <= transitions.GetUpperBound(0); i++)
                    {
                        // Skip nowhere transitions
                        if (i == 0)
                        {
                            continue;
                        }

                        for (var j = 0; j <= transitions.GetUpperBound(1); j++)
                        {
                            // Only take values outside the diagonal
                            if (i == j || j == 0)
                            {
                                continue;
                            }

                            transitionSum += (int)transitions.GetValue(i, j);
                        }
                    }
                }

                // Write transitionMatrix to dgv
                for (var i = transitions.GetLowerBound(0); i <= transitions.GetUpperBound(0); i++)
                {
                    // Skip nowhere transitions
                    if (i == 0)
                    {
                        continue;
                    }

                    for (var j = transitions.GetLowerBound(1); j <= transitions.GetUpperBound(1); j++)
                    {
                        // Only take values above the diagonal
                        if (i >= j)
                        {
                            continue;
                        }

                        float transAtoB;
                        float transBtoA;
                        if (absolute)
                        {
                            transAtoB = (int)transitions.GetValue(i, j);
                            transBtoA = (int)transitions.GetValue(j, i);
                        }
                        else
                        {
                            transAtoB = (float)Math.Round((int)transitions.GetValue(i, j) / transitionSum * 100, 1);
                            transBtoA = (float)Math.Round((int)transitions.GetValue(j, i) / transitionSum * 100, 1);
                        }

                        if (transAtoB > 0 || transBtoA > 0)
                        {
                            var showNumbers = false;
                            if ((this.ArrowDrawAction & ShapeDrawAction.Name) == ShapeDrawAction.Name)
                            {
                                this.ArrowDrawAction |= ~ShapeDrawAction.Name;
                                showNumbers           = true;
                            }

                            var arrow = new VGArrow(this.ArrowDrawAction, this.ArrowPen);
                            arrow.Brush = this.ArrowBrush;
                            if (!showNumbers)
                            {
                                arrow.HideWeights = true;
                            }

                            var location1      = aoisWithoutSearchRects[i - 1].Center;
                            var location2      = aoisWithoutSearchRects[j - 1].Center;
                            var distanceFirst  = distances.Count >= i ? distances[i - 1] : 15;
                            var distanceSecond = distances.Count >= j ? distances[j - 1] : 15;
                            if (location1.X <= location2.X)
                            {
                                arrow.FirstPoint          = location1;
                                arrow.SecondPoint         = location2;
                                arrow.FirstPointDistance  = distanceFirst;
                                arrow.SecondPointDistance = distanceSecond;
                                arrow.FirstPointWeight    = transBtoA;
                                arrow.SecondPointWeight   = transAtoB;
                            }
                            else
                            {
                                arrow.FirstPoint          = location2;
                                arrow.SecondPoint         = location1;
                                arrow.FirstPointDistance  = distanceSecond;
                                arrow.SecondPointDistance = distanceFirst;
                                arrow.FirstPointWeight    = transAtoB;
                                arrow.SecondPointWeight   = transBtoA;
                            }

                            arrow.FormatString = "N0";
                            if (!absolute)
                            {
                                if (arrow.FirstPointWeight < 1 && arrow.SecondPointWeight < 1)
                                {
                                    arrow.FormatString = "N1";
                                }

                                arrow.AddOnString = "%";
                            }

                            arrow.WeightFont      = this.ArrowFont;
                            arrow.WeightFontColor = this.ArrowFontColor;
                            arrow.ScaleFactor     = this.ArrowFactor;
                            arrow.StyleGroup      = VGStyleGroup.AOI_STATISTICS_ARROW;
                            arrow.TextAlignment   = this.ArrowTextAlignment;
                            this.Elements.Add(arrow);
                        }
                    }
                }
            }

            this.DrawForeground(true);
        }
Beispiel #54
0
    ///////////////////////////////////////////////////////////////////////////////
    // Methods for doing main class job                                          //
    ///////////////////////////////////////////////////////////////////////////////
    #region METHODS

    /// <summary>
    /// This method exports the fixations of the given <see cref="SampleType"/>
    /// to the given File including AOI information.
    /// </summary>
    /// <param name="options">An <see cref="ExportOptions"/> with options for the file export.</param>
    /// <param name="type">The <see cref="SampleType"/> to be exported.</param>
    private void Export(ExportOptions options, SampleType type)
    {
      string tableName = string.Empty;
      string fileName = string.Empty;

      DataTable dataTable = new DataTable();
      switch (type)
      {
        case SampleType.Gaze:
          tableName = "GazeFixations";
          dataTable = Document.ActiveDocument.DocDataSet.GazeFixations;
          fileName = options.GazeFileName;
          break;
        case SampleType.Mouse:
          tableName = "MouseFixations";
          dataTable = Document.ActiveDocument.DocDataSet.MouseFixations;
          fileName = options.MouseFileName;
          break;
      }

      bool unknownSubjectFound = false;
      string missingSubjectName = string.Empty;

      using (StreamWriter exportFileWriter = new StreamWriter(fileName))
      {
        // Write Documentation
        exportFileWriter.WriteLine("# File: " + Path.GetFileName(fileName));
        exportFileWriter.WriteLine("# Created: " + DateTime.Today.Date.ToLongDateString() + "," + DateTime.Now.ToLongTimeString());
        exportFileWriter.WriteLine("# with: " + Application.ProductName + " Version: " + Document.ActiveDocument.ExperimentSettings.OgamaVersion.ToString(3));

        exportFileWriter.WriteLine("# Contents: " + tableName + " table.");
        exportFileWriter.WriteLine("# Applies to Projekt:" + Document.ActiveDocument.ExperimentSettings.Name);
        exportFileWriter.WriteLine("#");

        if (options.ExportFixations)
        {
          // Write Column Names
          foreach (DataColumn dataColumn in dataTable.Columns)
          {
            exportFileWriter.Write(dataColumn.Caption);
            exportFileWriter.Write("\t");
          }
        }
        else
        {
          // We should export saccades which need some other column descriptions
          exportFileWriter.Write("SubjectName");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("TrialID");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("TrialSequence");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("CountInTrial");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("StartTime");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Duration");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Distance");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Velocity");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Validity");
          exportFileWriter.Write("\t");
        }

        if (options.ExportSubjectDetails)
        {
          exportFileWriter.Write("SubjectCategory");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Age");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Sex");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Handedness");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Comments");
          exportFileWriter.Write("\t");

          DataTable customParams =
            Document.ActiveDocument.DocDataSet.ParamsAdapter.GetData();
          foreach (DataRow paramRow in customParams.Rows)
          {
            exportFileWriter.Write(paramRow["Param"]);
            exportFileWriter.Write("\t");
          }
        }

        if (options.ExportTrialDetails)
        {
          exportFileWriter.Write("Trial Name");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("Trial Category");
          exportFileWriter.Write("\t");
          exportFileWriter.Write("SlideNr");
          exportFileWriter.Write("\t");
        }

        if (options.ExportAOIDetails)
        {
          if (options.ExportFixations)
          {
            exportFileWriter.Write("AOI");
            exportFileWriter.Write("\t");
            exportFileWriter.Write("AOI group");
            exportFileWriter.Write("\t");
          }
          else
          {
            exportFileWriter.Write("Saccade Target AOI");
            exportFileWriter.Write("\t");
            exportFileWriter.Write("Saccade Target AOI group");
            exportFileWriter.Write("\t");
          }
        }

        exportFileWriter.WriteLine();

        int trialID = -1;
        int lastTrialID = -1;

        string subjectName = string.Empty;
        string lastsubjectName = "LastSubjectKLSMA";

        DataView trialsAOIsView = new DataView(Document.ActiveDocument.DocDataSet.AOIs);
        SubjectsData subjectData = new SubjectsData();
        Dictionary<string, string> subjectParams = new Dictionary<string, string>();

        // Sort fixation data
        DataView fixationsView = new DataView(dataTable);
        fixationsView.Sort = "SubjectName, TrialSequence, CountInTrial ASC";

        VGElementCollection trialAOIs = new VGElementCollection();
        string category = string.Empty;
        string trialName = string.Empty;
        PointF lastFixationCenter = PointF.Empty;
        long lastFixationEndTime = 0;
        int lastFixationDuration = 0;
        int countInTrial = 0;
        int slideNr = 0;
        List<long> slideStartTimes = new List<long>();
        foreach (DataRowView dataRow in fixationsView)
        {
          trialID = (int)dataRow["TrialID"];

          // Skip trials that are not selected.
          if (!options.CheckedTrialIDs.Contains(trialID))
          {
            continue;
          }

          int trialSequence = (int)dataRow["TrialSequence"];
          long startTime = (long)dataRow["StartTime"];
          int length = (int)dataRow["Length"];
          float posX = Convert.ToSingle(dataRow["PosX"]);
          float posY = Convert.ToSingle(dataRow["PosY"]);
          PointF fixationCenter = new PointF(posX, posY);

          subjectName = dataRow["SubjectName"].ToString();
          if (!options.CheckedSubjects.Contains(subjectName))
          {
            continue;
          }

          if (options.ExportSubjectDetails)
          {
            if (subjectName != lastsubjectName)
            {
              subjectData = new SubjectsData();

              DataTable subjectsTable = Document.ActiveDocument.DocDataSet.SubjectsAdapter.GetDataBySubject(subjectName);
              if (subjectsTable.Rows.Count == 0)
              {
                unknownSubjectFound = true;
                missingSubjectName = subjectName;
                continue;
              }

              // Parse subject information
              if (!subjectsTable.Rows[0].IsNull("Age"))
              {
                subjectData.Age = (int)subjectsTable.Rows[0]["Age"];
              }

              subjectData.Category = subjectsTable.Rows[0]["Category"].ToString();
              subjectData.Comments = subjectsTable.Rows[0]["Comments"].ToString();
              subjectData.Handedness = subjectsTable.Rows[0]["Handedness"].ToString();
              subjectData.Sex = subjectsTable.Rows[0]["Sex"].ToString();

              // Parse custom subject information
              subjectParams.Clear();
              DataTable subjectParamsTable = Document.ActiveDocument.DocDataSet.SubjectParametersAdapter.GetDataBySubject(subjectName);
              foreach (DataRow paramRow in subjectParamsTable.Rows)
              {
                subjectParams.Add(paramRow["Param"].ToString(), paramRow["ParamValue"].ToString());
              }

              lastsubjectName = subjectName;
            }
          }

          if (trialID != lastTrialID)
          {
            slideStartTimes.Clear();
            DataTable trialEvents = Document.ActiveDocument.DocDataSet.TrialEventsAdapter.GetDataBySubjectNameTrialSequenceButOnlySlideChangeResponses(subjectName, trialSequence);
            foreach (DataRow slideEventRow in trialEvents.Rows)
            {
              slideStartTimes.Add((long)slideEventRow["EventTime"]);
            }

            countInTrial = 0;
            slideNr = 0;

            if (options.ExportTrialDetails || options.ExportAOIDetails)
            {
              DataTable trialTable = Document.ActiveDocument.DocDataSet.TrialsAdapter.GetDataBySubjectAndTrialID(subjectName, trialID);
              if (trialTable.Rows.Count > 0)
              {
                category = trialTable.Rows[0]["Category"].ToString();
                trialName = trialTable.Rows[0]["TrialName"].ToString();
              }

              string filter = "TrialID=" + trialID + string.Empty;
              trialsAOIsView.RowFilter = filter;
              lastTrialID = trialID;
              trialAOIs.Clear();

              foreach (DataRowView row in trialsAOIsView)
              {
                string strPtList = row["ShapePts"].ToString();
                string aoiType = row["ShapeType"].ToString();
                string aoiName = row["ShapeName"].ToString();
                string shapeGroup = row["ShapeGroup"].ToString();

                VGElement aoi = Queries.GetVGElementFromDatabase(aoiType, aoiName, shapeGroup, strPtList);
                trialAOIs.Add(aoi);
              }
            }
          }

          if (slideStartTimes.Count > (slideNr + 1) && startTime > slideStartTimes[slideNr])
          {
            slideNr++;
          }

          if (options.ExportFixations)
          {
            // Write fixation table content
            foreach (object cellValue in dataRow.Row.ItemArray)
            {
              exportFileWriter.Write(cellValue.ToString());
              exportFileWriter.Write("\t");
            }
          }
          else
          {
            if (countInTrial != 0)
            {
              // we should export saccades
              exportFileWriter.Write(subjectName);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(trialID);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(trialSequence);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(countInTrial);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(lastFixationEndTime);
              exportFileWriter.Write("\t");
              int duration = (int)(startTime - lastFixationEndTime);
              exportFileWriter.Write(duration);
              exportFileWriter.Write("\t");
              float distance = VGPolyline.Distance(lastFixationCenter, fixationCenter);
              exportFileWriter.Write(distance);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(distance / duration);
              exportFileWriter.Write("\t");

              int validity = 0;
              if (duration > lastFixationDuration)
              {
                validity = -1;
              }

              exportFileWriter.Write(validity);
              exportFileWriter.Write("\t");
            }
          }

          if (options.ExportSubjectDetails)
          {
            if (options.ExportFixations || countInTrial != 0)
            {
              // Write subject information
              exportFileWriter.Write(subjectData.Category);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(subjectData.Age);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(subjectData.Sex);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(subjectData.Handedness);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(subjectData.Comments);
              exportFileWriter.Write("\t");

              foreach (string paramValue in subjectParams.Values)
              {
                exportFileWriter.Write(paramValue);
                exportFileWriter.Write("\t");
              }
            }
          }

          if (options.ExportTrialDetails)
          {
            if (options.ExportFixations || countInTrial != 0)
            {
              // Write trial information
              exportFileWriter.Write(trialName != string.Empty ? trialName : "NamelessTrial");
              exportFileWriter.Write("\t");
              exportFileWriter.Write(category);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(slideNr);
              exportFileWriter.Write("\t");
            }
          }

          if (options.ExportAOIDetails)
          {
            if (options.ExportFixations || countInTrial != 0)
            {
              // Retrieve AOI position
              string hittedAOIName = string.Empty;
              string hittedAOIGroup = string.Empty;
              List<string[]> hittedAOIs = Statistics.Statistic.FixationHitsAOI(trialAOIs, dataRow);

              if (hittedAOIs.Count == 0)
              {
                hittedAOIName = "nowhere";
                hittedAOIGroup = "nowhere";
              }

              foreach (string[] aoi in hittedAOIs)
              {
                // Concatenate hitted AOIs
                hittedAOIName += aoi[0] + "#";
                hittedAOIGroup += aoi[1] + "#";
              }

              if (hittedAOIs.Count > 0)
              {
                hittedAOIName = hittedAOIName.Substring(0, hittedAOIName.Length - 1);
                hittedAOIGroup = hittedAOIGroup.Substring(0, hittedAOIGroup.Length - 1);
              }

              exportFileWriter.Write(hittedAOIName);
              exportFileWriter.Write("\t");
              exportFileWriter.Write(hittedAOIGroup);
              exportFileWriter.Write("\t");
            }
          }

          if (options.ExportFixations || countInTrial != 0)
          {
            // Write new line for next row.
            exportFileWriter.WriteLine();
          }

          countInTrial++;
          lastFixationCenter = fixationCenter;
          lastFixationEndTime = startTime + length;
          lastFixationDuration = length;
        }
      }

      if (unknownSubjectFound)
      {
        string message = "At least one fixation of an subject that is not in the database anymore " +
          "was found. Subject: '" + missingSubjectName + "'" + Environment.NewLine +
          "Please re-run a complete fixation calculation for all subjects.";
        ExceptionMethods.ProcessMessage("Old subject fixations found", message);
      }

      ExceptionMethods.ProcessMessage("Export successful.", "Fixations were successfully exported to file");
    }
 public static extern void BeginSample(SampleType type);
Beispiel #56
0
 /// <summary>
 ///     Creates a new histogram metric and registers it under the given type and name
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <param name="sampleType">The sample type</param>
 /// <returns></returns>
 public HistogramMetric Histogram(string name, SampleType sampleType)
 {
     return(_host.Histogram(typeof(TOwner), name, sampleType));
 }
Beispiel #57
0
 public SmallPedigreeSampleOptions(string sampleName, SampleType sampleType, IFileLocation bam)
 {
     SampleName = sampleName;
     SampleType = sampleType;
     Bam        = bam;
 }
        public Action <Image <Gray, byte>, Image <Bgr, byte> > ProcessingStep1_alt_bk(
            int threshold,
            SampleType sampletype,
            int cHnum,
            int cWnum,
            bool debugmode = false)
        {
            return(new Action <Image <Gray, byte>, Image <Bgr, byte> >((baseimg, colorimg) =>
            {
                try
                {
                    Stopwatch stw = new Stopwatch();
                    stw.Start();
                    var color_visual_img = colorimg.Clone();
                    PResult = new ImgPResult(
                        PData.UPAreaLimit,
                        PData.DWAreaLimit,
                        PData.IntenSumUPLimit,
                        PData.IntenSumDWLimit

                        );
                    VectorOfVectorOfPoint contours;
                    if (debugmode)
                    {
                        contours = baseimg
                                   .Map(img => Proc_Method_List[sampletype](img))
                                   .Act(img => img.Save(TestFileSavePath.BasePath + "\\beforcntr.bmp"))
                                   .Map(img => FindContour(img))
                                   .Map(cntr => Sortcontours(cntr));
                    }
                    else
                    {
                        contours = baseimg
                                   .Map(img => Proc_Method_List[sampletype](img))
                                   .Map(img => FindContour(img))
                                   .Map(cntr => Sortcontours(cntr));
                    }
                    var centerMoment = contours
                                       .Map(cntr => CalcCenter(cntr));

                    var boxlist = contours
                                  .Map(cntr => ApplyBox(cntr));

                    byte[,,]   indexingImage = MatPattern(cHnum, cWnum, 3);
                    byte[,,]   passfailPosData = new byte[cHnum, cWnum, 1];
                    double[,,] estedChipP = EstedChipPos(cHnum, cWnum)
                                            .Act(est => DrawCenterPoint(color_visual_img, est))
                                            .Act_LoopChipPos(boxlist
                                                             , centerMoment
                                                             , CheckOkNg_SizeInInten(
                                                                 indexingImage
                                                                 , contours
                                                                 , color_visual_img
                                                                 , ref PResult));

                    var centers = (ClusterData(
                                       (from item in PResult.OutData
                                        select new double[] { item.Intensity })
                                       .ToArray <double[]>())["center"] as  double[][])
                                  .Select(x => x[0])
                                  .OrderBy(x => x)
                                  .ToArray();

                    PResult.OutData
                    .Act(CheckLowOver(
                             estedChipP
                             , indexingImage
                             , color_visual_img
                             , centers
                             , LineThickness));

                    UpdateResult(PResult)(indexingImage, color_visual_img);
                    stw.Stop();
                    Console.WriteLine("Process Time : " + stw.ElapsedMilliseconds);
                }
                catch (Exception er)
                {
                    System.Windows.Forms.MessageBox.Show(er.ToString());
                    evtProcessingDone(true);
                }
            }));
        }
 private void onRBSmallSampleChecked(object sender, RoutedEventArgs e)
 {
     this.mSampleType = SampleType.SMALL;
 }
 private static extern bool context_isSupported(IntPtr dm, ChannelConfig channels, SampleType type, ref IntPtr exceptionPointer);