private void CaptureRefState(Reference reference) { var fullName = reference.FullName; var refState = new ReferenceState(reference.Type, fullName, reference.Name, reference.Pointer.Dereference().Hash); _states[fullName] = refState; }
public void Set(ActionType actionType, string collection, Reference reference, string itemId, long lastIndexedParentEtag, TransactionOperationContext indexContext) { var dictionary = GetDictionary(actionType); var referencedItemId = (string)reference.Key; var referenceEtag = reference.Etag; indexContext.Transaction.InnerTransaction.LowLevelTransaction.AfterCommitWhenNewReadTransactionsPrevented += _ => { // we update this only after the transaction was committed dictionary[collection] = new ReferenceState(referencedItemId, referenceEtag, itemId, lastIndexedParentEtag); #if DEBUG if (_setCollections.Add((actionType, collection)) == false) { throw new InvalidOperationException($"Double set of collection {collection} of action type {actionType}"); } #endif }; #if DEBUG indexContext.Transaction.InnerTransaction.LowLevelTransaction.OnDispose += _ => { _setCollections.Remove((actionType, collection)); }; #endif }
public override void OnNodeLayout( DrawInfo drawInfo ) { base.OnNodeLayout( drawInfo ): if( m_drawPreview ) { m_iconPos = m_globalPosition: m_iconPos.width = 19 * drawInfo.InvertedZoom: m_iconPos.height = 19 * drawInfo.InvertedZoom: m_iconPos.y += 10 * drawInfo.InvertedZoom: m_iconPos.x += m_globalPosition.width - m_iconPos.width - 5 * drawInfo.InvertedZoom: } bool instanced = CheckReference(): if( instanced ) { m_state = ReferenceState.Instance: m_previewTextProp = m_referenceSampler: } else if( m_texPort.IsConnected ) { m_state = ReferenceState.Connected: m_previewTextProp = m_texPort.GetOutputNode( 0 ) as ParentNode: } else { m_state = ReferenceState.Self: m_previewTextProp = this: } if( m_previewTextProp == null ) m_previewTextProp = this: }
/// <summary> /// Transforms the term. /// </summary> /// <param name="term">Term.</param> /// <returns>Transformed term.</returns> public ITerm Visit(ObjectFunctionTerm term) { if (ReferenceState != null) { IAtom groundedFunctionAtom = GroundAtomDeep(term.FunctionAtom, Substitution, ReferenceState); return(new ConstantTerm(ReferenceState.GetObjectFunctionValue(groundedFunctionAtom), IdManager)); } return(new ObjectFunctionTerm(GroundAtom(term.FunctionAtom, Substitution), IdManager)); }
/// <summary> /// Visits expression term. /// </summary> /// <param name="term">Expression term.</param> public void PostVisit(ObjectFunctionTerm term) { List <int> argumentsList = new List <int>(); for (int i = 0; i < term.Terms.Count; ++i) { argumentsList.Add(TermStack.Pop()); } argumentsList.Reverse(); IGroundedAtom groundedFunctionAtom = new GroundedAtom(term.NameID, argumentsList); int groundedConstantValue = ReferenceState.GetObjectFunctionValue(groundedFunctionAtom); TermStack.Push(groundedConstantValue); }
/// <summary> /// Checks the equality of objects. /// </summary> /// <param name="obj">Object to be checked.</param> /// <returns>True if the objects are equal, false otherwise.</returns> public override bool Equals(object obj) { if (obj == this) { return(true); } Successor other = obj as Successor; if (other == null) { return(false); } return(ReferenceState.Equals(other.ReferenceState) && AppliedOperator.Equals(other.AppliedOperator)); }
/// <summary> /// Evaluates the expression. /// </summary> /// <param name="expression">Expression.</param> /// <returns>True if the expression is logically true, false otherwise.</returns> public override bool Visit(PredicateLiteralCNF expression) { IAtom groundedPredicateAtom = GroundingManager.GroundAtomDeep(expression.PredicateAtom, Substitution, ReferenceState); if (RigidRelations.Contains(groundedPredicateAtom)) { // satisfied or failed by rigid relation return(!expression.IsNegated); } bool hasPredicate = ReferenceState.HasPredicate(groundedPredicateAtom); if (hasPredicate == expression.IsNegated) { // failed by state predicate return(false); } // satisfied by state predicate -> store this atom Atoms.Add(groundedPredicateAtom); return(true); }
/// <summary> /// Constructor /// </summary> /// <param name="refrigerantCategory">PureFluid, PredefinedMixture, NewMixture, PseudoPureFluid</param> /// <param name="refrigerantName">e.g. : R22,or R410A,or "R22=0.5,R134a=0.5"(0.5 is the mole composition</param> public Refrigerant(RefrigerantCategory refrigerantCategory, string refrigerantName,ReferenceState reference) { //this.Category = refrigerantCategory; this.Name = refrigerantName; if (refrigerantCategory == RefrigerantCategory.PureFluid) { base.LoadFluid(Name + ".fld", 1, new double[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },reference.ToString()); } else if (refrigerantCategory == RefrigerantCategory.PredefinedMixture) { base.LoadPredefinedFluid(Name + ".mix",reference.ToString()); } else if (refrigerantCategory == RefrigerantCategory.NewMixture) { string[] a = refrigerantName.Split(','); double[] b = new double[20]; string c = ""; for (int i = 0; i < a.Length; i++) { c += a[i].Split('=')[0]; b[i] = Convert.ToDouble((a[i].Split('='))[1]); c += ".fld|"; } base.LoadFluid(c, a.Length, b,reference.ToString()); } else { } if (NumberOfComponents < 1) throw new Exception("Number of Components is less than 1"); components = new Comonent[NumberOfComponents]; for (int i = 0; i < NumberOfComponents; i++) { double wm = 0.0, ttp = 0.0, tnbp = 0.0, tc = 0.0, pc = 0.0, Dc = 0.0, Zc = 0.0, acf = 0.0, dip = 0.0, Rgas = 0.0; base.GetComponentInfo(i + 1, ref wm, ref ttp, ref tnbp, ref tc, ref pc, ref Dc, ref Zc, ref acf, ref dip, ref Rgas); components[i] = new Comonent(); components[i].MolecularWeight = wm; components[i].TriplePointTemperature = ttp; components[i].NormalBoilingPointTemperature = tnbp; components[i].CriticalTemperature = tc; components[i].CriticalPressure = pc; components[i].CriticalDensity = Dc; components[i].Compressibility = Zc; components[i].AccentricFactor = acf; components[i].DipoleMoment = dip; components[i].GasConstant = Rgas; components[i].Mass_Fraction = MassFractions[i]; components[i].MoleFraction = MoleFractions[i]; if (NumberOfComponents == 1) components[i].Name = refrigerantName; else if(refrigerantCategory == RefrigerantCategory.PredefinedMixture) components[i].Name = base.hfiles.ToString().Split('|')[i]; else if(refrigerantCategory == RefrigerantCategory.NewMixture) components[i].Name = refrigerantName.Split(',', '=')[i * 2]; } }
//private Refrigerant(string refrigerantName) // : this(refrigerantName, ReferenceState.DEF, UnitSystems.Refprop) { } //private Refrigerant(string refrigerantName, UnitSystems currentUnits) // : this(refrigerantName, ReferenceState.DEF, currentUnits) { } public static Refrigerant GetInstance(string refrigerantName, ReferenceState? reference = ReferenceState.DEF, UnitSystems currentUnits = UnitSystems.SI) { if (_instance == null) { lock (_lockHelper) { if (_instance == null) { _instance = new Refrigerant(refrigerantName, reference, currentUnits); } } } else { _instance.Name = refrigerantName; if (reference != null) _instance.Reference = reference; _instance.CurrentUnitSystem = currentUnits; } return _instance; }
//private Refrigerant(): this("") { } /// <summary> /// Constructor: The refrigerant category can be determined by its name /// </summary> /// <param name="refrigerantName"></param> /// <param name="reference"></param> /// <param name="currentUnits"></param> private Refrigerant(string refrigerantName, ReferenceState? reference, UnitSystems currentUnits) { Load(refrigerantName, reference); initThermDynamicParameters(); this.CurrentUnitSystem = currentUnits; }
private void Load(string refrigerantName, ReferenceState? reference) { refrigerantName = CheckName(refrigerantName); if (String.IsNullOrEmpty(refrigerantName)) { currentRef = refrigerantName; return; } CheckCategory(refrigerantName); if (Category == RefrigerantCategory.PureFluid) { if (refrigerantName.EndsWith(".fld", true, null) || refrigerantName.EndsWith(".ppf", true, null)) base.LoadFluid(refrigerantName, 1, new double[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, reference.ToString(), isMassQ); else base.LoadFluid(refrigerantName + ".fld", 1, new double[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, reference.ToString(), isMassQ); } else if (Category == RefrigerantCategory.PredefinedMixture) { if (refrigerantName.EndsWith(".mix", true, null)) base.LoadPredefinedFluid(refrigerantName, reference.ToString()); else base.LoadPredefinedFluid(refrigerantName + ".mix", reference.ToString()); } else if (Category == RefrigerantCategory.NewMixture) { string[] a = refrigerantName.Split(','); double[] b = new double[20]; string c = ""; double sum = 0.0; System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo(); provider.NumberDecimalSeparator = "."; provider.NumberGroupSeparator = ","; for (int i = 0; i < a.Length; i++) { string s = " "; c += CheckName(a[i].Split('=')[0]); // s = a[i].Split('=')[1]; try { b[i] = Convert.ToDouble(s, provider); } catch (FormatException) { Console.WriteLine("Unable to convert '{0}' to a Double.", s); } catch (OverflowException) { Console.WriteLine("'{0}' is outside the range of a Double.", s); } c += ".fld|"; sum += b[i]; } for (int i = 0; i < a.Length; i++) b[i] = b[i] / sum; base.LoadFluid(c, a.Length, b, reference.ToString(), isMassQ); } else { } if (NumberOfComponents < 1) throw new Exception("Number of Components is less than 1"); components = new Comonent[NumberOfComponents]; for (int i = 0; i < NumberOfComponents; i++) { double wm = 0.0, ttp = 0.0, tnbp = 0.0, tc = 0.0, pc = 0.0, Dc = 0.0, Zc = 0.0, acf = 0.0, dip = 0.0, Rgas = 0.0; base.GetComponentInfo(i + 1, ref wm, ref ttp, ref tnbp, ref tc, ref pc, ref Dc, ref Zc, ref acf, ref dip, ref Rgas); components[i] = new Comonent(); components[i].MolecularWeight = wm; components[i].TriplePointTemperature = ttp; components[i].NormalBoilingPointTemperature = tnbp; components[i].CriticalTemperature = tc; components[i].CriticalPressure = pc; components[i].CriticalDensity = Dc; components[i].Compressibility = Zc; components[i].AccentricFactor = acf; components[i].DipoleMoment = dip; components[i].GasConstant = Rgas; components[i].MassFraction = MassFractions[i]; components[i].MoleFraction = MoleFractions[i]; if (NumberOfComponents == 1) components[i].Name = refrigerantName; else if (Category == RefrigerantCategory.PredefinedMixture) components[i].Name = base.hfiles.ToString().Split('|')[i]; else if (Category == RefrigerantCategory.NewMixture) components[i].Name = refrigerantName.Split(',', '=')[i * 2]; string temps = components[i].Name; components[i].Name = temps.Substring(temps.LastIndexOf('/') + 1).Replace(".FLD", ""); } currentRef = refrigerantName; this.name = refrigerantName; base.hrf = reference.ToString(); //好奇怪的做法啊 }
/// <summary> /// Constructor /// </summary> /// <param name="refrigerantCategory">PureFluid, PredefinedMixture, NewMixture, PseudoPureFluid</param> /// <param name="refrigerantName">e.g. : R22,or R410A,or "R22=0.5,R134a=0.5"(0.5 is the mole composition</param> public Refrigerant(RefrigerantCategory refrigerantCategory, string refrigerantName, ReferenceState reference) { //this.Category = refrigerantCategory; this.Name = refrigerantName; if (refrigerantCategory == RefrigerantCategory.PureFluid) { base.LoadFluid(Name + ".fld", 1, new double[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, reference.ToString()); } else if (refrigerantCategory == RefrigerantCategory.PredefinedMixture) { base.LoadPredefinedFluid(Name + ".mix", reference.ToString()); } else if (refrigerantCategory == RefrigerantCategory.NewMixture) { string[] a = refrigerantName.Split(','); double[] b = new double[20]; string c = ""; for (int i = 0; i < a.Length; i++) { c += a[i].Split('=')[0]; b[i] = Convert.ToDouble((a[i].Split('='))[1]); c += ".fld|"; } base.LoadFluid(c, a.Length, b, reference.ToString()); } else { } if (NumberOfComponents < 1) { throw new Exception("Number of Components is less than 1"); } components = new Comonent[NumberOfComponents]; for (int i = 0; i < NumberOfComponents; i++) { double wm = 0.0, ttp = 0.0, tnbp = 0.0, tc = 0.0, pc = 0.0, Dc = 0.0, Zc = 0.0, acf = 0.0, dip = 0.0, Rgas = 0.0; base.GetComponentInfo(i + 1, ref wm, ref ttp, ref tnbp, ref tc, ref pc, ref Dc, ref Zc, ref acf, ref dip, ref Rgas); components[i] = new Comonent(); components[i].MolecularWeight = wm; components[i].TriplePointTemperature = ttp; components[i].NormalBoilingPointTemperature = tnbp; components[i].CriticalTemperature = tc; components[i].CriticalPressure = pc; components[i].CriticalDensity = Dc; components[i].Compressibility = Zc; components[i].AccentricFactor = acf; components[i].DipoleMoment = dip; components[i].GasConstant = Rgas; components[i].Mass_Fraction = MassFractions[i]; components[i].MoleFraction = MoleFractions[i]; if (NumberOfComponents == 1) { components[i].Name = refrigerantName; } else if (refrigerantCategory == RefrigerantCategory.PredefinedMixture) { components[i].Name = base.hfiles.ToString().Split('|')[i]; } else if (refrigerantCategory == RefrigerantCategory.NewMixture) { components[i].Name = refrigerantName.Split(',', '=')[i * 2]; } } }
public override string ToString() { return($"Q:{Q} M:{Marker} ToState: {ReferenceState.ToString()}"); }