void IObjectTransformerConsumer.Add(IObjectTransformer transformer) { if (this.transformer != null) { throw new Exception(); } this.transformer = transformer; InitTransformer(); }
private void createCombo() { IObjectTransformer t = transformer.Transformer; string[] ins = t.Input; userControlComboboxList.Count = ins.Length; userControlComboboxList.Texts = ins; /* for (int i = 0; i < ins.Length; i++) * { * userControlComboboxList.Texts[i] = ins[i]; * }*/ }
/// <summary> /// Construtor from objet transformer /// </summary> /// <param name="transformer">Object transformer</param> public FiniteMatrixDerivationTransformer(IObjectTransformer transformer) { dim = IsAccessible(transformer); if (dim == null) { throw new Exception("Finite matrix is not accessible"); } matrix = new double[dim[1], dim[0]]; difference = new double[dim[0]]; state = new double[dim[0]]; output = new double[dim[1]]; this.transformer = transformer; }
/// <summary> /// Is accessible /// </summary> /// <param name="transformer">Transformer</param> /// <returns>Dimension</returns> public static int[] IsAccessible(IObjectTransformer transformer) { if (transformer.Input.Length != 1) { return(null); } if (transformer.Output.Length != 1) { return(null); } object[] t = new object[] { transformer.GetInputType(0), transformer.GetOutputType(0) }; int[] dim = new int[2]; for (int i = 0; i < t.Length; i++) { object type = t[i]; if (!(type is ArrayReturnType)) { return(null); } ArrayReturnType art = type as ArrayReturnType; if ((double)art.ElementType != a) { return(null); } int[] k = art.Dimension; if (k.Length != 1) { return(null); } dim[i] = k[0]; } return(dim); }
/// <summary> /// Set parameters /// </summary> /// <param name="trans">Transition</param> /// <param name="meas">Measurements</param> /// <param name="realMeasurements">Real measurements</param> /// <param name="covState">Covariation of state vector</param> /// <param name="covMea">Measurements of covariation matrix</param> /// <returns>True in success and false otherwise</returns> public bool Set(string trans, string meas, string realMeasurements, string covState, string covMea) { string[] str = new string[] { trans, meas }; IObjectTransformer[] tr = new IObjectTransformer[2]; int[][] n = new int[2][]; Diagram.UI.Interfaces.IComponentCollection cc = this; for (int i = 0; i < str.Length; i++) { IObjectTransformer trt = cc.GetCollectionObject <IObjectTransformer>(str[i]); int[] k = FiniteMatrixDerivationTransformer.IsAccessible( cc.GetCollectionObject <IObjectTransformer>(str[i])); if (k == null) { return(false); } n[i] = k; tr[i] = trt; } if ((n[0][0] != n[0][1]) | (n[0][1] != n[1][0])) { return(false); } IMeasurements[] mm = new IMeasurements[] { cc.GetCollectionObject <IMeasurements>(realMeasurements), cc.GetCollectionObject <IMeasurements>(covState), cc.GetCollectionObject <IMeasurements>(covMea) }; ArrayReturnType[] art = new ArrayReturnType[3]; Double a = 0; int[] d = new int[] { 1, 2, 2 }; for (int i = 0; i < art.Length; i++) { IMeasurements mea = mm[i]; if (mea == null) { return(false); } if (mea.Count != 1) { return(false); } object r = mea[0].Type; if (!(r is ArrayReturnType)) { return(false); } ArrayReturnType att = r as ArrayReturnType; art[i] = att; if (!att.ElementType.Equals(a)) { return(false); } if (att.Dimension.Length != d[i]) { return(false); } } ArrayReturnType at = art[0]; if (at.Dimension[0] != n[1][1]) { return(false); } at = art[1]; if ((at.Dimension[0] != n[0][0]) | (at.Dimension[1] != n[0][0])) { return(false); } at = art[2]; if ((at.Dimension[0] != n[1][1]) | (at.Dimension[1] != n[1][1])) { return(false); } inmea = mm; this.trans = trans; this.meas = meas; this.realMeasurements = realMeasurements; this.covState = covState; this.covMea = covMea; transitionObjectM = new FiniteMatrixDerivationTransformer(tr[0]); measurementsM = new FiniteMatrixDerivationTransformer(tr[1]); CreateMeas(n[1]); state = Create(n[0][0]); covariation = Create(n[0]); if (!isSerialized) { CreateArrays(n); } return(true); }
void IObjectTransformerConsumer.Remove(IObjectTransformer transformer) { this.transformer = null; }
public GenericCommand(IObjectTransformer transformer = null) { objectTransformer = transformer; }