public void DeleteElementTest()
 {
     Multiplicity<int> many = new Multiplicity<int>();
     many.AddElement(1);
     many.DeleteELement(1);
     Assert.IsTrue(many.IsEmpty());
 }
예제 #2
1
 public DomainRole(DslDocument Doc, String Name, String DisplayName, String PropertyName, String PropertyDisplayName, Multiplicity Multiplicity)
     : base(Doc.CreateElement("DomainRole"))
 {
     this.Xml.SetAttribute("Id", Guid.NewGuid().ToString());
     this.Xml.SetAttribute("Name", Name);
     this.Xml.SetAttribute("DisplayName", DisplayName);
     this.Xml.SetAttribute("PropertyName", PropertyName);
     this.Xml.SetAttribute("PropertyDisplayName", PropertyDisplayName);
     this.Xml.SetAttribute("Multiplicity", Multiplicity.ToString());
     this.RolePlayer = Name;
 }
예제 #3
1
        public GroupRx(Multiplicity multiplicity, params IRx[] items)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }
            if (items.Length == 0)
            {
                throw new ArgumentException("Items should not be empty!", "items");
            }

            _items = items;
            _multiplicity = multiplicity;
        }
예제 #4
0
        protected void updateRanges(Multiplicity owner, MultiplicityRange newRange)
        {
            List <object> ranges = owner.getRange();

            ranges.Add(newRange);
            owner.setRange(ranges);
        }
예제 #5
0
파일: Dsl.cs 프로젝트: Obles/vwdaddin
 public DomainRelationship CreateRelationship(DomainClass Source, Multiplicity SourceMultiplicity, DomainClass Target, Multiplicity TargetMultiplicity, Boolean IsEmbedding)
 {
     DomainRelationship dr = new DomainRelationship(
         OwnerDocument,
         Source.Xml.GetAttribute("Name") + (IsEmbedding ? "Has" : "References") + Target.Xml.GetAttribute("Name"),
         Source.Xml.GetAttribute("DisplayName") + (IsEmbedding ? " Has " : " References ") + Target.Xml.GetAttribute("DisplayName"),
         IsEmbedding
     );
     dr.Source = new DomainRole(OwnerDocument,
         Source.Xml.GetAttribute("Name"),
         Source.Xml.GetAttribute("DisplayName"),
         Target.Xml.GetAttribute("Name"),
         Target.Xml.GetAttribute("DisplayName"),
         SourceMultiplicity
     );
     dr.Target = new DomainRole(OwnerDocument,
         Target.Xml.GetAttribute("Name"),
         Target.Xml.GetAttribute("DisplayName"),
         Source.Xml.GetAttribute("Name"),
         Source.Xml.GetAttribute("DisplayName"),
         TargetMultiplicity
     );
     Relationships.Add(dr);
     return dr;
 }
예제 #6
0
        private void AddNextBtn_Click(object sender, EventArgs e)
        {
            SelectorPanel.Visible        = false;
            AddDetectorTypePanel.Visible = false;

            // Create new detector with default parameters for the selected type
            DataSourceIdentifier did = new DataSourceIdentifier();

            did.DetectorName = AddDetectorNameTextBox.Text;
            InstrType dt;

            INCCDB.Descriptor desc = (INCCDB.Descriptor)AddDetectorTypeComboBox.SelectedItem;
            System.Enum.TryParse <InstrType>(desc.Name, out dt);
            did.SRType       = dt;
            did.FullConnInfo = new LMConnectionInfo();
            Multiplicity mkey = new Multiplicity(InstrTypeExtensions.DefaultFAFor(did.SRType));

            det = new Detector(did, mkey, null);

            // Jump to an edit panel for the parameters of the appropriate type
            if (det != null)
            {
                if (det.Id.SRType == InstrType.MCA527)
                {
                    PopulateMCA527ParamFields();
                }
                else
                {
                    PopulateLMMM_PTR32ParamFields();
                }
            }
            AddingNew = true;
        }
예제 #7
0
파일: Overview.cs 프로젝트: radtek/INCC6
        List <string> GenDetMultStr(Detector det, Multiplicity m)
        {
            List <string> ls = new List <string>();

            ls.Add(string.Format("{0,10}: {1,7} {2}", "Predelay", m.SR.predelay.ToString(), "tics"));
            ls.Add(string.Format("{0,10}: {1,7} {2}", "Gate length", m.SR.gateLength.ToString(), "tics"));
            ls.Add(string.Format("{0,10}: {1,7}", "High voltage", m.SR.highVoltage.ToString()));
            ls.Add(string.Format("{0,10}: {1,7} {2}", "DieAway time", m.SR.dieAwayTime.ToString(), "tics"));
            ls.Add(string.Format("{0,10}: {1,7}", "Efficiency", m.SR.efficiency.ToString()));
            ls.Add(string.Format("{0,15}: {1,7} {2}", "Multiplicity deadtime (T)", m.SR.deadTimeCoefficientTinNanoSecs.ToString(), "pSec"));
            ls.Add(string.Format("{0,15}: {1,7} {2}", "Coefficient A deadtime", m.SR.deadTimeCoefficientAinMicroSecs.ToString(), "µSec"));
            ls.Add(string.Format("{0,15}: {1,7} {2}", "Coefficient B deadtime", m.SR.deadTimeCoefficientBinPicoSecs.ToString(), "pSec"));
            ls.Add(string.Format("{0,15}: {1,7} {2}", "Coefficient C deadtime", m.SR.deadTimeCoefficientCinNanoSecs.ToString(), "pSec"));
            ls.Add(string.Format("{0,15}: {1,7}", "Doubles gate fraction", m.SR.doublesGateFraction.ToString()));
            ls.Add(string.Format("{0,15}: {1,7}", "Triples gate fraction", m.SR.triplesGateFraction.ToString()));
            if (det.ListMode)
            {
                ls.Add(string.Format("{0,10}: {1,7}", "Triggering", m.FA == FAType.FAOff ? "Conventional" : "Fast accidentals"));
                if (m.FA == FAType.FAOn)
                {
                    ls.Add(string.Format("{0,10}: {1,7} {2}", "Bkg gate", m.BackgroundGateTimeStepInTics, "tics"));
                }
                else
                {
                    ls.Add(string.Format("{0,15}: {1,7} {2}", "Acc gate delay", m.AccidentalsGateDelayInTics, "tics"));
                }
            }
            return(ls);
        }
예제 #8
0
        public CountingAnalysisParameters CountingParameters(Detector det, bool applySRFromDetector)
        {
            CountingAnalysisParameters cap = CountingParameters(det.Id.DetectorName);

            if (applySRFromDetector)
            {
                Multiplicity m = det.MultiplicityParams;
                foreach (SpecificCountingAnalyzerParams s in cap)
                {
                    Type t = s.GetType();
                    if (t.Equals(typeof(Multiplicity)))
                    {
                        Multiplicity thisone = ((Multiplicity)s);
                        ulong        gw      = thisone.gateWidthTics;
                        //ulong predelay = thisone.SR.predelay;
                        thisone.SR = new ShiftRegisterParameters(m.SR); // use the current detector's SR params, then
                        thisone.SetGateWidthTics(gw);                   // override with the user's choice from the DB
                        //thisone.SR.predelay = predelay;
                    }
                    else if (t.Equals(typeof(Coincidence)))
                    {
                        Coincidence thisone = ((Coincidence)s);
                        ulong       gw      = thisone.gateWidthTics;
                        //ulong predelay = thisone.SR.predelay;
                        thisone.SR = new ShiftRegisterParameters(m.SR); // use the current detector's SR params, then
                        thisone.SetGateWidthTics(gw);                   // override with the user's choice from the DB
                        //thisone.SR.predelay = predelay;
                    }
                }
            }
            return(cap);
        }
예제 #9
0
        public void AddStringElementTest()
        {
            Multiplicity <string> multiplicity = new Multiplicity <string>();

            multiplicity.Insert("ololo");
            Assert.IsTrue(multiplicity.ExistenceChecking("ololo"));
        }
예제 #10
0
        public void AddIntElementTest()
        {
            Multiplicity <int> multiplicity = new Multiplicity <int>();

            multiplicity.Insert(1);
            Assert.IsTrue(multiplicity.ExistenceChecking(1));
        }
예제 #11
0
        /// <summary>
        /// Reads the associations.
        /// </summary>
        private void ReadAssociations()
        {
            foreach (XmlNode assocNode in _xdoc.SelectNodes("/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Association/UML:Association.connection", _nsManager))
            {
                XmlNodeList assocEndNodes = assocNode.SelectNodes("UML:AssociationEnd", _nsManager);

                string typeName;
                bool   isPrimitive;
                bool   classExists;

                XmlNode node2 = assocEndNodes[0].SelectSingleNode("UML:AssociationEnd.participant/UML:Class", _nsManager);
                string  id    = node2.Attributes["xmi.idref"].Value;
                GetTypeInfo(id, out typeName, out isPrimitive);

                ClassNameInfo nameHelper = new ClassNameInfo(_initialNamespace, typeName);
                Entity        source     = (Entity)_layer.AddTypeIfNotExists(nameHelper, false, out classExists);
                Debug.Assert(isPrimitive == false && classExists == true);
                XmlNode      multiplicityNode   = assocEndNodes[0].SelectSingleNode("UML:AssociationEnd.multiplicity/UML:Multiplicity/UML:Multiplicity.range/UML:MultiplicityRange", _nsManager);
                Multiplicity sourceMultiplicity = GetMultiplicityFromValue(multiplicityNode.Attributes["lower"].Value, multiplicityNode.Attributes["upper"].Value);

                node2 = assocEndNodes[1].SelectSingleNode("UML:AssociationEnd.participant/UML:Class", _nsManager);
                id    = node2.Attributes["xmi.idref"].Value;
                GetTypeInfo(id, out typeName, out isPrimitive);
                Entity target = (Entity)_layer.AddTypeIfNotExists(nameHelper, false, out classExists);
                Debug.Assert(isPrimitive == false && classExists == true);
                multiplicityNode = assocEndNodes[1].SelectSingleNode("UML:AssociationEnd.multiplicity/UML:Multiplicity/UML:Multiplicity.range/UML:MultiplicityRange", _nsManager);
                Multiplicity targetMultiplicity = GetMultiplicityFromValue(multiplicityNode.Attributes["lower"].Value, multiplicityNode.Attributes["upper"].Value);

                Association assoc = source.AddAssociationTo(target);
                assoc.SourceMultiplicity = sourceMultiplicity;
                assoc.TargetMultiplicity = targetMultiplicity;
            }
        }
 public Association(string name, Multiplicity multiplicity, string target)
     : base()
 {
     Name = name;
     Multiplicity = multiplicity;
     Target = target;
     this.Annotation = new LinkedList<Annotation>();
 }
 public void UnificationTest()
 {
     Multiplicity<int> many = new Multiplicity<int>();
     many.AddElement(1);
     Multiplicity<int> many2 = new Multiplicity<int>();
     many2.Unification(many);
     Assert.IsFalse(many2.IsEmpty());
 }
 static Port.Capacity ToCapacity(Multiplicity multiplicity)
 {
     if (multiplicity == Multiplicity.ExactlyOne || multiplicity == Multiplicity.ZeroOrOne)
     {
         return(Port.Capacity.Single);
     }
     return(Port.Capacity.Multi);
 }
예제 #15
0
파일: Central.cs 프로젝트: tempbottle/INCC6
 /// <summary>
 /// For a list-mode-only measurement with a multiplicity analyzer the detector SR params must match at least one of the multiplicity analyzer SR params
 /// </summary>
 public static void ApplyVSRChangesToDefaultDetector(Measurement meas)
 {
     if (meas.AnalysisParams.HasMultiplicity())                                  // devnote: override default detector settings
     {
         Multiplicity mkey = meas.AnalysisParams.GetFirstMultiplicityAnalyzer(); // hack: multmult just using the first one found, lame, shoud be using closest match
         meas.Detectors[0].MultiplicityParams.CopyValues(mkey);
     }
 }
예제 #16
0
        public void RemovingOfElementTest()
        {
            Multiplicity <int> multiplicity = new Multiplicity <int>();

            multiplicity.Insert(1);
            multiplicity.RemovingOfElement(1);
            Assert.IsTrue(multiplicity.IsEmpty());
        }
 public void IntersectionTest()
 {
     Multiplicity<int> many = new Multiplicity<int>();
     many.AddElement(1);
     Multiplicity<int> many2 = new Multiplicity<int>();
     Multiplicity<int> result = many.Intersection(many2);
     Assert.IsTrue(result.IsEmpty());
 }
예제 #18
0
 public MultiplicityTestData(Multiplicity expected, params string[] args) : base(ParseTarget.Multiplicity, args)
 {
     if (expected == null)
     {
         throw new ArgumentNullException("expected");
     }
     ExpectedMultiplicity = expected;
 }
 public Association()
     : base()
 {
     this.Name = string.Empty;
     this.Target = string.Empty;
     Multiplicity = Multiplicity.ZeroToOne;
     this.Annotation = new LinkedList<Annotation>();
     Valuation = string.Empty;
 }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        /// <param name="ownerField">The referencing field.</param>
        /// <param name="targetType">The referenced type.</param>
        /// <param name="multiplicity">The association multiplicity.</param>
        /// <param name="onOwnerRemove">The <see cref="OnRemoveAction"/> that will be applied on <see cref="OwnerType"/> object removal.</param>
        /// <param name="onTargetRemove">The <see cref="OnRemoveAction"/> that will be applied on <see cref="TargetType"/> object removal.</param>
        public AssociationInfo(FieldInfo ownerField, TypeInfo targetType, Multiplicity multiplicity,
                               OnRemoveAction?onOwnerRemove, OnRemoveAction?onTargetRemove)
        {
            OwnerField     = ownerField;
            TargetType     = targetType;
            Multiplicity   = multiplicity;
            OnOwnerRemove  = onOwnerRemove;
            OnTargetRemove = onTargetRemove;
            ancestors      = new NodeCollection <AssociationInfo>(this, "Ancestors");
        }
예제 #21
0
        // build up the requested analyses for this run from the list of analyzer params
        internal void PrepareAndStartCountingAnalyzers(CountingAnalysisParameters ap)
        {
            if (ap == null)
            {
                logger.TraceEvent(LogLevels.Error, 1519, "No counting analyzers specified");
                return;
            }

            bool good = false;

            foreach (SpecificCountingAnalyzerParams sap in ap)
            {
                if (!sap.Active) // skip disabled analyzers
                {
                    continue;
                }
                if (sap is BaseRate)
                {
                    BaseRate b = (BaseRate)sap;
                    good = State.Sup.AddRates(b.gateWidthTics);
                    if (!good)
                    {
                        // perhaps the gate is too large
                        // dev note : each analyzer should publish it's limits with constant attributes on the class
                        good = State.Sup.AddRates(b.gateWidthTics = (ulong)1e7);
                        logger.TraceEvent(LogLevels.Warning, 1512, "Rate analyzer gatewidth created with default {0} ticks", b.gateWidthTics);
                    }
                }
                else if (sap is Multiplicity)
                {
                    Multiplicity m = (Multiplicity)sap;
                    good = State.Sup.AddMultiplicity(m, m.FA);
                }
                else if (sap is Rossi)
                {
                    Rossi r = (Rossi)sap;
                    good = State.Sup.AddRossi(r.gateWidthTics);
                }
                else if (sap is Feynman)
                {
                    Feynman f = (Feynman)sap;
                    good = State.Sup.AddFeynman(f.gateWidthTics);
                }
                else if (sap is TimeInterval)
                {
                    TimeInterval ti = (TimeInterval)sap;
                    good = State.Sup.AddTimeInterval(ti.gateWidthTics);
                }
                else if (sap is Coincidence)
                {
                    Coincidence co = (Coincidence)sap;
                    good = State.Sup.AddCoincidenceMatrix(co);
                }
            }
        }
예제 #22
0
 public static String AsDigits(Multiplicity mult)
 {
     switch (mult)
     {
         case Multiplicity.ZeroMany: return "0..*";
         case Multiplicity.ZeroOne: return "0..1";
         case Multiplicity.One: return "1";
         case Multiplicity.OneMany: return "1..*";
         default: throw new NotImplementedException();
     }
 }
예제 #23
0
 internal void DeriveMultiplicity()
 {
     if (this.RoleType?.ObjectType != null && this.RoleType.ObjectType.IsUnit)
     {
         this.multiplicity = Multiplicity.OneToOne;
     }
     else
     {
         this.multiplicity = this.AssignedMultiplicity;
     }
 }
예제 #24
0
        public void UnionTest()
        {
            Multiplicity <int> multiplicity1 = new Multiplicity <int>();

            multiplicity1.Insert(1);
            Multiplicity <int> multiplicity2 = new Multiplicity <int>();
            Multiplicity <int> result        = new Multiplicity <int>();

            result.Union(multiplicity1, multiplicity2);
            Assert.IsFalse(result.IsEmpty());
        }
예제 #25
0
        public ResourceAssociations FindAssociationsOfMultiplicity(Multiplicity resourceTypeEndMul, Multiplicity otherEndMul)
        {
            ResourceAssociations associationsFoundWithMul = new ResourceAssociations();

            foreach (ResourceProperty prop in this.Properties.OfType <ResourceProperty>().Where(p => p.IsNavigation == true && p.Name != null))
            {
                if (prop.AssociationEnd.Multiplicity == resourceTypeEndMul && prop.OtherAssociationEnd.Multiplicity == otherEndMul)
                {
                    associationsFoundWithMul.Add(prop.ResourceAssociation);
                }
            }
            return(associationsFoundWithMul);
        }
예제 #26
0
        private static bool ApplyNavigationProperty(ContainmentQuery query, Multiplicity mult, bool isLink)
        {
            ResourceProperty property = getRandomNavigationProperty(query.Type, mult);

            if (property == null)
            {
                return(false);
            }

            query.Type      = property.OtherAssociationEnd.ResourceType;
            query.Container = query.Container.FindDefaultRelatedContainer(property);
            query.Query     = query.Query.Nav(property.Property(), isLink);
            return(true);
        }
        protected bool getSpecificIsOneMultiplicity()
        {
            Multiplicity  multiplicity    = getMultiplicity();
            List <object> rangeCollection = multiplicity.getRange();

            foreach (MultiplicityRange range in rangeCollection)
            {
                if (range.getUpper() == 1 && rangeCollection.Count == 1)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #28
0
        protected override bool getSpecificIsMandatory()
        {
            Multiplicity  multiplicity    = getMultiplicity();
            List <object> rangeCollection = multiplicity.getRange();

            foreach (MultiplicityRange range in rangeCollection)
            {
                if (range.getLower() == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #29
0
        public void Intersection1Test()
        {
            Multiplicity <int> multiplicity1 = new Multiplicity <int>();

            multiplicity1.Insert(1);
            Multiplicity <int> multiplicity2 = new Multiplicity <int>();

            multiplicity2.Insert(2);
            Multiplicity <int> result = new Multiplicity <int>();

            result.Insert(1234);
            result.Intersection(multiplicity1, multiplicity2);
            Assert.IsTrue(result.IsEmpty());
        }
        public static bool IsValid(Multiplicity multiplicity, int nbConnections)
        {
            switch (multiplicity)
            {
            case Multiplicity.ZeroOrOne when nbConnections < 2:
            case Multiplicity.ExactlyOne when nbConnections == 1:
            case Multiplicity.OneOrMore when nbConnections > 0:
            case Multiplicity.Any:
            case Multiplicity.Zero when nbConnections == 0:
                return(true);

            default:
                return(false);
            }
        }
예제 #31
0
        public static int UpperBound(this Multiplicity m)
        {
            switch (m)
            {
            case Multiplicity.One:
            case Multiplicity.ZeroOrOne:
                return(1);

            case Multiplicity.ZeroOrMore:
                return(Int32.MaxValue);

            default:
                throw new ArgumentOutOfRangeException("m", "unknown value");
            }
        }
예제 #32
0
        /// <summary>
        /// maps from a RelationEnd.Multiplicity to EF's RelationshipMultiplicity as used in the SSDL part of EDMX
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public static RelationshipMultiplicity ToSsdlMultiplicity(this Multiplicity m)
        {
            switch (m)
            {
            case Multiplicity.One:
            case Multiplicity.ZeroOrOne:
                return(RelationshipMultiplicity.ZeroOrOne);

            case Multiplicity.ZeroOrMore:
                return(RelationshipMultiplicity.Many);

            default:
                throw new ArgumentOutOfRangeException("m");
            }
        }
예제 #33
0
        protected override bool getSpecificIsOneMultiplicity()
        {
            Multiplicity  multiplicity    = getMultiplicity();
            List <object> rangeCollection = multiplicity.getRange();
            int           index           = 0;

            foreach (MultiplicityRange range in rangeCollection)
            {
                if (range.getUpper() == 1 && index != rangeCollection.Count - 1)
                {
                    return(true);
                }
                index++;
            }
            return(false);
        }
예제 #34
0
        /// <summary>
        /// maps from a RelationEnd.Multiplicity to EF's RelationshipMultiplicity as used in the CSDL part of EDMX
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public static RelationshipMultiplicity ToCsdlRelationshipMultiplicity(this Multiplicity m)
        {
            switch (m)
            {
            case Multiplicity.One:
            case Multiplicity.ZeroOrOne:
                // ObjectReferences in C# are always nullable
                return(RelationshipMultiplicity.ZeroOrOne);

            case Multiplicity.ZeroOrMore:
                return(RelationshipMultiplicity.Many);

            default:
                throw new ArgumentOutOfRangeException("m");
            }
        }
예제 #35
0
        void PlotThePlots(CycleList cl, Multiplicity mkey)
        {
            Series s1 = Singles.Series["Vals"];

            s1.MarkerStyle       = MarkerStyle.Circle;
            s1.MarkerColor       = System.Drawing.Color.SkyBlue;
            s1.MarkerSize        = 5;
            s1.MarkerBorderColor = System.Drawing.Color.DarkCyan;
            s1.Color             = System.Drawing.Color.MediumPurple;

            Series s2 = Doubles.Series["Vals"];

            s2.MarkerStyle       = MarkerStyle.Circle;
            s2.MarkerColor       = System.Drawing.Color.SkyBlue;
            s2.MarkerSize        = 5;
            s2.MarkerBorderColor = System.Drawing.Color.DarkCyan;
            s2.Color             = System.Drawing.Color.MediumPurple;

            Series s3 = Triples.Series["Vals"];

            s3.MarkerStyle       = MarkerStyle.Circle;
            s3.MarkerColor       = System.Drawing.Color.SkyBlue;
            s3.MarkerSize        = 5;
            s3.MarkerBorderColor = System.Drawing.Color.DarkCyan;
            s3.Color             = System.Drawing.Color.MediumPurple;

            int i = 0;

            foreach (Cycle c in cl)
            {
                i++;
                MultiplicityCountingRes mcr = c.MultiplicityResults(mkey);
                bool somtingfunnyhere       = (c.QCStatus(mkey).status != QCTestStatus.Pass);

                int idx = s1.Points.AddXY(i, mcr.DeadtimeCorrectedSinglesRate.v);  // next: vary color and shape based on cycle status/outlier status
                s2.Points.AddXY(i, mcr.DeadtimeCorrectedDoublesRate.v);
                s3.Points.AddXY(i, mcr.DeadtimeCorrectedTriplesRate.v);
                if (somtingfunnyhere)
                {
                    s1.Points[idx].MarkerColor = System.Drawing.Color.Orchid;
                    s2.Points[idx].MarkerColor = System.Drawing.Color.Orchid;
                    s3.Points[idx].MarkerColor = System.Drawing.Color.Orchid;
                    s1.Points[idx].ToolTip     = string.Format("#{0} {1}", c.seq, c.QCStatus(mkey).INCCString());
                    s3.Points[idx].ToolTip     = s2.Points[idx].ToolTip = s1.Points[idx].ToolTip;
                }
            }
        }
예제 #36
0
        /// <summary>
        /// Guaranteed to return an instance of the specified type. Will cache and manage instances already instantiated.
        /// </summary>
        public IFlow Request(Type instanceType, Multiplicity multiplicity, Permanence permanence)
        {
            //We only want to allow a single instance of the type, so just get one if there's already one created.
            //Unfortunately, this will not respect the flow's "busy" state. Hey -- don't look at me like that. That's what you get for using singletons.
            if (multiplicity == Multiplicity.Singleton && MaybeGetFirstInstance(instanceType, out var instance))
            {
                return(instance);
            }

            //Otherwise, try to get the first non-busy instance of the type
            if (MaybeGetFirstNonBusyInstance(instanceType, out instance))
            {
                return(instance);
            }

            //Else we have to create a new one
            instance = (IFlow)Activator.CreateInstance(instanceType);
            instance.Initialize(Guid.NewGuid(), _ResolverCache);

            //The stuff here is just bookkeeping, so no need to hold up the requesting thread.
            Task.Run(() =>
            {
                //First, clear any instances that have expired.
                //Of course, they might expire at any point -- this is just to keep space down.
                ClearExpiredInstances(instanceType);

                //Either hold on to the object ourselves, or only keep a weak reference, depending on the flow metadata
                Func <IFlow> accessor;
                if (permanence == Permanence.Keep)
                {
                    accessor = () => instance;
                }
                else
                {
                    //Closures are AWESOME.
                    var weakReference = new WeakReference <IFlow>(instance);
                    accessor          = () =>
                    {
                        weakReference.TryGetTarget(out var maybeInstance);
                        return(maybeInstance);
                    };
                }
                CacheAdd(instanceType, accessor);
            });

            return(instance);
        }
예제 #37
0
        public static string Display(this Multiplicity value)
        {
            switch (value)
            {
            case Multiplicity.One:
                return("1");

            case Multiplicity.ZeroOne:
                return("0..1");

            case Multiplicity.ZeroMany:
                return("0..*");

            default:
                return(string.Empty);
            }
        }
예제 #38
0
        private static bool GetMultiplicity(Multiplicity kind, bool isCollection)
        {
            switch (kind)
            {
            case Multiplicity.Auto:
                return(isCollection);

            case Multiplicity.Multiple:
                return(true);

            case Multiplicity.Single:
                return(false);

            default:
                throw new ArgumentOutOfRangeException(nameof(kind), kind, null);
            }
        }
예제 #39
0
        private string GetMultiplicityDisplay(Multiplicity multiplicity)
        {
            switch (multiplicity)
            {
            case Multiplicity.One:
                return("1");

            case Multiplicity.ZeroOne:
                return("0..1");

            case Multiplicity.ZeroMany:
                return("*");

            default:
                throw new NotSupportedException();
            }
        }
예제 #40
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public bool Transfer(Multiplicity mup, MultiplicityResult mr, int idx)
 {
     if (mr == null)
         return true;
     bool res = true;
     try
     {
         SetQCStatus(mup, QCTestStatus.Pass);  // marked Pass at the outset
         MultiplicityCountingRes lmcs = new MultiplicityCountingRes(mup.FA, idx);
         countresults.Add(mup, lmcs);
         lmcs.Totals = Totals;
         lmcs.TransferRawResult(mr);
         lmcs.TS = new TimeSpan(TS.Ticks);
     }
     catch (OutOfMemoryException e)
     {
         mup.reason = "Multiplicity transfer " + e.Message;
         res = false;
         logger.TraceEvent(LogLevels.Error, 87406,  mup.reason);
     }
     return res;
 }
예제 #41
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public void SetQCStatus(Multiplicity key, QCTestStatus newval, double voltage = -1)
 {
     QCStatus val = new QCStatus();
     bool ok = qcstatus.TryGetValue(key, out val);
     if (!ok)
         qcstatus.Add(key, new QCStatus(newval, voltage));
     else
         qcstatus[key] = new QCStatus(newval, voltage);
 }
예제 #42
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public bool QCStatusWeaklyValidForTHisKey(Multiplicity key)
 {
     if (qcstatus.ContainsKey(key))
         return QCStatus(key).status != QCTestStatus.None;
     else
         return false;
 }
예제 #43
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public bool QCStatusValid(Multiplicity key)
 {
     if (qcstatus.ContainsKey(key))
     return QCStatus(key).status == QCTestStatus.Pass;
     else
         return false;
 }
예제 #44
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public bool QCStatusHasFlag(QCTestStatus filter, Multiplicity key)
 {
     if (qcstatus.ContainsKey(key))
     return QCStatus(key).status.HasFlag(filter);
     else
         return false;
 }
예제 #45
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public bool QCStatusHasChecksumError(Multiplicity key)
 {
     if (qcstatus.ContainsKey(key)) {
     QCTestStatus ts = QCStatus(key).status;
     return ((ts == QCTestStatus.Checksum1) || (ts == QCTestStatus.Checksum2) ||
         (ts == QCTestStatus.Checksum3)); // err yeah, guess I could use the flags and mask for true here
     } else
         return false;
 }
예제 #46
0
 protected Section ConstructReportSection(ReportSections section, Multiplicity mu, MultiplicityCountingRes mcr)
 {
     Section sec = null;
     if (!(bool)selectedReportSections.GetValue((int)section))
         return sec;
     try
     {
         switch (section)
         {
             case ReportSections.RepResults:
                 sec = new Section(typeof(RepResults), 1, 1, 1);
                 sec[1].Add(0, "Corrected rates for SR " + mu.ShortName());
                 sec.Add(GenResultsRow(mcr));
                 break;
             case ReportSections.RepDytlewskiResults:
                 sec = new Section(typeof(RepResults), 1, 1, 1);
                 sec[1].Add(0, "Dytlewski rates for SR " + mu.ShortName());
                 sec.Add(GenDytlewskiResultsRow(mcr));
                 break;
         }
     }
     catch (Exception e)
     {
         ctrllog.TraceException(e);
     }
     return sec;
 }
예제 #47
0
        /// <summary>
        ///  Create the cycle counting results, add it to the measurement and copy the data from the run to the equivalent fields on the cycle
        /// </summary>
        /// <param name="run"></param>
        /// <param name="cycle"></param>
        public static unsafe MultiplicityCountingRes RunToCycle(run_rec run, Cycle cycle, Multiplicity key)
        {
            cycle.seq = run.run_number;
            cycle.TS = new TimeSpan(0, 0, (int)run.run_count_time);  // dev note: check if this is always only in seconds, or fractions of a second

            cycle.Totals = (ulong)run.run_singles;
            cycle.SinglesRate = run.run_singles / run.run_count_time; // use this value in the conditioning steps, it is not yet the DT corrected rate

            string s = TransferUtils.str(run.run_tests, INCC.MAX_RUN_TESTS_LENGTH);
            QCTestStatus qcts = QCTestStatusExtensions.FromString(s);

            cycle.SetQCStatus(key, qcts); // creates entry if not found

            MultiplicityCountingRes mcr = new MultiplicityCountingRes(key.FA, cycle.seq);
            cycle.CountingAnalysisResults.Add(key, mcr);
            mcr.Totals = cycle.Totals;
            mcr.TS = cycle.TS;

            mcr.DeadtimeCorrectedSinglesRate.v = run.run_singles_rate; // overridden later, not used
            mcr.DeadtimeCorrectedDoublesRate.v = run.run_doubles_rate;
            mcr.DeadtimeCorrectedTriplesRate.v = run.run_triples_rate;

            mcr.RASum = (ulong)run.run_reals_plus_acc;
            mcr.ASum = (ulong)run.run_acc;

            mcr.efficiency = run.run_multiplicity_efficiency;
            mcr.mass = run.run_mass;
            mcr.multiAlpha = run.run_multiplicity_alpha;
            mcr.multiplication = run.run_multiplicity_mult;
            cycle.HighVoltage = run.run_high_voltage;

            // assign the hits to a single channel (0)
            cycle.HitsPerChannel[0] = run.run_singles;
            mcr.RawSinglesRate.v = run.run_singles_rate;
            mcr.RawDoublesRate.v = run.run_doubles_rate;
            mcr.RawTriplesRate.v = run.run_triples_rate;

            mcr.Scaler1.v = run.run_scaler1;
            mcr.Scaler2.v = run.run_scaler2;
            mcr.Scaler1Rate.v = run.run_scaler1_rate;
            mcr.Scaler2Rate.v = run.run_scaler2_rate;

            mcr.RAMult = TransferUtils.multarrayxfer(run.run_mult_reals_plus_acc, INCC.MULTI_ARRAY_SIZE);
            mcr.NormedAMult = TransferUtils.multarrayxfer(run.run_mult_acc, INCC.MULTI_ARRAY_SIZE);
            mcr.MaxBins = (ulong)Math.Max(mcr.RAMult.Length, mcr.NormedAMult.Length);
            mcr.MinBins = (ulong)Math.Min(mcr.RAMult.Length, mcr.NormedAMult.Length);
            mcr.UnAMult = new ulong[mcr.MaxBins]; // todo: compute this
            return mcr;
        }
        public static CreatePropertyCommand Evaluate(IEngine engine, Command command)
        {
            if (command.Parameters.Count < 3)
                return null;

            if (command.Parameters[0].Name.ToLower() != "create")
                return null;
            if (command.Parameters[0].Value != null)
                return null;

            Multiplicity multiplicity = Multiplicity.None;

            switch (command.Parameters[1].Name.ToLower())
            {
                case "property":
                case "relationship":
                    break;
                case "one-one":
                case "oneone":
                case "one-to-one":
                case "onetoone":
                    multiplicity = Multiplicity.OneToOne;
                    break;
                case "one-many":
                case "onemany":
                case "one-to-many":
                case "onetomany":
                case "reference":
                    multiplicity = Multiplicity.OneToMany;
                    break;
                case "many-one":
                case "manyone":
                case "many-to-one":
                case "manytoone":
                case "list":
                    multiplicity = Multiplicity.ManyToOne;
                    break;
                case "many-many":
                case "manymany":
                case "many-to-many":
                case "manytomany":
                    multiplicity = Multiplicity.ManyToMany;
                    break;
                default:
                    return null;
            }
            if (command.Parameters[1].Value != null)
                return null;

            string name = command.Parameters[2].Name;
            if (string.IsNullOrEmpty(name))
                return null;  // register exception...

            string[] parts = name.Split(".".ToCharArray());
            if (parts.Length != 2)
                return null;  // register exception...

            string className = parts[0];
            string propertyName = parts[1];

            if (string.IsNullOrEmpty(className))
                return null;  // register exception...

            if (string.IsNullOrEmpty(propertyName))
                return null;  // register exception...

            ISchemaService schemaService = engine.GetService<ISchemaService>();
            IObjectService objectService = engine.GetService<IObjectService>();

            CreatePropertyCommand createPropertyCommand = new CreatePropertyCommand(className, propertyName);
            createPropertyCommand.Multiplicity = multiplicity;
            createPropertyCommand.Type = typeof(string);
            createPropertyCommand.StringLength = 255;

            bool list = false;

            IList<Parameter> parameters = command.Parameters[2].Value as IList<Parameter>;
            if (parameters != null)
            {
                foreach (Parameter parameter in parameters)
                {
                    if (parameter.Value != null)
                    {
                        switch (parameter.Name.ToLower())
                        {
                            case "type":
                                if (schemaService.HasClass(parameter.Value.ToString()))
                                    createPropertyCommand.Type = objectService.GetTypeByName(parameter.Value.ToString());
                                else
                                    createPropertyCommand.Type = Type.GetType(parameter.Value.ToString());
                                break;
                            case "list":
                                list = true;
                                break;
                            case "multiplicity":
                            case "ref":
                            case "reference":
                            case "referencetype":
                                if (createPropertyCommand.Multiplicity == Multiplicity.None)
                                {
                                    string refType = parameter.Value.ToString();
                                    switch (refType.ToLower())
                                    {
                                        case "one-one":
                                        case "oneone":
                                        case "one-to-one":
                                        case "onetoone":
                                            createPropertyCommand.Multiplicity = Multiplicity.OneToOne;
                                            break;
                                        case "one-many":
                                        case "onemany":
                                        case "one-to-many":
                                        case "onetomany":
                                            createPropertyCommand.Multiplicity = Multiplicity.OneToMany;
                                            break;
                                        case "many-one":
                                        case "manyone":
                                        case "many-to-one":
                                        case "manytoone":
                                            createPropertyCommand.Multiplicity = Multiplicity.ManyToOne;
                                            break;
                                        case "many-many":
                                        case "manymany":
                                        case "many-to-many":
                                        case "manytomany":
                                            createPropertyCommand.Multiplicity = Multiplicity.ManyToMany;
                                            break;
                                        default:
                                            createPropertyCommand.Multiplicity = Multiplicity.None;
                                            break;
                                    }
                                }
                                list = true;
                                break;
                            case "length":
                                createPropertyCommand.StringLength = Convert.ToInt32(parameter.Value.ToString());
                                break;
                            case "column":
                            case "columnname":
                                createPropertyCommand.ColumnName = parameter.Value.ToString();
                                break;
                            case "null":
                            case "nullable":
                                createPropertyCommand.Nullable = Convert.ToBoolean(parameter.Value.ToString());
                                break;
                            case "inverse":
                                createPropertyCommand.Inverse = parameter.Value.ToString();
                                break;
                        }
                    }
                }
            }

            if (createPropertyCommand.Multiplicity == Multiplicity.None)
            {
                if (schemaService.HasClass(objectService.GetTypeName(createPropertyCommand.Type)))
                {
                    if (list)
                        createPropertyCommand.Multiplicity = Multiplicity.ManyToOne;
                    else
                        createPropertyCommand.Multiplicity = Multiplicity.OneToMany;
                }
            }

            if (createPropertyCommand.Multiplicity != Multiplicity.None)
            {
                if (string.IsNullOrEmpty(createPropertyCommand.Inverse))
                    createPropertyCommand.Inverse = "InverseOf" + name;
            }

            return createPropertyCommand;
        }
예제 #49
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
        /// <summary>
        /// Create parameter list for the results on a cycle
        /// </summary>
        /// <param name="mkey">The multiplicity parameters used to select the specific results. There can be more than one such results set per cycle.</param>
        public void GenParamList(Multiplicity mkey)
        {
            GenParamList(); // ^ does the basic INCC5 and new LM cycle stuff

            // now add the mkey stuff
            Table = "cycles";
            MultiplicityCountingRes pmcr = null;
            QCTestStatus status = QCTestStatus.None;
            if (CountingAnalysisResults.HasMultiplicity)
                try
                {
                    pmcr = (MultiplicityCountingRes)CountingAnalysisResults[mkey];
                    status = qcstatus[mkey].status;
                }
                catch (Exception) // mkey not found happens when a param is changed on a VSR that is not reflected back to the default [0] SR
                {
                    logger.TraceEvent(LogLevels.Warning, 7832, "Cycle status not set in DB, mkey mismatch: " + mkey.ToString());
                }
            if (pmcr == null)
                pmcr = new MultiplicityCountingRes();  // null results
            ps.Add(new DBParamEntry("scaler1", pmcr.Scaler1.v));
            ps.Add(new DBParamEntry("scaler2", pmcr.Scaler2.v));
            ps.Add(new DBParamEntry("reals_plus_acc", pmcr.RASum));
            ps.Add(new DBParamEntry("acc", pmcr.ASum));
            ps.Add(new DBParamEntry("mult_reals_plus_acc", pmcr.RAMult));
            ps.Add(new DBParamEntry("mult_acc", pmcr.NormedAMult));
            ps.Add(new DBParamEntry("scaler1_rate", pmcr.Scaler1Rate.v));
            ps.Add(new DBParamEntry("scaler2_rate", pmcr.Scaler2Rate.v));
            ps.Add(new DBParamEntry("doubles_rate", pmcr.RawDoublesRate.v));
            ps.Add(new DBParamEntry("triples_rate", pmcr.RawTriplesRate.v));
            ps.Add(new DBParamEntry("multiplicity_mult", pmcr.multiplication));
            ps.Add(new DBParamEntry("multiplicity_alpha", pmcr.multiAlpha));
            ps.Add(new DBParamEntry("multiplicity_efficiency", pmcr.efficiency));
            ps.Add(new DBParamEntry("mass", pmcr.mass));
            ps.Add(new DBParamEntry("status", (int)status));
            {	// la super hack-a-whack
                DB.DB db = new DB.DB(true);
                if (db.TableHasColumn(Table,"mult_acc_un"))
                    ps.Add(new DBParamEntry("mult_acc_un", pmcr.UnAMult));
            }
        }
예제 #50
0
 void ExpandMaxBins(ulong _MaxBins, CycleList cl, Multiplicity key)
 {
     foreach(Cycle c in cl)
     {
         MultiplicityCountingRes cmcr = (MultiplicityCountingRes)c.CountingAnalysisResults[key];
         if (_MaxBins > (ulong)cmcr.RAMult.Length || _MaxBins > (ulong)cmcr.NormedAMult.Length)
             Bloat(_MaxBins, cmcr);
     }
 }
예제 #51
0
        void PlotThePlots(CycleList cl, Multiplicity mkey)
        {
            Series s1 = Singles.Series["Vals"];
            s1.MarkerStyle = MarkerStyle.Circle;
            s1.MarkerColor = System.Drawing.Color.SkyBlue;
            s1.MarkerSize = 5;
            s1.MarkerBorderColor = System.Drawing.Color.DarkCyan;
            s1.Color = System.Drawing.Color.MediumPurple;

            Series s2 = Doubles.Series["Vals"];
            s2.MarkerStyle = MarkerStyle.Circle;
            s2.MarkerColor = System.Drawing.Color.SkyBlue;
            s2.MarkerSize = 5;
            s2.MarkerBorderColor = System.Drawing.Color.DarkCyan;
            s2.Color = System.Drawing.Color.MediumPurple;

            Series s3 = Triples.Series["Vals"];
            s3.MarkerStyle = MarkerStyle.Circle;
            s3.MarkerColor = System.Drawing.Color.SkyBlue;
            s3.MarkerSize = 5;
            s3.MarkerBorderColor = System.Drawing.Color.DarkCyan;
            s3.Color = System.Drawing.Color.MediumPurple;

            int i = 0;
            foreach (Cycle c in cl)
            {
                i++;
                MultiplicityCountingRes mcr = c.MultiplicityResults(mkey);
                bool somtingfunnyhere = (c.QCStatus(mkey).status != QCTestStatus.Pass);

                int idx = s1.Points.AddXY(i, mcr.DeadtimeCorrectedSinglesRate.v);  // next: vary color and shape based on cycle status/outlier status
                s2.Points.AddXY(i, mcr.DeadtimeCorrectedDoublesRate.v);
                s3.Points.AddXY(i, mcr.DeadtimeCorrectedTriplesRate.v);
                if (somtingfunnyhere)
                {
                    s1.Points[idx].MarkerColor = System.Drawing.Color.Orchid;
                    s2.Points[idx].MarkerColor = System.Drawing.Color.Orchid;
                    s3.Points[idx].MarkerColor = System.Drawing.Color.Orchid;
                    s1.Points[idx].ToolTip = string.Format("#{0} {1}", c.seq, c.QCStatus(mkey).INCCString());
                    s3.Points[idx].ToolTip = s2.Points[idx].ToolTip = s1.Points[idx].ToolTip;
                }

            }
        }
예제 #52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImportColumnType"/> class.
 /// </summary>
 /// <param name="displayName">The display name.</param>
 /// <param name="type">The type.</param>
 /// <param name="multiplicity">The multiplicity.</param>
 public ImportColumnType(string displayName, DataCategory type, Multiplicity multiplicity)
 {
     DisplayName = displayName;
     Type = type;
     Multiplicity = multiplicity;
 }
예제 #53
0
 internal static unsafe run_rec MoveCycleToRunRec(Cycle c, Multiplicity mkey)
 {
     run_rec res = new run_rec();
     res.run_number = (ushort)c.seq;
     byte[] b = StringSquish(c.DataSourceId.dt.ToString("yy.MM.dd"), INCC.DATE_TIME_LENGTH);
     TransferUtils.Copy(b, res.run_date);
     b = StringSquish(c.DataSourceId.dt.ToString("HH:mm:ss"), INCC.DATE_TIME_LENGTH);
     TransferUtils.Copy(b, res.run_time);
     QCStatus qc = c.QCStatus(mkey);
     b = StringSquish(QCTestStatusExtensions.INCCString(qc), INCC.MAX_RUN_TESTS_LENGTH);
     TransferUtils.Copy(b, res.run_tests);
     res.run_count_time = c.TS.TotalSeconds;
     res.run_singles = c.Totals; // raw counts
     MultiplicityCountingRes mcr = c.MultiplicityResults(mkey);
     res.run_scaler1 = mcr.Scaler1.v;
     res.run_scaler2 = mcr.Scaler2.v;
     res.run_reals_plus_acc = mcr.RASum;
     res.run_acc = mcr.ASum;
     TransferUtils.CopyULongsToDbls(mcr.RAMult, res.run_mult_reals_plus_acc);
     TransferUtils.CopyULongsToDbls(mcr.NormedAMult, res.run_mult_acc);
     res.run_singles_rate = mcr.DeadtimeCorrectedSinglesRate.v; // correct counts or not?
     res.run_doubles_rate = mcr.DeadtimeCorrectedDoublesRate.v;
     res.run_triples_rate = mcr.DeadtimeCorrectedTriplesRate.v;
     res.run_scaler1_rate = mcr.Scaler1Rate.v;
     res.run_scaler2_rate = mcr.Scaler2Rate.v;
     res.run_multiplicity_mult = mcr.multiplication;
     res.run_multiplicity_alpha = mcr.multiAlpha;
     res.run_multiplicity_efficiency = mcr.efficiency;
     res.run_mass = mcr.Mass;
     res.run_high_voltage = c.HighVoltage;
     return res;
 }
예제 #54
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public QCStatus QCStatus(Multiplicity key)
 {
     QCStatus val = new QCStatus();
     bool ok = qcstatus.TryGetValue(key, out val);
     return val;
 }
예제 #55
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public bool HasEntry(Multiplicity key)
 {
     QCStatus val = null;
     bool ok = qcstatus.TryGetValue(key, out val);
     return ok;
 }
예제 #56
0
 public ResourceAssociations FindAssociationsOfMultiplicity(Multiplicity resourceTypeEndMul, Multiplicity otherEndMul)
 {
     ResourceAssociations associationsFoundWithMul = new ResourceAssociations();
     foreach (ResourceProperty prop in this.Properties.OfType<ResourceProperty>().Where(p => p.IsNavigation == true && p.Name != null))
     {
         if (prop.AssociationEnd.Multiplicity == resourceTypeEndMul && prop.OtherAssociationEnd.Multiplicity == otherEndMul)
         {
             associationsFoundWithMul.Add(prop.ResourceAssociation);
         }
     }
     return associationsFoundWithMul;
 }
예제 #57
0
파일: Cycle.cs 프로젝트: hnordquist/INCC6
 public MultiplicityCountingRes MultiplicityResults(Multiplicity pk)
 {
     if (CountingAnalysisResults.ContainsKey(pk))
         return (MultiplicityCountingRes)CountingAnalysisResults[pk];
     else
         return null;
 }
예제 #58
0
        public unsafe void BuildDetector(INCCInitialDataDetectorFile iddf, int num)
        {
            INCCDB DB = NC.App.DB;

            detector_rec d = iddf.Detector[0];
            sr_parms_rec sr = iddf.SRParms[0];
            bkg_parms_rec bkh = iddf.BKGParms[0];
            norm_parms_rec norm = iddf.NormParms[0];
            tm_bkg_parms_rec tmbkg = iddf.TMBKGParms[0];
            add_a_source_setup_rec aass = iddf.AASParms[0];

            InstrType srtype = (InstrType)sr.sr_type;

            bool overwrite = NC.App.AppContext.OverwriteImportedDefs;

            mlogger.TraceEvent(LogLevels.Verbose, 34100, "Building '{0}' detector '{1}' from {2} {3}",
                                srtype.ToString(),
                                TransferUtils.str(d.detector_id, INCC.MAX_DETECTOR_ID_LENGTH),
                                num, iddf.Path);

            // if the detector is not known internally, then
            //        add the detector to the list of detectors in memory, and
            //        associate a new set of SR, Bkg and Norm and AB params with the new detector
            // todo: What are the HV Params from INCC5, and once that is known, can they be transferred to the INCC6 HV Param and results tables
            Detector det = new Detector();
            if (srtype.IsListMode())
                det.Id.FullConnInfo = new LMConnectionInfo();

            try
            {
                // this transfer should be a method in this class, it will be used elsewhere too
                det.Id.DetectorId = TransferUtils.str(d.detector_id, INCC.MAX_DETECTOR_ID_LENGTH);
                det.Id.SRType = srtype;
                det.Id.Type = TransferUtils.str(d.detector_type, INCC.DETECTOR_TYPE_LENGTH);
                det.Id.ElectronicsId = TransferUtils.str(d.electronics_id, INCC.ELECTRONICS_ID_LENGTH);
                det.Id.ConnInfo = sr.sr_port_number.ToString();
                det.Id.source = ConstructedSource.INCCTransferCopy;
                det.MultiplicityParams.FA = srtype.DefaultFAFor();
                det.MultiplicityParams.gateWidthTics = (ulong)(sr.gate_length * 10.0);  // shift down to tics from microseconds
                det.SRParams.deadTimeCoefficientAinMicroSecs = sr.coeff_a_deadtime;
                det.SRParams.deadTimeCoefficientBinPicoSecs = sr.coeff_b_deadtime;
                det.SRParams.deadTimeCoefficientCinNanoSecs = sr.coeff_c_deadtime;
                det.SRParams.deadTimeCoefficientMultiplicityinNanoSecs = sr.multiplicity_deadtime;
                det.SRParams.dieAwayTime = sr.die_away_time * 10.0;  // shift down to tics from microseconds
                det.SRParams.doublesGateFraction = sr.doubles_gate_fraction;
                det.SRParams.efficiency = sr.efficiency;
                det.SRParams.gateLength = (ulong)(sr.gate_length * 10.0);  // shift down to tics from microseconds
                //det.SRParams.gateLength2 = sr.gate_length2;
                det.SRParams.highVoltage = sr.high_voltage;
                det.SRParams.predelay = (ulong)(sr.predelay * 10.0);  // shift down to tics from microseconds
                det.SRParams.triplesGateFraction = sr.triples_gate_fraction;
                //    = sr.sr_type , sr.sr_port_number, sr.sr_detector_id  these are in the Id now, not the SRparams, but they travel together.

                if (NC.App.AppContext.OverwriteImportedDefs)
                    DB.Detectors.Replace(det);
                else
                    DB.Detectors.AddOnlyIfNotThere(det);
                DetectorIndex = DB.Detectors.Count - 1;

                BackgroundParameters bkg = new BackgroundParameters();
                bkg.DeadtimeCorrectedRates.Singles.v = bkh.curr_passive_bkg_singles_rate;
                bkg.DeadtimeCorrectedRates.Doubles.v = bkh.curr_passive_bkg_doubles_rate;
                bkg.DeadtimeCorrectedRates.Triples.v = bkh.curr_passive_bkg_triples_rate;
                bkg.DeadtimeCorrectedRates.Singles.err = bkh.curr_passive_bkg_singles_err;
                bkg.DeadtimeCorrectedRates.Doubles.err = bkh.curr_passive_bkg_doubles_err;
                bkg.DeadtimeCorrectedRates.Triples.err = bkh.curr_passive_bkg_triples_err;
                bkg.Scaler1.v = bkh.curr_passive_bkg_scaler1_rate;
                bkg.Scaler2.v = bkh.curr_passive_bkg_scaler2_rate;
                bkg.INCCActive.Singles.v = bkh.curr_active_bkg_singles_rate;
                bkg.INCCActive.Singles.err = bkh.curr_active_bkg_singles_err;
                bkg.INCCActive.Scaler1Rate = bkh.curr_active_bkg_scaler1_rate;
                bkg.INCCActive.Scaler2Rate = bkh.curr_active_bkg_scaler2_rate;
                bkg.TMBkgParams.Singles.v = tmbkg.tm_singles_bkg;
                bkg.TMBkgParams.Ones.v = tmbkg.tm_ones_bkg;
                bkg.TMBkgParams.Twos.v = tmbkg.tm_twos_bkg;
                bkg.TMBkgParams.Zeros.v = tmbkg.tm_zeros_bkg;
                bkg.TMBkgParams.Singles.err = tmbkg.tm_singles_bkg_err;
                bkg.TMBkgParams.Ones.err = tmbkg.tm_ones_bkg_err;
                bkg.TMBkgParams.Twos.err = tmbkg.tm_twos_bkg_err;
                bkg.TMBkgParams.Zeros.err = tmbkg.tm_zeros_bkg_err;
                bkg.TMBkgParams.ComputeTMBkg = (tmbkg.tm_bkg == 0 ? false : true);

                if (DB.BackgroundParameters.Get(det.Id.DetectorName) == null)
                {
                    DB.BackgroundParameters.GetMap().Add(det, bkg); // saved to DB at below
                }
                else if (overwrite)
                {
                    bkg.modified = true;
                    NC.App.DB.BackgroundParameters.GetMap().Remove(det);
                    NC.App.DB.BackgroundParameters.GetMap().Add(det, bkg);
                    NC.App.DB.BackgroundParameters.Set(det, bkg);
                }

                // save the params listed here using the detector as the key
                NormParameters normp = new NormParameters();
                normp.acceptanceLimitPercent = norm.acceptance_limit_percent;
                normp.acceptanceLimitStdDev = norm.acceptance_limit_std_dev;
                normp.amliRefSinglesRate = norm.amli_ref_singles_rate;
                normp.biasMode = OldToNewBiasTestId(norm.bias_mode);
                normp.biasPrecisionLimit = norm.bias_precision_limit;
                normp.biasTestAddasrcPosition = norm.bias_test_addasrc_position;
                normp.biasTestUseAddasrc = (norm.bias_test_use_addasrc == 0 ? false : true);
                normp.cf252RefDoublesRate.v = norm.cf252_ref_doubles_rate;
                normp.currNormalizationConstant.v = norm.curr_normalization_constant;
                normp.currNormalizationConstant.err = norm.curr_normalization_constant_err;
                normp.initSrcPrecisionLimit = norm.init_src_precision_limit;
                normp.measRate.v = norm.meas_rate;
                normp.measRate.err = norm.meas_rate_err;
                normp.refDate = INCC.DateFrom(TransferUtils.str(norm.ref_date, INCC.DATE_TIME_LENGTH));
                normp.sourceId = TransferUtils.str(norm.source_id, INCC.SOURCE_ID_LENGTH);
                normp.yieldRelativeToMrc95 = norm.yield_relative_to_mrc_95;

                if (DB.NormParameters.Get(det.Id.DetectorName) == null)
                {
                    DB.NormParameters.GetMap().Add(det, normp); // saved to DB at end
                }
                else if (overwrite)
                {
                    normp.modified = true;
                    DB.NormParameters.GetMap().Remove(det);
                    DB.NormParameters.GetMap().Add(det, normp); // the in-memory map
                    DB.NormParameters.Set(det, normp);  // the DB table
                }
                AddASourceSetup aassp = new AddASourceSetup();
                aassp.type = OldToNewAASId(aass.ad_type);
                aassp.port_number = aass.ad_port_number;
                aassp.forward_over_travel = aass.ad_forward_over_travel;
                aassp.reverse_over_travel = aass.ad_reverse_over_travel;
                aassp.number_positions = aass.ad_number_positions;
                aassp.dist_to_move = TransferUtils.Copy(aass.ad_dist_to_move, INCC.MAX_ADDASRC_POSITIONS);
                aassp.cm_steps_per_inch = aass.cm_steps_per_inch;
                aassp.cm_forward_mask = aass.cm_forward_mask;
                aassp.cm_reverse_mask = aass.cm_reverse_mask;
                aassp.cm_axis_number = aass.cm_axis_number;
                aassp.cm_over_travel_state = aass.cm_over_travel_state;
                aassp.cm_step_ratio = aass.cm_step_ratio;
                aassp.cm_slow_inches = aass.cm_slow_inches;
                aassp.plc_steps_per_inch = aass.plc_steps_per_inch;
                aassp.scale_conversion_factor = aass.scale_conversion_factor;
                aassp.cm_rotation = (aass.cm_rotation == 0 ? false : true);

                if (!DB.AASSParameters.GetMap().ContainsKey(det))
                {
                    DB.AASSParameters.GetMap().Add(det, aassp);
                }
                else if (overwrite)
                {
                    aassp.modified = true;
                    DB.AASSParameters.GetMap().Remove(det);
                    DB.AASSParameters.GetMap().Add(det, aassp); // todo: in-memory and db
                }
                if (!DB.UnattendedParameters.GetMap().ContainsKey(det))
                {
                    DB.UnattendedParameters.GetMap().Add(det, new UnattendedParameters());
                }
                else if (overwrite)
                {
                    DB.UnattendedParameters.GetMap().Remove(det);
                    DB.UnattendedParameters.GetMap().Add(det, new UnattendedParameters());
                }

                // the alpha beta arrays must be sized here, for first use by the calc_alpha_beta code in the cycle conditioning code
                Multiplicity mkey = new Multiplicity(srtype.DefaultFAFor());
                mkey.SR = new ShiftRegisterParameters(det.SRParams);
                MultiplicityCountingRes mcr = new MultiplicityCountingRes(srtype.DefaultFAFor(), 0);
                ABKey abkey = new ABKey(mkey, 512); // NEXT: maxbins is arbitrary
                LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(abkey, det.AB);
                mcr.AB.TransferIntermediates(det.AB);
            }
            catch (Exception e)
            {
                mlogger.TraceEvent(LogLevels.Warning, 34064, "Detector transfer processing error {0} {1} ({2})", det.Id.DetectorName, e.Message, System.IO.Path.GetFileName(iddf.Path));
            }
        }
예제 #59
0
 protected void ConstructSRSection(INCCStyleSection sec, Multiplicity mu, Detector det)
 {
     // if this is based on a virtual SR then show it
     if (det.Id.source.UsingVirtualSRCounting(det.Id.SRType))
         sec.AddTwo(" Virtual shift register:", mu.ToString());
     sec.AddTwo("Predelay:", mu.SR.predelayMS);
     sec.AddTwo("Gate length:", mu.SR.gateLengthMS);
     if (det.Id.SRType == InstrType.DGSR)
         sec.AddTwo("Gate length2:", mu.SR.gateLengthMS); 
     sec.AddIntegerRow("High voltage:", (Int32)mu.SR.highVoltage);
     sec.SetFPCurrentFormatPrecision(4);
     sec.AddTwo("Die away time:", mu.SR.dieAwayTimeMS);
     sec.AddTwo("Efficiency:", mu.SR.efficiency);
     sec.AddTwo("Multiplicity deadtime:", mu.SR.deadTimeCoefficientMultiplicityinNanoSecs);
     sec.AddTwo("Coefficient A deadtime:", mu.SR.deadTimeCoefficientAinMicroSecs);
     sec.AddTwo("Coefficient B deadtime:", mu.SR.deadTimeCoefficientBinPicoSecs);
     sec.AddTwo("Coefficient C deadtime:", mu.SR.deadTimeCoefficientCinNanoSecs);
     sec.AddTwo("Doubles gate fraction:", mu.SR.doublesGateFraction);
     sec.AddTwo("Triples gate fraction:", mu.SR.triplesGateFraction);
 }
예제 #60
0
        Row GenDetectorCalibrationRow(Detector det, Multiplicity mkey = null)
        {
            Row row = new Row();
            ShiftRegisterParameters sr = (mkey == null ? det.SRParams : mkey.SR);
            row.Add((int)DetectorCalibration.DetectorType, det.Id.SRType.ToString());
            row.Add((int)DetectorCalibration.DetectorId, det.Id.DetectorId);
            row.Add((int)DetectorCalibration.ElectronicsId, det.Id.ElectronicsId);
            if (mkey != null)
            {
                row.Add((int)DetectorCalibration.Predelay, (sr.predelay * 1e-1).ToString());
                row.Add((int)DetectorCalibration.GateLength, (sr.gateLength * 1e-1).ToString());
                row.Add((int)DetectorCalibration.HighVoltage, sr.highVoltage.ToString());
                row.Add((int)DetectorCalibration.DieAwayTime, (sr.dieAwayTime * 1e-1).ToString());
                row.Add((int)DetectorCalibration.Efficiency, sr.efficiency.ToString());
                row.Add((int)DetectorCalibration.DTCoeffT, (sr.deadTimeCoefficientTinNanoSecs).ToString());
                row.Add((int)DetectorCalibration.DTCoeffA, (sr.deadTimeCoefficientAinMicroSecs).ToString());
                row.Add((int)DetectorCalibration.DTCoeffB, (sr.deadTimeCoefficientBinPicoSecs).ToString());
                row.Add((int)DetectorCalibration.DTCoeffC, (sr.deadTimeCoefficientCinNanoSecs).ToString());
                row.Add((int)DetectorCalibration.DoublesGateFraction, sr.doublesGateFraction.ToString());
                row.Add((int)DetectorCalibration.TriplesGateFraction, sr.triplesGateFraction.ToString());

                if (det.Id.SRType.IsListMode()) // Only add long delay for LM instruments hn 9.21.2015
                {
                    row.Add((int)DetectorCalibration.FA, mkey.FA.ToString());
                    row.Add((int)DetectorCalibration.LongDelay, (mkey.FA == FAType.FAOn ? mkey.BackgroundGateTimeStepInTics * 1e-1 : mkey.AccidentalsGateDelayInTics * 1e-1).ToString());
                }
                else
                {
                    row.Add((int)DetectorCalibration.FA, "N/A");
                    row.Add((int)DetectorCalibration.LongDelay, "N/A");
                }
                row.Add((int)DetectorCalibration.Status, (mkey.suspect ? "Unusable because " + mkey.reason : "OK"));
            }
            return row;
        }