public PlotTallyButton(CountTreeVM count)
        {
            InitializeComponent();

            _tallyBTN.Click += new EventHandler(this.OnTallyButtonClicked);
            _settingsBTN.Click += new EventHandler(this.OnSettingsButtonClicked);
            this.Count = count;
            UpdateTallyButton();
        }
        public void GetCountByHotKeyTest()
        {
            var stratum = new StratumModel();

            var counts = new CountTreeVM[]
                { new CountTreeVM() { Tally = new TallyDO() { Hotkey = "A" } },
                    new CountTreeVM() {Tally = new TallyDO() { Hotkey = "Banana" } },
                new CountTreeVM() {Tally = new TallyDO() { Hotkey = "cat" } }};

            var samplegroups = new SampleGroupModel[] {
                new SampleGroupModel() { Counts = counts }
            };

            stratum.SampleGroups = new List<SampleGroupModel>(samplegroups);

            Assert.IsTrue(stratum.GetCountByHotKey('A') == counts[0]);
            Assert.IsTrue(stratum.GetCountByHotKey('B') == counts[1]);
            Assert.IsTrue(stratum.GetCountByHotKey('C') == counts[2]);
            Assert.IsNull(stratum.GetCountByHotKey('0'));
        }
        public void PopulateHotKeyLookupTest()
        {
            var stratum = new StratumModel();

            var counts = new CountTreeVM[]
                { new CountTreeVM() { Tally = new TallyDO() { Hotkey = "A" } },
                    new CountTreeVM() {Tally = new TallyDO() { Hotkey = "Banana" } },
                new CountTreeVM() {Tally = new TallyDO() { Hotkey = "cat" } }};

            var samplegroups = new SampleGroupModel[] {
                new SampleGroupModel() { Counts = counts }
            };

            stratum.SampleGroups = new List<SampleGroupModel>(samplegroups);

            Assert.IsNotNull(stratum.HotKeyLookup);

            stratum.PopulateHotKeyLookup();
            Assert.IsNotNull(stratum.HotKeyLookup);
            Assert.IsTrue(stratum.HotKeyLookup.ContainsKey('A'));
            Assert.IsTrue(stratum.HotKeyLookup.ContainsKey('B'));
            Assert.IsTrue(stratum.HotKeyLookup.ContainsKey('C'));
        }
        public void TestTreeTally()
        {
            var st = new StratumModel();
            st.Method = CruiseDAL.Schema.CruiseMethods.STR;

            var sg = new SampleGroupModel();
            sg.Stratum = st;
            sg.SamplingFrequency = 5;
            sg.InsuranceFrequency = 0;
            sg.SampleSelectorType = CruiseDAL.Enums.SampleSelectorType.Block.ToString();

            CountTreeVM count = new CountTreeVM();
            count.SampleGroup = sg;

            int numSamples = 10000;
            for (int i = 0; i < numSamples; i++)
            {
                _de.OnTally(count);
            }

            System.Diagnostics.Debug.WriteLine("Sample Count = " + _controller.SampleCount.ToString());
            System.Diagnostics.Debug.WriteLine("ISample Count = " + _controller.ISampleCount.ToString());
        }
 public void ShowTallySettings(CountTreeVM count)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public TreeVM CreateNewTreeEntry(CountTreeVM count, bool isMeasure)
 {
     return this.CreateNewTreeEntry(count.SampleGroup, count.TreeDefaultValue, isMeasure);
 }
        public void ShowTallySettings(CountTreeVM count)
        {
            try
            {
                count.Save();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return;
            }

            using (FormTallySettings view = new FormTallySettings(this.ApplicationController))
            {
                view.ShowDialog(count);
            }
        }
 public TreeVM CreateNewTreeEntry(CountTreeVM count)
 {
     return CreateNewTreeEntry(count, true);
 }
 public void OnTally(CountTreeVM count)
 {
     this.ViewLogicController.OnTally(count);
 }
Exemplo n.º 10
0
 public TallyAction(CountTreeVM count)
     : this()
 {
     Count = count;
 }
        protected void OnTally(CountTreeVM count, PlotVM plot)
        {
            System.Diagnostics.Debug.Assert(plot != null);
            TreeVM tree = null;
            if (Stratum.Method == CruiseMethods.FIX
                || Stratum.Method == CruiseMethods.PNT)
            {
                tree = plot.CreateNewTreeEntry(count, true);
                this.Controller.ViewController.ShowCruiserSelection(tree);

                tree.TrySave();
                CurrentPlot.AddTree(tree);

                SelectLastTree();
                return;
            }

            SampleGroupDO sg = count.SampleGroup;
            //if ((sg.TallyMethod & CruiseDAL.Enums.TallyMode.Manual) == CruiseDAL.Enums.TallyMode.Manual)
            //{
            //    TreeVM newTree;
            //    newTree = Controller.CreateNewTreeEntry(count, plot, true);
            //    count.TreeCount += sg.SamplingFrequency;
            //    this.Controller.TrySaveTree(newTree);
            //    Controller.OnTally();
            //    return;
            //}

            SampleSelecter sampler = (SampleSelecter)count.SampleGroup.Sampler;
            if (count.SampleGroup.Stratum.Is3P)
            {
                int kpi = 0;
                int? value = ViewController.AskKPI((int)count.SampleGroup.MinKPI, (int)count.SampleGroup.MaxKPI);
                if (value == null)
                {
                    return;
                }
                else
                {
                    kpi = value.Value;
                }

                //if kpi == -1 then tree is sure to measure
                if (kpi != -1)
                {
                    ThreePItem item = (ThreePItem)((ThreePSelecter)sampler).NextItem();

                    if (item != null && kpi > item.KPI)
                    {
                        //because the three p sample selector doesn't select insurance trees for us
                        //we need to select them our selves
                        if (sampler.IsSelectingITrees)
                        {
                            item.IsInsuranceItem = sampler.InsuranceCounter.Next();
                        }
                        if (item.IsInsuranceItem)
                        {
                            this.ViewController.SignalInsuranceTree();
                            tree = plot.CreateNewTreeEntry(count, true);
                            tree.CountOrMeasure = "I";
                        }
                        else
                        {
                            this.ViewController.SignalMeasureTree(true);
                            tree = plot.CreateNewTreeEntry(count, true);
                            //tree.CountOrMeasure = "M";
                        }
                    }
                    else
                    {
                        tree = plot.CreateNewTreeEntry(count, false);
                        //tree.CountOrMeasure = "C";
                    }
                    tree.KPI = kpi;
                }
                else
                {
                    tree = plot.CreateNewTreeEntry(count, true);
                    tree.STM = "Y";
                }
            }
            else
            {
                //count.TreeCount++; tree count doesn't get incremented for plots

                boolItem item = (sampler != null) ? (boolItem)sampler.NextItem() : (boolItem)null;
                if (item != null && !item.IsInsuranceItem)
                {
                    this.ViewController.SignalMeasureTree(true);
                    tree = plot.CreateNewTreeEntry(count, true);
                    //tree.CountOrMeasure = "M";
                }
                else if (item != null && item.IsInsuranceItem)
                {
                    this.ViewController.SignalInsuranceTree();
                    tree = plot.CreateNewTreeEntry(count, true);
                    tree.CountOrMeasure = "I";
                }
                else
                {
                    tree = plot.CreateNewTreeEntry(count, false);
                }
            }

            tree.TreeCount = 1;
            tree.TrySave();

            plot.AddTree(tree);
        }
        //public void HandleTreeNumberChanging(long newTreeNumber, out bool cancel)
        //{
        //    try
        //    {
        //        if (!this.CurrentPlot.IsTreeNumberAvalible(newTreeNumber))
        //        {
        //            cancel = true;
        //            return;
        //        }
        //    }
        //    catch
        //    {
        //        cancel = true;
        //        return;
        //    }
        //    cancel = false;
        //}
        public void OnTally(CountTreeVM count)
        {
            if (!this.EnsureCurrentPlotWorkable()) { return; }

            this.OnTally(count, this.CurrentPlot);
            this.SelectLastTree();
        }
        public Control MakeTallyRow(Control container, CountTreeVM count)
        {
            var row = new TallyRow(count);
            row.SuspendLayout();

            row.TallyButtonClicked += new EventHandler(this.OnTallyButtonClicked);
            row.SettingsButtonClicked += new EventHandler(this.OnTallySettingsClicked);

            row.Parent = container;
            row.AdjustHeight();

            row.Dock = DockStyle.Top;
            row.ResumeLayout(false);
            return row;
        }
        private void OnSample(TallyAction action, CountTreeVM count, bool isInsurance)
        {
            TreeVM tree = Unit.CreateNewTreeEntry(count);
            tree.CountOrMeasure = (isInsurance) ? "I" : "M";

            action.TreeRecord = tree;

            if (!isInsurance)
            {
                this.ViewController.SignalMeasureTree(true);
            }
            else
            {
                this.ViewController.SignalInsuranceTree();
            }

            this.ViewController.ShowCruiserSelection(tree);

            tree.TrySave();
            Unit.AddNonPlotTree(tree);

            if (!isInsurance && View.AskEnterMeasureTreeData())
            {
                this.View.GotoTreePage();
                this.View.TreeViewMoveLast();
            }
        }
        public void OnTally(CountTreeVM count)
        {
            TallyAction action = new TallyAction(count);
            SampleGroupDO sg = count.SampleGroup;

            //if doing a manual tally create a tree and jump out
            //if ((sg.TallyMethod & CruiseDAL.Enums.TallyMode.Manual) == CruiseDAL.Enums.TallyMode.Manual)
            //{
            //    TreeVM newTree;
            //    newTree = Controller.CreateNewTreeEntry(count, null, true); //create measure tree
            //    count.TreeCount += sg.SamplingFrequency;                    //increment tree count on tally
            //    this.Controller.TrySaveTree(newTree);
            //    Controller.AddTallyAction(action);
            //    Controller.OnTally();
            //    return;
            //}

            SampleSelecter sampler = (SampleSelecter)count.SampleGroup.Sampler;
            if (count.SampleGroup.Stratum.Is3P)//threeP sampling
            {
                int kpi = 0;
                int? value = ViewController.AskKPI((int)count.SampleGroup.MinKPI, (int)count.SampleGroup.MaxKPI);
                if (value == null)
                {
                    return;
                }
                else
                {
                    kpi = value.Value;
                }
                if (kpi == -1)  //user enterted sure to measure
                {
                    TreeVM tree;
                    tree = Unit.CreateNewTreeEntry(count);
                    tree.STM = "Y";
                    tree.TrySave();
                    Unit.AddNonPlotTree(tree);
                    action.TreeRecord = tree;
                }
                else
                {
                    action.TreeEstimate = count.LogTreeEstimate(kpi);
                    action.KPI = kpi;
                    count.SumKPI += kpi;

                    ThreePItem item = (ThreePItem)((ThreePSelecter)sampler).NextItem();
                    if (item != null && kpi > item.KPI)
                    {
                        if (sampler.IsSelectingITrees)
                        {
                            item.IsInsuranceItem = sampler.InsuranceCounter.Next();
                        }
                        this.OnSample(action, count, kpi, item.IsInsuranceItem);
                    }
                }
            }
            else//non 3P sampling (STR)
            {
                boolItem item = (boolItem)sampler.NextItem();
                //If we recieve nothing from from the sampler, we don't have a sample
                if (item != null)//&& (item.IsSelected || item.IsInsuranceItem))
                {
                    this.OnSample(action, count, (item != null && item.IsInsuranceItem));
                }
            }

            count.TreeCount++;
            Unit.TallyHistoryBuffer.Add(action);
        }
        public DialogResult ShowDialog(CountTreeVM count)
        {
            var method = count.SampleGroup.Stratum.Method;
            bool isPlot = Array.IndexOf(CruiseDAL.Schema.CruiseMethods.PLOT_METHODS, method) >= 0;
            bool isThreep = count.SampleGroup.Stratum.Is3P;

            this.EnableTallyCount = !isPlot;
            this.EnableBigBAF = isPlot;
            this.EnableIFrequency = !isPlot;
            this.EnableTotalTreeCount = !isPlot;

            this.EnableFrequency = !isThreep;
            this.EnableKZ = isThreep;
            this.EnableSumKPI = (isThreep && !isPlot);

            //this.comboBox1.SelectedItem = (count.Tag is BlockSelecter) ? TallyMode.Block.ToString() : (count.Tag is SRSSelecter) ? TallyMode.SRS.ToString() : (count.Tag is SystematicSelecter) ? TallyMode.Systematic.ToString() : "???";
            this._tallyDescription_TB.Text = count.Tally.Description;
            this._SGDescription_TB.Text = count.SampleGroup.Description;
            this._frequencyTB.Text = count.SampleGroup.ToString("1 in [SamplingFrequency]", null);
            this._kzTB.Text = count.SampleGroup.KZ.ToString();
            this._SumKPI_TB.Text = count.SumKPI.ToString();
            this._bigBAFTB.Text = count.SampleGroup.BigBAF.ToString();
            this._iFreqTB.Text = count.SampleGroup.InsuranceFrequency.ToString();
            this._tallyCount_TB.Text = count.TreeCount.ToString();
            long countsFromTrees = count.GetCountsFromTrees();
            this._countsFromTrees_TB.Text = countsFromTrees.ToString();
            this._totalTreeCount_TB.Text = (countsFromTrees + count.TreeCount).ToString();
            this._measureTrees_TB.Text = count.GetMeasureTreeCount().ToString();

            String samplingMethod = "Manual";
            SampleSelecter sampler = count.SampleGroup.Sampler;
            if (sampler != null)
            {
                if (sampler is SystematicSelecter)
                {
                    samplingMethod = "Systematic with random start";
                }
                else if (sampler is BlockSelecter)
                {
                    samplingMethod = "Blocked";
                }
                else if (sampler is ThreePSelecter)
                {
                    samplingMethod = "Three P";
                }
            }
            this._samplingMethod_TB.Text = samplingMethod;

            _count = count;
            DialogResult result = this.ShowDialog();
            _count = null;
            return result;
        }
Exemplo n.º 17
0
        public Control MakeTallyRow(Control container, CountTreeVM count)
        {
            var row = new PlotTallyRow(count);
            row.SuspendLayout();

            row.TallyButtonClicked += new EventHandler(this.tallyRow_TallyButtonClicked);
            row.SettingsButtonClicked += new EventHandler(this.tallyRow_InfoButtonClicked);

            row.Height = 56;
            row.Parent = container;

            row.Dock = DockStyle.Top;
            row.ResumeLayout(true);
            return row;
        }
Exemplo n.º 18
0
 public TallyAction(TreeVM treeRecord, CountTreeVM count)
 {
     TreeRecord = treeRecord;
 }
Exemplo n.º 19
0
        public void LoadCounts(CuttingUnitDO unit)
        {
            var counts = new List<CountTreeVM>();
            var tallySettings = DAL.From<TallySettingsDO>()
                .Where("SampleGroup_CN = ?")
                .GroupBy("CountTree.SampleGroup_CN", "CountTree.TreeDefaultValue_CN", "CountTree.Tally_CN")
                .Read(SampleGroup_CN);

            foreach (TallySettingsDO ts in tallySettings)
            {
                CountTreeVM count = DAL.From<CountTreeVM>()
                    .Where("CuttingUnit_CN = ? AND SampleGroup_CN = ? AND Tally_CN = ?")
                    .Read(unit.CuttingUnit_CN
                    , ts.SampleGroup_CN
                    , ts.Tally_CN).FirstOrDefault();
                if (count == null)
                {
                    count = new CountTreeVM(DAL);
                    count.CuttingUnit = unit;
                    count.SampleGroup_CN = ts.SampleGroup_CN;
                    count.TreeDefaultValue_CN = ts.TreeDefaultValue_CN;
                    count.Tally_CN = ts.Tally_CN;

                    count.Save();
                }

                count.SampleGroup = this;

                counts.Add(count);
            }

            Counts = counts;
        }
Exemplo n.º 20
0
        public Control MakeTallyRow(Control container, CountTreeVM count)
        {
            var row = new PlotTallyButton(count);
            row.SuspendLayout();

            row.TallyButtonClicked += new EventHandler(this.TallyButton_Click);
            row.SettingsButtonClicked += new EventHandler(this.SettingsButton_Click);

            row.Width = 90;
            row.Parent = container;

            row.Dock = DockStyle.Left;
            row.ResumeLayout(false);
            return row;
        }