The Transformer object is used to convert strings to and from object instances. This is used during the serialization and deserialization process to transform types from the Java class libraries, as well as other types which do not contain XML schema annotations. Typically this will be used to transform primitive types to and from strings, such as int values. @Element private String[] value; For example taking the above value the array of strings needs to be converted in to a single string value that can be inserted in to the element in such a way that in can be read later. In this case the serialized value of the string array would be as follows. <value>one, two, three</value> Here each non-null string is inserted in to a comma separated list of values, which can later be deserialized. Just to note the above array could be annotated with ElementList just as easily, in which case each entry would have its own element. The choice of which annotation to use is up to the developer. A more obvious benefit to transformations like this can be seen for values annotated with the Attribute annotation.
Example #1
0
 static void Main(string[] args)
 {
     Transformer t = new Transformer(Transform);
     t = Transform;
     t = delegate (int y) { return -y; };
     t = y => 2 * y;
 }
Example #2
0
 static void Trans(int[] values, Transformer t)
 {
     for (int i = 0; i < values.Length; i++)
     {
         values[i] = t(values[i]);
     }
 }
Example #3
0
        public void SetScale(double scaleFactor)
        {
            // get the current center in logical units

            Rectangle rc = Rectangle.Intersect(viewer.PhysicalViewRectangle, viewer.ClientRectangle); // get what you see in physical coordinates
            PointF center = new PointF(rc.Left + rc.Width / 2, rc.Top + rc.Height / 2); // get the center of what you see in physical coordinates
            Transformer t = new Transformer(viewer.Transform);
            center = t.PointToLogical(center);  // get the center of what you see in logical coordinates


            if (scaleFactor == 1)
            {
                if (viewer.SizeMode != RasterPaintSizeMode.Normal)
                    viewer.SizeMode = RasterPaintSizeMode.Normal;
            }

            scaleFactor = Math.Max(_minimumScaleFactor, Math.Min(_maximumScaleFactor, scaleFactor));

            if (viewer.ScaleFactor != scaleFactor)
            {
                viewer.ScaleFactor = scaleFactor;

                // bring the original center into the view center
                t = new Transformer(viewer.Transform);
                center = t.PointToPhysical(center); // get the center of what you saw before the zoom in physical coordinates
                viewer.CenterAtPoint(Point.Round(center)); // bring the old center into the center of the view
            }
        }
Example #4
0
 public void Transform(ref int[] array, Transformer t)
 {
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = t(array[i]);
     }
 }
Example #5
0
    public static void Main(String[] args)
    {
        try
        {
            ITransformer transformer = new Transformer();
            IReader reader = new ConsoleReader();
            IAnalyzer analyzer = new Analyzer(reader, transformer);
            AnalysisResult analysisResult = analyzer.Analyze();
            IDumper fileDumper = new ConsoleDumper(analysisResult);

            // A better way to inform about the result would be an Enum with some codes (error dumping, error reading, error connecting to db, etc)
            bool operationFinished = fileDumper.Dump();
            string message = "";
            if (operationFinished) { message = ""; }
            else { message = "The application encountered an error. Please check the logs. Press Enter to exit."; }

            Console.WriteLine(message);
            Console.ReadLine();
        }
        catch (Exception ex)
        {
            ex.Log("");
            Console.WriteLine("The application encountered an error. Please check the logs. Press Enter to exit.");
            Console.ReadLine();
        }
    }
 /**
  * Constructor that performs no validation.
  * Use <code>getInstance</code> if you want that.
  *
  * @param predicates  array of predicates, not cloned, no nulls
  * @param transformers  matching array of transformers, not cloned, no nulls
  * @param defaultTransformer  the transformer to use if no match, null means return null
  */
 public SwitchTransformer(Predicate[] predicates, Transformer[] transformers, Transformer defaultTransformer)
     : base()
 {
     iPredicates = predicates;
     iTransformers = transformers;
     iDefault = (defaultTransformer == null ? ConstantTransformer.NULL_INSTANCE : defaultTransformer);
 }
    public List<Transformer> GetTransformer()
    {
        List<Transformer> transformerList = new List<Transformer>();
        foreach (GridViewRow gvr in GV_List.Rows)
        {
            Transformer transformer = new Transformer();
            transformer.OrderLocTransId = int.Parse(((HiddenField)gvr.FindControl("hfOrderLocTransId")).Value);
            transformer.OrderNo = ((Label)gvr.FindControl("lblOrderNo")).Text;
            transformer.Sequence = int.Parse(((Label)gvr.FindControl("lblSequence")).Text);
            transformer.ItemCode = ((Label)gvr.FindControl("lblItemCode")).Text;
            transformer.ItemDescription = ((Label)gvr.FindControl("lblItemDescription")).Text;
            transformer.ReferenceItemCode = ((Label)gvr.FindControl("lblReferenceItemCode")).Text;
            transformer.UomCode = ((Label)gvr.FindControl("lblUom")).Text;
            transformer.UnitCount = decimal.Parse(((Label)gvr.FindControl("lblUnitCount")).Text);
            transformer.LocationFromCode = ((Label)gvr.FindControl("lblLocationFrom")).Text;
            transformer.LocationToCode = ((Label)gvr.FindControl("lblLocationTo")).Text;
            transformer.Qty = decimal.Parse(((Label)gvr.FindControl("lblQty")).Text);
            //订单数,为ASN收货加的
            transformer.OrderedQty = decimal.Parse(((Label)gvr.FindControl("lblQty")).Text);
            transformer.ReceivedQty = decimal.Parse(((Label)gvr.FindControl("lblReceivedQty")).Text);
            transformer.CurrentQty = this.GetActedQty(gvr);
            transformer.TransformerDetails = GetTransformerDetailControl(gvr).GetHuList();

            transformerList.Add(transformer);
        }

        return transformerList;
    }
 /**
  * Factory to create the predicate.
  *
  * @param transformer  the transformer to decorate
  * @return the predicate
  * @throws IllegalArgumentException if the transformer is null
  */
 public static Predicate getInstance(Transformer transformer)
 {
     if (transformer == null)
     {
         throw new java.lang.IllegalArgumentException("The transformer to call must not be null");
     }
     return new TransformerPredicate(transformer);
 }
 /**
  * Factory method that performs validation.
  * <p>
  * A null transformer will return the <code>NOPClosure</code>.
  *
  * @param transformer  the transformer to call, null means nop
  * @return the <code>transformer</code> closure
  */
 public static Closure getInstance(Transformer transformer)
 {
     if (transformer == null)
     {
         return NOPClosure.INSTANCE;
     }
     return new TransformerClosure(transformer);
 }
Example #10
0
 public TransformTest()
 {
     when = ROS.GetTime();
     //
     // TODO: Add constructor logic here
     //
     transformer = new Transformer();
 }
Example #11
0
        static void Main(string[] args)
        {
            ROS.Init(args, "tf_example");

            NodeHandle nh = new NodeHandle();

            ROS.Info("This node will create a Transformer to compare lookup results between four source/target frame pairs of an OpenNI2 node's transform tree with ones observed in linux with tf_echo");

            tfer = new Transformer(false);

#region tf_echo results
            /*
             * tf_echo camera_link camera_rgb_frame
             *      (0.0,-0.045,0.0)
             *      (0,0,0,1)
             */
            emTransform result1 = new emTransform() {basis = new emQuaternion(0, 0, 0, 1), origin = new emVector3(0, -0.045, 0), child_frame_id = "camera_rgb_frame", frame_id = "camera_link"};
            
            /*
             * tf_echo camera_link camera_rgb_optical_frame
             *      (0.0,-0.045,0.0)
             *      (-0.5,0.5,-0.5,0.5)
             */
            emTransform result2 = new emTransform() { basis = new emQuaternion(-0.5, 0.5, -0.5, 0.5), origin = new emVector3(0.0, -0.045, 0.0), child_frame_id = "camera_rgb_optical_frame", frame_id = "camera_link" };
            
            /*
             * tf_echo camera_rgb_frame camera_depth_frame
             *      (0.0,0.25,0.0)
             *      (0,0,0,1)
             */
            emTransform result3 = new emTransform() { basis = new emQuaternion(0,0,0,1), origin = new emVector3(0.0, 0.025, 0.0), child_frame_id = "camera_depth_frame", frame_id = "camera_rgb_frame" };
            
            /*
             * tf_echo camera_rgb_optical_frame camera_depth_frame
             *      (-0.25,0.0,0.0)
             *      (0.5,-0.5,0.5,0.5)
             */
            emTransform result4 = new emTransform() { basis = new emQuaternion(0.5, -0.5, 0.5, 0.5), origin = new emVector3(-0.025, 0.0, 0.0), child_frame_id = "camera_depth_frame", frame_id = "camera_rgb_optical_frame" };
#endregion

            emTransform test1 = null, test2 = null, test3 = null, test4 = null;
            do
            {
                if (test1 == null || !string.Equals(result1.ToString(), test1.ToString()))
                    test1 = testLookup(result1);
                if (test2 == null || !string.Equals(result2.ToString(), test2.ToString()))
                    test2 = testLookup(result2);
                if (test3 == null || !string.Equals(result3.ToString(), test3.ToString()))
                    test3 = testLookup(result3);
                if (test4 == null || !string.Equals(result4.ToString(), test4.ToString()))
                    test4 = testLookup(result4);
                Thread.Sleep(1000);
            } while (!string.Equals(result1.ToString(), test1.ToString()) || !string.Equals(result2.ToString(), test2.ToString()) || !string.Equals(result3.ToString(), test3.ToString()) || !string.Equals(result4.ToString(), test4.ToString()));

            Console.WriteLine("\n\n\nALL TFs MATCH!\n\nPress enter to quit");
            Console.ReadLine();
            ROS.shutdown();
        }
Example #12
0
 /** Create a symbolic transformer. */
 public Transformer CreateTransformer(FuncDecl[] _RelParams, Term[] _IndParams, Term _Formula)
     {
         Transformer t = new Transformer();
         t.RelParams = _RelParams;
         t.IndParams = _IndParams;
         t.Formula = _Formula;
         t.owner = this;
         return t;
     }
Example #13
0
        static int[] Processor(int[] values, Transformer transformer)
        {
            for (var i = 0; i < values.Length; i++)
            {
                values[i] = transformer(values[i]);
            }

            return values;
        }
 //-----------------------------------------------------------------------
 /**
  * Constructor that wraps (not copies).
  * <p>
  * If there are any elements already in the collection being decorated, they
  * are NOT transformed.
  *
  * @param coll  the collection to decorate, must not be null
  * @param transformer  the transformer to use for conversion, must not be null
  * @throws IllegalArgumentException if collection or transformer is null
  */
 protected TransformedCollection(java.util.Collection<Object> coll, Transformer transformer)
     : base(coll)
 {
     if (transformer == null)
     {
         throw new java.lang.IllegalArgumentException("Transformer must not be null");
     }
     this.transformer = transformer;
 }
Example #15
0
 public MainWindow(List<RunSession> RunSessions, Transformer trans)
     : base(Gtk.WindowType.Toplevel)
 {
     this.trans = trans;
     this.RunSessions = RunSessions;
     this.runFilter = new RunEventFilter (this.RunSessions);
     this.fa = new StatController(this.RunSessions);
     this.Build();
 }
Example #16
0
 //function that applies transform f to all elements in an array
 public static int[] transformArray(int[] values, Transformer f)
 {
     int[] output = new int[values.Length];
     for(int i = 0; i < values.Length; i++)
     {
         output[i] = f(values[i]);
     }
     return output;
 }
 /**
  * Factory method that performs validation and copies the parameter array.
  *
  * @param transformers  the transformers to chain, copied, no nulls
  * @return the <code>chained</code> transformer
  * @throws IllegalArgumentException if the transformers array is null
  * @throws IllegalArgumentException if any transformer in the array is null
  */
 public static Transformer getInstance(Transformer[] transformers)
 {
     FunctorUtils.validate(transformers);
     if (transformers.Length == 0)
     {
         return NOPTransformer.INSTANCE;
     }
     transformers = FunctorUtils.copy(transformers);
     return new ChainedTransformer(transformers);
 }
        public void Test()
        {
            var transformer = new Transformer();
            transformer.Transform(Helper.GetDataPath());

            var config1 = Path.Combine(Helper.GetDataPath(), "Folder\\Web.config");
            var config2 = Path.Combine(Helper.GetDataPath(), "Folder\\SubFolder\\App.config");
            var config3 = Path.Combine(Helper.GetDataPath(), "Folder\\SubFolder\\SubSubFolder\\App.config");

            XmlDocument doc1 = new XmlDocument(); doc1.Load(config1);
            XmlDocument doc2 = new XmlDocument(); doc2.Load(config2);
            XmlDocument doc3 = new XmlDocument(); doc3.Load(config3);

            var nodes1 = doc1.SelectNodes("configuration/appSettings/add[@key = 'Acropolis.SolutionFolder' and @value = 'd:\\Projects\\Ajeva Project']");
            var nodes2 = doc2.SelectNodes("configuration/appSettings/add[@key = 'Acropolis.SolutionFolder' and @value = 'd:\\Projects\\Ajeva Project']");
            var nodes3 = doc3.SelectNodes("configuration/appSettings/add[@key = 'Acropolis.SolutionFolder' and @value = 'c:\\Server\\Web\\ajeva.com\\Web']");

            Assert.AreEqual(nodes1.Count, 1);
            Assert.AreEqual(nodes2.Count, 1);
            Assert.AreEqual(nodes3.Count, 1);
        }
    public List<Transformer> GetInspectTransformer()
    {
        List<Transformer> transformerList = new List<Transformer>();
        foreach (GridViewRow gvr in GV_List.Rows)
        {
            Transformer transformer = new Transformer();
            transformer.Id = int.Parse(((HiddenField)gvr.FindControl("hfId")).Value);
            transformer.ItemCode = ((Label)gvr.FindControl("lblItemCode")).Text;
            transformer.ItemDescription = ((Label)gvr.FindControl("lblItemDescription")).Text;
            transformer.UomCode = ((Label)gvr.FindControl("lblUom")).Text;
            transformer.UnitCount = decimal.Parse(((Label)gvr.FindControl("lblUnitCount")).Text);
            transformer.LocationFromCode = ((Label)gvr.FindControl("lblLocationFrom")).Text;
            transformer.LocationToCode = ((Label)gvr.FindControl("lblLocationTo")).Text;
            transformer.CurrentQty = this.GetActedQty(gvr);
            transformer.CurrentRejectQty = this.GetActedRejectQty(gvr);
            transformer.TransformerDetails = GetTransformerDetailControl(gvr).GetHuList();

            transformerList.Add(transformer);
        }

        return transformerList;
    }
Example #20
0
        public string Compile(Transformer.Transformations transformations)
        {
            Transformations = transformations;

            sb.AppendLine("<?php");
            foreach(var c in signature)
                sb.AppendLine(c);
            sb.AppendLine(@"error_reporting(E_ALL | ~E_STRICT);
            if(!class_exists('F_Object'))
            require_once 'libfructose.php';
            if(!isset($_stack))
            global $_stack;
            global $_lambda_objs;
            if(!isset($_locals))
            global $_locals;
            global $_gthis;
            global $_globals;
            ");

            foreach (var stmt in tree.Statements)
                CompileNode(stmt);

            return sb.ToString();
        }
Example #21
0
 public int Transform(Transformer t) {
     return t(data);
 }
 /**
  * Copy method
  *
  * @param transformers  the transformers to copy
  * @return a clone of the transformers
  */
 internal static Transformer[] copy(Transformer[] transformers)
 {
     if (transformers == null)
     {
         return null;
     }
     return (Transformer[])transformers.clone();
 }
Example #23
0
        private static void AddTransformerDetail(Resolver resolver, TransformerDetail transformerDetail)
        {
            if (transformerDetail != null && transformerDetail.CurrentQty > 0)
            {
                List <Transformer> transformers = new List <Transformer>();
                if (resolver.Transformers != null)
                {
                    transformers = resolver.Transformers.ToList();
                }
                //检查重复扫描
                //CheckMatchHuExist(resolver, transformerDetail.HuId);

                //自动生成序号
                int seq = FindMaxSeq(transformers.ToArray());
                transformerDetail.Sequence = seq + 1;
                //匹配:严格匹配ItemCode/UomCode/UnitCount/StorageBinCode/LotNo
                var query = transformers.Where
                                (t => (string.Equals(t.ItemCode, transformerDetail.ItemCode, StringComparison.OrdinalIgnoreCase) &&
                                       string.Equals(t.UomCode, transformerDetail.UomCode, StringComparison.OrdinalIgnoreCase) &&
                                       (t.UnitCount == transformerDetail.UnitCount || t.UnitCount == transformerDetail.Qty) &&
                                       string.Equals(t.StorageBinCode, transformerDetail.StorageBinCode, StringComparison.OrdinalIgnoreCase) &&
                                       (t.LotNo == null || t.LotNo.Trim() == string.Empty || (string.Equals(t.LotNo, transformerDetail.LotNo, StringComparison.OrdinalIgnoreCase)))
                                       ));
                //匹配:如果没有匹配上,降低条件,匹配ItemCode/UomCode/UnitCount
                if (query.Count() == 0)
                {
                    query = transformers.Where
                                (t => (string.Equals(t.ItemCode, transformerDetail.ItemCode, StringComparison.OrdinalIgnoreCase) &&
                                       string.Equals(t.UomCode, transformerDetail.UomCode, StringComparison.OrdinalIgnoreCase) &&
                                       (t.UnitCount == transformerDetail.UnitCount || t.UnitCount == transformerDetail.Qty)
                                       ));
                }
                //匹配:如果还是没有匹配上,再降低条件,匹配ItemCode/UomCode
                if (query.Count() == 0)
                {
                    query = transformers.Where
                                (t => (string.Equals(t.ItemCode, transformerDetail.ItemCode, StringComparison.OrdinalIgnoreCase) &&
                                       string.Equals(t.UomCode, transformerDetail.UomCode, StringComparison.OrdinalIgnoreCase)
                                       ));
                }
                if (query.Count() > 0)
                {
                    List <Transformer> transformerList = query.ToList();
                    foreach (var transformer in transformerList)
                    {
                        if (transformer.Qty > transformer.CurrentQty || resolver.ModuleType == BusinessConstants.TRANSFORMER_MODULE_TYPE_STOCKTAKING)
                        {
                            List <TransformerDetail> transformerDetails = new List <TransformerDetail>();
                            foreach (var t in transformers)
                            {
                                if (t.TransformerDetails != null && t.TransformerDetails.Length > 0)
                                {
                                    foreach (var td in t.TransformerDetails)
                                    {
                                        if (td.HuId != null && td.HuId.ToLower() == transformerDetail.HuId.ToLower())
                                        {
                                            transformerDetails.Add(td);
                                        }
                                    }
                                }
                            }
                            if (transformerDetails.Count() == 1 && transformerDetails.Single().CurrentQty == 0M)
                            {
                                transformerDetails.Single().CurrentQty = transformerDetail.CurrentQty;
                                transformerDetails.Single().Sequence   = transformerDetail.Sequence;
                                transformer.CurrentQty += transformerDetail.CurrentQty;
                                transformer.Cartons++;
                            }
                            else
                            {
                                AddTransformerDetail(transformer, transformerDetail);
                            }
                            break;
                        }
                    }
                }
                else if (query.Count() == 0)
                {
                    Transformer transformer = new Transformer();
                    transformer.ItemCode        = transformerDetail.ItemCode;
                    transformer.ItemDescription = transformerDetail.ItemDescription;
                    transformer.UomCode         = transformerDetail.UomCode;
                    transformer.UnitCount       = transformerDetail.UnitCount;
                    transformer.CurrentQty      = transformerDetail.CurrentQty;
                    transformer.Qty             = transformerDetail.Qty;
                    transformer.LocationCode    = transformerDetail.LocationCode;
                    transformer.LotNo           = transformerDetail.LotNo;
                    transformer.StorageBinCode  = transformerDetail.StorageBinCode;
                    transformer.Cartons         = 1;
                    transformer.Sequence        = transformers.Count > 0 ? transformers.Max(t => t.Sequence) + 1 : 0;

                    AddTransformerDetail(transformer, transformerDetail);
                    transformers.Add(transformer);
                }
                //else
                //{
                //    //throw new Exception("Error on: Sconit_CS.Utility");
                //}
                resolver.Transformers = transformers.ToArray();
            }
            ProcessTransformer(resolver.Transformers);
            resolver.Command = BusinessConstants.CS_BIND_VALUE_TRANSFORMERDETAIL;
        }
        public override CanvasGeometry CreateGeometry(ICanvasResourceCreator resourceCreator, Matrix3x2 matrix)
        {
            Transformer transformer = base.Transform.Transformer;

            return(TransformerGeometry.CreatePie(resourceCreator, transformer, matrix, this.SweepAngle));
        }
Example #25
0
 private PostEntry RenderEntry(PostEntry entry)
 {
     entry         = entry.Clone();
     entry.Content = Transformer.Transform(entry.Content);
     return(entry);
 }
Example #26
0
 private void OnTransformerChosen(Transformer transformerChosen)
 {
     OnSelectingDone();
     wizardKing.GetKingCharacterControl().OnPuttingOnHat();
     DispatchMessage("OnTransformerChosen", transformerChosen);
 }
 /// <summary>
 /// Initialize a <see cref = "Transform" />.
 /// </summary>
 /// <param name="source"> The source transformer. </param>
 /// <param name="destination"> The destination transformer. </param>
 public Transform(Transformer source, Transformer destination)
 {
     this.Transformer = destination;
 }
 /// <summary>
 /// Initialize a <see cref = "Transform" />.
 /// </summary>
 /// <param name="transformer"> The transformer. </param>
 public Transform(Transformer transformer)
 {
     this.Transformer = transformer;
 }
 public static void DrawNode(IRenderer renderer, Transformer transformer, in Vector2 position)
 public NodeVisualization(DefinitionNode[] definitionNodes, Transformer transformer)
 {
     DefinitionNodes = definitionNodes;
     Transformer     = transformer;
 }
Example #31
0
 public string TransformToWordsTests(double number)
 => Transformer.TransformToWords(number);
Example #32
0
        // todo: Check whether busy and modified state are set correctly in all stages

        public FeatureFetchDispatcher(MemoryProvider cache, Transformer transformer)
        {
            _cache       = cache;
            _transformer = transformer;
        }
Example #33
0
        /// <summary>
        /// Subscribes a play object to all relevant gestures - tap, pan,
        /// press, release
        /// </summary>
        /// <param name="go">Game object</param>
        /// <param name="draggable">If set to <c>true</c> is a draggable object.</param>
        public void AddAndSubscribeToGestures(GameObject go, bool draggable, bool storypage)
        {
            // add a tap gesture component if one doesn't exist
            TapGesture tg = go.GetComponent <TapGesture>();

            if (tg == null)
            {
                tg = go.AddComponent <TapGesture>();
            }
            // checking for null anyway in case adding the component didn't work
            if (tg != null)
            {
                tg.Tapped += tappedHandler; // subscribe to tap events
                Logger.Log(go.name + " subscribed to tap events");
            }
            // if this object is draggable, handle pan events
            if (draggable)
            {
                // add pan gesture component if one doesn't exist yet
                TransformGesture trg = go.GetComponent <TransformGesture>();
                if (trg == null)
                {
                    trg      = go.AddComponent <TransformGesture>();
                    trg.Type = TransformGesture.TransformType.Translation;
                }
                if (trg != null)
                {
                    trg.TransformStarted   += transformStartedHandler;
                    trg.Transformed        += transformedHandler;
                    trg.TransformCompleted += transformCompleteHandler;
                    Logger.Log(go.name + " subscribed to drag events");
                }

                // make sure we do have a transformer if we're draggable
                Transformer tr = go.GetComponent <Transformer>();
                if (tr == null)
                {
                    tr = go.AddComponent <Transformer>();
                }
            }

            PressGesture prg = go.GetComponent <PressGesture>();

            if (prg == null)
            {
                prg = go.AddComponent <PressGesture>();
            }
            if (prg != null)
            {
                prg.Pressed += pressedHandler;
                Logger.Log(go.name + " subscribed to press events");
            }
            ReleaseGesture rg = go.GetComponent <ReleaseGesture>();

            if (rg == null)
            {
                rg = go.AddComponent <ReleaseGesture>();
            }
            if (rg != null)
            {
                rg.Released += releasedHandler;
                Logger.Log(go.name + " subscribed to release events");
            }


            // if this is a story page, handle swipe/flick events
            if (storypage)
            {
                // add flick gesture component if one doesn't exist yet
                FlickGesture fg = go.GetComponent <FlickGesture>();
                if (fg == null)
                {
                    fg = go.AddComponent <FlickGesture>();
                }
                if (fg != null)
                {
                    fg.Flicked += flickHandler;
                    fg.AddFriendlyGesture(tg);
                    fg.MinDistance       = 0.4f;
                    fg.FlickTime         = 0.5f;
                    fg.MovementThreshold = 0.1f;
                    Logger.Log(go.name + " subscribed to flick events");
                }
            }
        }
Example #34
0
			public void MovePrimitives(IEnumerable<IEditorPrimitive> primitives, Vector2 move2d, Camera camera, TransformToolMode mode)
			{
				Vector2 v1proj = camera.ProjectPoint(V1);
				Vector2 v2proj = camera.ProjectPoint(V1 + AxisVector[axis]);

				Vector2 dir = (v2proj - v1proj);

				float l = dir.Normalize();
				float amount = (dir.Dot(move2d)) / l;
				
				Vector3 translation = new Vector3();
				Vector3 scale = new Vector3(1,1,1);
				Vector3 euler = new Vector3();

				if (mode == TransformToolMode.Move)
					translation = amount * AxisVector[axis];
				else if (mode == TransformToolMode.Rotate)
					euler = AxisVector[axis] * (amount * 0.1f);
				else if (mode == TransformToolMode.Scale)
					scale += AxisVector[axis] * amount * 0.1f;

				Transformer transformer = new Transformer()
					{ euler =euler, translation = translation, scale = scale };

				// Get vertices
				foreach (ISceneEditor se in Program.SceneManager.SceneEditors)
					se.TransformSelection (primitives, transformer);
			}
Example #35
0
 public static void Html2Text(XDocument source, TextWriter output)
 {
     Transformer.Transform(source.CreateReader(), null, output);
 }
 /// <summary>
 /// Cache the class's transformer. Ex: _oldTransformer = Transformer.
 /// </summary>
 public virtual void CacheTransform()
 {
     this.StartingTransformer     = this.Transformer;
     this.StartingIsCrop          = this.IsCrop;
     this.StartingCropTransformer = this.GetActualTransformer();
 }
Example #37
0
 private PostExcerpt RenderExcerpt(PostExcerpt excerpt)
 {
     excerpt         = excerpt.Clone();
     excerpt.Excerpt = Transformer.Transform(excerpt.Excerpt);
     return(excerpt);
 }
Example #38
0
 public void Constructor_Throws_ArgumentOutOfRangeException_Thread_Count_Is_Below_One()
 {
     var collectionMock  = new Mock <IProducerConsumerCollection <object> >();
     var transformerMock = new Transformer <object, object>(collectionMock.Object, null, 0);
 }
Example #39
0
        /// <summary>
        /// Public method for transforming the double array somehow.
        /// </summary>
        /// <param name="array">Array of double numbers.</param>
        /// <param name="transformer">Method performing transforming.</param>
        /// <returns>Array of strings.</returns>
        /// <exception cref="ArgumentNullException">Is thrown if the <param name="array"/> is equal to null.</exception>
        /// <exception cref="ArgumentException">Is thrown if the <param name="array"/> is empty.</exception>
        public static IEnumerable <TResult> Transform <TSource, TResult>(IEnumerable <TSource> array, Transformer <TSource, TResult> transformer)
        {
            if (array == null)
            {
                throw new ArgumentNullException($"{nameof(array)} can't be equal to null");
            }

            return(TransformCore());

            IEnumerable <TResult> TransformCore()
            {
                foreach (var a in array)
                {
                    yield return(transformer(a));
                }
            }
        }
Example #40
0
 public void Constructor_Throws_ArugmentNullException_When_Consume_Collection_Is_Null()
 {
     var trasnformer = new Transformer <object, object>(null, null, 1);
 }
 public static int Transform(int x, Transformer t)
 {
     return(x = t(x));
 }
Example #42
0
 /** Create a hyper-edge. */
 public Edge CreateEdge(Node _Parent, Transformer _F, Node[] _Children)
 {
     Edge e = new Edge();
     e.Parent = _Parent;
     e.F = _F;
     e.Children = _Children;
     e.owner = this;
     e.number = ++edgeCount;
     _Parent.Outgoing = e;
     foreach (var c in _Children)
         if(c != null)
           c.Incoming.Add(e);
     return e;
 }
Example #43
0
        private Meter ToMeter(XDocument sheet)
        {
            double?ToNullableDouble(string str)
            {
                if (string.IsNullOrEmpty(str))
                {
                    return(null);
                }

                return(Convert.ToDouble(str));
            }

            XElement rootElement = sheet.Root;

            Meter meter = new Meter()
            {
                MeterAssets = new List <MeterAsset>(),
                Channels    = new List <Channel>()
            };

            XElement meterElement = rootElement.Element("meter");

            meter.ID          = Convert.ToInt32((string)meterElement.Element(nameof(meter.ID)));
            meter.AssetKey    = (string)meterElement.Element(nameof(meter.AssetKey));
            meter.LocationID  = Convert.ToInt32((string)meterElement.Element(nameof(meter.LocationID)));
            meter.Name        = (string)meterElement.Element(nameof(meter.Name));
            meter.Alias       = (string)meterElement.Element(nameof(meter.Alias));
            meter.ShortName   = (string)meterElement.Element(nameof(meter.ShortName));
            meter.Make        = (string)meterElement.Element(nameof(meter.Make));
            meter.Model       = (string)meterElement.Element(nameof(meter.Model));
            meter.TimeZone    = (string)meterElement.Element(nameof(meter.TimeZone));
            meter.Description = (string)meterElement.Element(nameof(meter.Description));

            Location location = new Location()
            {
                Meters         = new List <Meter>(),
                AssetLocations = new List <AssetLocation>()
            };

            XElement meterLocationElement = rootElement.Element("location");

            location.ID          = Convert.ToInt32((string)meterLocationElement.Element(nameof(location.ID)));
            location.LocationKey = (string)meterLocationElement.Element(nameof(location.LocationKey));
            location.Name        = (string)meterLocationElement.Element(nameof(location.Name));
            location.Alias       = (string)meterLocationElement.Element(nameof(location.Alias));
            location.ShortName   = (string)meterLocationElement.Element(nameof(location.ShortName));
            location.Latitude    = Convert.ToDouble((string)meterLocationElement.Element(nameof(location.Latitude)));
            location.Longitude   = Convert.ToDouble((string)meterLocationElement.Element(nameof(location.Longitude)));
            location.Description = (string)meterLocationElement.Element(nameof(location.Description));
            location.Meters.Add(meter);
            meter.Location = location;

            // This needs to be adjusted to work for Assets of all Types
            Dictionary <int, Asset> assets = new Dictionary <int, Asset>();

            foreach (XElement breakerElement in rootElement.Elements("breaker"))
            {
                Breaker breaker = new Breaker()
                {
                    AssetLocations = new List <AssetLocation>(),
                    MeterAssets    = new List <MeterAsset>(),
                    DirectChannels = new List <Channel>(),
                    Connections    = new List <AssetConnection>(),
                    AssetTypeID    = (int)AssetType.Breaker
                };
                breaker.VoltageKV     = Convert.ToDouble((string)breakerElement.Element(nameof(breaker.VoltageKV)));
                breaker.ThermalRating = Convert.ToDouble((string)breakerElement.Element(nameof(breaker.ThermalRating)));
                breaker.Speed         = Convert.ToDouble((string)breakerElement.Element(nameof(breaker.Speed)));
                breaker.ID            = Convert.ToInt32((string)breakerElement.Element(nameof(breaker.ID)));
                breaker.AssetKey      = (string)breakerElement.Element(nameof(breaker.AssetKey));
                breaker.Description   = (string)breakerElement.Element(nameof(breaker.Description));
                breaker.AssetName     = (string)breakerElement.Element(nameof(breaker.AssetName));
                assets.Add(breaker.ID, breaker);
            }

            foreach (XElement busElement in rootElement.Elements("bus"))
            {
                Bus bus = new Bus()
                {
                    AssetLocations = new List <AssetLocation>(),
                    MeterAssets    = new List <MeterAsset>(),
                    DirectChannels = new List <Channel>(),
                    Connections    = new List <AssetConnection>(),
                    AssetTypeID    = (int)AssetType.Bus
                };
                bus.VoltageKV   = Convert.ToDouble((string)busElement.Element(nameof(bus.VoltageKV)));
                bus.ID          = Convert.ToInt32((string)busElement.Element(nameof(bus.ID)));
                bus.AssetKey    = (string)busElement.Element(nameof(bus.AssetKey));
                bus.Description = (string)busElement.Element(nameof(bus.Description));
                bus.AssetName   = (string)busElement.Element(nameof(bus.AssetName));

                assets.Add(bus.ID, bus);
            }

            foreach (XElement capacitorBankElement in rootElement.Elements("capacitorBank"))
            {
                CapBank capBank = new CapBank()
                {
                    AssetLocations = new List <AssetLocation>(),
                    MeterAssets    = new List <MeterAsset>(),
                    DirectChannels = new List <Channel>(),
                    Connections    = new List <AssetConnection>(),
                    AssetTypeID    = (int)AssetType.CapacitorBank
                };
                capBank.VoltageKV          = Convert.ToDouble((string)capacitorBankElement.Element(nameof(capBank.VoltageKV)));
                capBank.NumberOfBanks      = Convert.ToInt32((string)capacitorBankElement.Element(nameof(capBank.NumberOfBanks)));
                capBank.CansPerBank        = Convert.ToInt32((string)capacitorBankElement.Element(nameof(capBank.CansPerBank)));
                capBank.CapacitancePerBank = Convert.ToDouble((string)capacitorBankElement.Element(nameof(capBank.CapacitancePerBank)));

                capBank.ID          = Convert.ToInt32((string)capacitorBankElement.Element(nameof(capBank.ID)));
                capBank.AssetKey    = (string)capacitorBankElement.Element(nameof(capBank.AssetKey));
                capBank.Description = (string)capacitorBankElement.Element(nameof(capBank.Description));
                capBank.AssetName   = (string)capacitorBankElement.Element(nameof(capBank.AssetName));

                assets.Add(capBank.ID, capBank);
            }

            foreach (XElement xfrElement in rootElement.Elements("transformer"))
            {
                Transformer xfr = new Transformer()
                {
                    AssetLocations = new List <AssetLocation>(),
                    MeterAssets    = new List <MeterAsset>(),
                    DirectChannels = new List <Channel>(),
                    Connections    = new List <AssetConnection>(),
                    AssetTypeID    = (int)AssetType.Transformer
                };
                xfr.ThermalRating      = Convert.ToDouble((string)xfrElement.Element(nameof(xfr.ThermalRating)));
                xfr.SecondaryVoltageKV = Convert.ToDouble((string)xfrElement.Element(nameof(xfr.SecondaryVoltageKV)));
                xfr.PrimaryVoltageKV   = Convert.ToDouble((string)xfrElement.Element(nameof(xfr.PrimaryVoltageKV)));
                xfr.Tap = Convert.ToDouble((string)xfrElement.Element(nameof(xfr.Tap)));
                xfr.R0  = Convert.ToDouble((string)xfrElement.Element(nameof(xfr.R0)));
                xfr.X0  = Convert.ToDouble((string)xfrElement.Element(nameof(xfr.X0)));
                xfr.R1  = Convert.ToDouble((string)xfrElement.Element(nameof(xfr.R1)));
                xfr.X1  = Convert.ToDouble((string)xfrElement.Element(nameof(xfr.X1)));

                xfr.ID          = Convert.ToInt32((string)xfrElement.Element(nameof(xfr.ID)));
                xfr.AssetKey    = (string)xfrElement.Element(nameof(xfr.AssetKey));
                xfr.Description = (string)xfrElement.Element(nameof(xfr.Description));
                xfr.AssetName   = (string)xfrElement.Element(nameof(xfr.AssetName));

                assets.Add(xfr.ID, xfr);
            }

            foreach (XElement lineElement in rootElement.Elements("line"))
            {
                Line line = new Line()
                {
                    AssetLocations = new List <AssetLocation>(),
                    MeterAssets    = new List <MeterAsset>(),
                    DirectChannels = new List <Channel>(),
                    Connections    = new List <AssetConnection>(),
                    AssetTypeID    = (int)AssetType.Line,
                    Segments       = new List <LineSegment>()
                };
                line.VoltageKV        = Convert.ToDouble((string)lineElement.Element(nameof(line.VoltageKV)));
                line.MaxFaultDistance = Convert.ToInt32((string)lineElement.Element(nameof(line.MaxFaultDistance)));
                line.MinFaultDistance = Convert.ToInt32((string)lineElement.Element(nameof(line.MinFaultDistance)));

                line.ID          = Convert.ToInt32((string)lineElement.Element(nameof(line.ID)));
                line.AssetKey    = (string)lineElement.Element(nameof(line.AssetKey));
                line.Description = (string)lineElement.Element(nameof(line.Description));
                line.AssetName   = (string)lineElement.Element(nameof(line.AssetName));

                assets.Add(line.ID, line);
            }

            foreach (XElement lineSegmentElement in rootElement.Elements("lineSegment"))
            {
                LineSegment lineSegment = new LineSegment()
                {
                    AssetLocations = new List <AssetLocation>(),
                    MeterAssets    = new List <MeterAsset>(),
                    DirectChannels = new List <Channel>(),
                    Connections    = new List <AssetConnection>(),
                    AssetTypeID    = (int)AssetType.LineSegement
                };
                lineSegment.ThermalRating = Convert.ToDouble((string)lineSegmentElement.Element(nameof(lineSegment.ThermalRating)));
                lineSegment.R0            = Convert.ToDouble((string)lineSegmentElement.Element(nameof(lineSegment.R0)));
                lineSegment.X0            = Convert.ToDouble((string)lineSegmentElement.Element(nameof(lineSegment.X0)));
                lineSegment.R1            = Convert.ToDouble((string)lineSegmentElement.Element(nameof(lineSegment.R1)));
                lineSegment.X1            = Convert.ToDouble((string)lineSegmentElement.Element(nameof(lineSegment.X1)));
                lineSegment.Length        = Convert.ToDouble((string)lineSegmentElement.Element(nameof(lineSegment.Length)));

                lineSegment.ID          = Convert.ToInt32((string)lineSegmentElement.Element(nameof(lineSegment.ID)));
                lineSegment.AssetKey    = (string)lineSegmentElement.Element(nameof(lineSegment.AssetKey));
                lineSegment.Description = (string)lineSegmentElement.Element(nameof(lineSegment.Description));
                lineSegment.AssetName   = (string)lineSegmentElement.Element(nameof(lineSegment.AssetName));

                assets.Add(lineSegment.ID, lineSegment);
            }
            foreach (XElement assetConnectionElement in rootElement.Elements("assetConnection"))
            {
                AssetConnection assetConnection = new AssetConnection();

                assetConnection.ID       = Convert.ToInt32((string)assetConnectionElement.Element(nameof(assetConnection.ID)));
                assetConnection.ChildID  = Convert.ToInt32((string)assetConnectionElement.Element(nameof(assetConnection.ChildID)));
                assetConnection.ParentID = Convert.ToInt32((string)assetConnectionElement.Element(nameof(assetConnection.ParentID)));
                assetConnection.AssetRelationshipTypeID = Convert.ToInt32((string)assetConnectionElement.Element(nameof(assetConnection.AssetRelationshipTypeID)));

                assets[assetConnection.ChildID].Connections.Add(assetConnection);
                assets[assetConnection.ParentID].Connections.Add(assetConnection);

                if (assets[assetConnection.ChildID].AssetTypeID == (int)AssetType.Line && assets[assetConnection.ParentID].AssetTypeID == (int)AssetType.LineSegement)
                {
                    Line        line        = (Line)assets[assetConnection.ChildID];
                    LineSegment lineSegment = (LineSegment)assets[assetConnection.ParentID];
                    line.Segments.Add(lineSegment);
                    lineSegment.Line = line;
                    assets[assetConnection.ChildID]  = line;
                    assets[assetConnection.ParentID] = lineSegment;
                }
                else if (assets[assetConnection.ParentID].AssetTypeID == (int)AssetType.Line && assets[assetConnection.ChildID].AssetTypeID == (int)AssetType.LineSegement)
                {
                    Line        line        = (Line)assets[assetConnection.ParentID];
                    LineSegment lineSegment = (LineSegment)assets[assetConnection.ChildID];
                    line.Segments.Add(lineSegment);
                    lineSegment.Line = line;
                    assets[assetConnection.ParentID] = line;
                    assets[assetConnection.ChildID]  = lineSegment;
                }

                assetConnection.Child  = assets[assetConnection.ChildID];
                assetConnection.Parent = assets[assetConnection.ParentID];
            }



            Dictionary <int, Channel>                   channels                   = new Dictionary <int, Channel>();
            Dictionary <int, MeasurementType>           measurementTypes           = new Dictionary <int, MeasurementType>();
            Dictionary <int, MeasurementCharacteristic> measurementCharacteristics = new Dictionary <int, MeasurementCharacteristic>();
            Dictionary <int, Phase> phases = new Dictionary <int, Phase>();

            foreach (XElement channelElement in rootElement.Elements("channel"))
            {
                Channel channel = new Channel()
                {
                    Series = new List <Series>()
                };
                channel.ID                          = Convert.ToInt32((string)channelElement.Element(nameof(channel.ID)));
                channel.MeterID                     = Convert.ToInt32((string)channelElement.Element(nameof(channel.MeterID)));
                channel.AssetID                     = Convert.ToInt32((string)channelElement.Element(nameof(channel.AssetID)));
                channel.MeasurementTypeID           = Convert.ToInt32((string)channelElement.Element(nameof(channel.MeasurementTypeID)));
                channel.MeasurementCharacteristicID = Convert.ToInt32((string)channelElement.Element(nameof(channel.ID)));
                channel.PhaseID                     = Convert.ToInt32((string)channelElement.Element(nameof(channel.PhaseID)));
                channel.Name                        = (string)channelElement.Element(nameof(channel.Name));
                channel.SamplesPerHour              = Convert.ToDouble((string)channelElement.Element(nameof(channel.SamplesPerHour)));
                channel.PerUnitValue                = ToNullableDouble((string)channelElement.Element(nameof(channel.PerUnitValue)));
                channel.HarmonicGroup               = Convert.ToInt32((string)channelElement.Element(nameof(channel.HarmonicGroup)));
                channel.Description                 = (string)channelElement.Element(nameof(channel.Description));
                channel.Enabled                     = Convert.ToBoolean((string)channelElement.Element(nameof(channel.Enabled)));
                channels.Add(channel.ID, channel);

                channel.MeasurementType = measurementTypes.GetOrAdd(channel.MeasurementTypeID, id => new MeasurementType()
                {
                    ID   = id,
                    Name = (string)channelElement.Element(nameof(channel.MeasurementType))
                });

                channel.MeasurementCharacteristic = measurementCharacteristics.GetOrAdd(channel.MeasurementCharacteristicID, id => new MeasurementCharacteristic()
                {
                    ID   = id,
                    Name = (string)channelElement.Element(nameof(channel.MeasurementCharacteristic))
                });

                channel.Phase = phases.GetOrAdd(channel.PhaseID, id => new Phase()
                {
                    ID   = id,
                    Name = (string)channelElement.Element(nameof(channel.Phase))
                });

                channel.Meter = meter;
                meter.Channels.Add(channel);

                channel.Asset = assets[channel.AssetID];
                channel.Asset.DirectChannels.Add(channel);
            }

            Dictionary <int, SeriesType> seriesTypes = new Dictionary <int, SeriesType>();

            foreach (XElement seriesElement in rootElement.Elements("series"))
            {
                Series series = new Series();
                series.ID            = Convert.ToInt32((string)seriesElement.Element(nameof(series.ID)));
                series.ChannelID     = Convert.ToInt32((string)seriesElement.Element(nameof(series.ChannelID)));
                series.SeriesTypeID  = Convert.ToInt32((string)seriesElement.Element(nameof(series.SeriesTypeID)));
                series.SourceIndexes = (string)seriesElement.Element(nameof(series.SourceIndexes));

                series.SeriesType = seriesTypes.GetOrAdd(series.SeriesTypeID, id => new SeriesType()
                {
                    ID   = id,
                    Name = (string)seriesElement.Element(nameof(series.SeriesType))
                });

                series.Channel = channels[series.ChannelID];
                series.Channel.Series.Add(series);
            }

            foreach (XElement assetLocationElement in rootElement.Elements("assetLocation"))
            {
                AssetLocation assetLocation = new AssetLocation();
                assetLocation.ID         = Convert.ToInt32((string)assetLocationElement.Element(nameof(assetLocation.ID)));
                assetLocation.LocationID = Convert.ToInt32((string)assetLocationElement.Element(nameof(assetLocation.LocationID)));
                assetLocation.AssetID    = Convert.ToInt32((string)assetLocationElement.Element(nameof(assetLocation.AssetID)));

                assetLocation.Location = location;
                location.AssetLocations.Add(assetLocation);

                assetLocation.Asset = assets[assetLocation.AssetID];
                assetLocation.Asset.AssetLocations.Add(assetLocation);
            }

            foreach (XElement meterAssetElement in rootElement.Elements("meterAsset"))
            {
                MeterAsset meterAsset = new MeterAsset();
                meterAsset.ID      = Convert.ToInt32((string)meterAssetElement.Element(nameof(meterAsset.ID)));
                meterAsset.MeterID = Convert.ToInt32((string)meterAssetElement.Element(nameof(meterAsset.MeterID)));
                meterAsset.AssetID = Convert.ToInt32((string)meterAssetElement.Element(nameof(meterAsset.AssetID)));

                meterAsset.Meter = meter;
                meter.MeterAssets.Add(meterAsset);

                meterAsset.Asset = assets[meterAsset.AssetID];
                meterAsset.Asset.MeterAssets.Add(meterAsset);
            }

            return(meter);
        }
Example #44
0
        public void TestNetFramework_ExternalCalculation_ReturnsHelloWorld()
        {
            var result = Transformer.TransformExternalCalculation();

            Assert.AreEqual("Hello World", result);
        }
Example #45
0
 public override int Velocidad(Transformer transformer)
 {
     return(transformer.PesoBase * 2);
 }
Example #46
0
        private void imageViewer_Clicked(object sender, EventArgs e)
        {
       //     return;
            MouseEventArgs eventArgs = (MouseEventArgs)e;
            Point p = new Point(eventArgs.X,eventArgs.Y);
            //Point clientP = imageViewer.Con

            Image image = null;
            
            if (toolBar != null && this.edit)
            {
                  //  this.imageViewer.
                if (Form.ModifierKeys == Keys.Control)
                {
                    image = (Image.FromHbitmap(ImageEdit.RedCheckmarkOnly.GetHbitmap()));
                }
                else
                {
                    image = (Image.FromHbitmap(ImageEdit.CheckmarkOnly.GetHbitmap()));
                }

                    AnnPicture pic = new AnnPicture(image);

                    AnnStampObject obj = new AnnStampObject();
                    obj.Picture = pic;
                    obj.Visible = true;
                    //  obj.
                    Transformer transform = new Transformer();
                    transform.Transform = this.imageViewer.Transform;


                    PointF pf = transform.PointToLogical(new PointF(eventArgs.X - 10, eventArgs.Y - 10));

                    obj.Bounds = new AnnRectangle(pf.X, pf.Y, 20, 20, AnnUnit.Pixel);
                    //  obj.Bounds = new AnnRectangle(new Rectangle(, new SizeF(30, 30)));
                    _annAutomation.Container.Objects.Add(obj);
                    _annAutomation.ImageDirty = true;
                    this.imageViewer.Invalidate();
             }
        }
Example #47
0
        /// <summary>
        /// Constructs the <see cref="LinearStateEstimator.Networks.PhaseSelection.PositiveSequence"/> version of the <see cref="LinearStateEstimator.Matrices.CurrentFlowMeasurementBusIncidenceMatrix"/>.
        /// </summary>
        /// <param name="network">The virtualized <see cref="LinearStateEstimator.Networks.Network"/> model.</param>
        private void BuildPositiveSequenceMatrix(Network network)
        {
            m_csvRowHeaders    = new List <string>();
            m_csvColumnHeaders = new List <string>();
            m_csvColumnHeaders.Add("A Matrix");

            List <ObservedBus> observedBusses = network.Model.ObservedBusses;
            //List<CurrentFlowPhasorGroup> measuredCurrents = network.Model.ActiveCurrentPhasors;
            List <CurrentFlowPhasorGroup> measuredCurrents = network.Model.IncludedCurrentFlows;

            if (observedBusses.Count > 0 && measuredCurrents.Count > 0)
            {
                m_matrixIsValid = true;

                // Create an empty current measurement-bus incidence matrix rows equal in number to the number of current phasors and
                // columns equal in number to the number of observed busses in the network.
                m_A = DenseMatrix.OfArray(new Complex[measuredCurrents.Count, observedBusses.Count]);

                foreach (CurrentFlowPhasorGroup measuredCurrent in measuredCurrents)
                {
                    m_csvRowHeaders.Add(measuredCurrent.Description);
                    foreach (ObservedBus observedBus in observedBusses)
                    {
                        if (measuredCurrents.IndexOf(measuredCurrent) == measuredCurrents.Count - 1)
                        {
                            m_csvColumnHeaders.Add("Sub: " + observedBus.InternalID.ToString());
                        }
                        foreach (Node node in observedBus.Nodes)
                        {
                            if (node.InternalID == (measuredCurrent.MeasuredFromNodeID))
                            {
                                // If measurement X leaves bus Y its element should be 1
                                if (measuredCurrent.MeasuredBranch is Transformer)
                                {
                                    Transformer transformer = measuredCurrent.MeasuredBranch as Transformer;
                                    if (node.InternalID == transformer.FromNode.InternalID)
                                    {
                                        double aSquared = transformer.EffectiveComplexMultiplier.Magnitude * transformer.EffectiveComplexMultiplier.Magnitude;
                                        m_A[measuredCurrents.IndexOf(measuredCurrent), observedBusses.IndexOf(observedBus)] = new Complex(1, 0) / aSquared;
                                    }
                                    else if (node.InternalID == transformer.ToNode.InternalID)
                                    {
                                        m_A[measuredCurrents.IndexOf(measuredCurrent), observedBusses.IndexOf(observedBus)] = new Complex(1, 0);
                                    }
                                }
                                else if (measuredCurrent.MeasuredBranch is TransmissionLine)
                                {
                                    m_A[measuredCurrents.IndexOf(measuredCurrent), observedBusses.IndexOf(observedBus)] = new Complex(1, 0);
                                }
                            }
                            else if (node.InternalID == (measuredCurrent.MeasuredToNodeID))
                            {
                                // If measurement X points toward bus Z its element should be -1
                                if (measuredCurrent.MeasuredBranch is Transformer)
                                {
                                    Transformer transformer = measuredCurrent.MeasuredBranch as Transformer;
                                    if (node.InternalID == transformer.FromNode.InternalID)
                                    {
                                        m_A[measuredCurrents.IndexOf(measuredCurrent), observedBusses.IndexOf(observedBus)] = new Complex(-1, 0) / transformer.EffectiveComplexMultiplier.Conjugate();
                                    }
                                    else if (node.InternalID == transformer.ToNode.InternalID)
                                    {
                                        m_A[measuredCurrents.IndexOf(measuredCurrent), observedBusses.IndexOf(observedBus)] = new Complex(-1, 0) / transformer.EffectiveComplexMultiplier;
                                    }
                                }
                                else if (measuredCurrent.MeasuredBranch is TransmissionLine)
                                {
                                    m_A[measuredCurrents.IndexOf(measuredCurrent), observedBusses.IndexOf(observedBus)] = new Complex(-1, 0);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                m_matrixIsValid = false;
            }
        }
Example #48
0
 public override int Peso(Transformer transformer)
 {
     return(transformer.PesoBase * 2);
 }
 /**
  * Factory method to create a transforming collection.
  * <p>
  * If there are any elements already in the collection being decorated, they
  * are NOT transformed.
  *
  * @param coll  the collection to decorate, must not be null
  * @param transformer  the transformer to use for conversion, must not be null
  * @return a new transformed collection
  * @throws IllegalArgumentException if collection or transformer is null
  */
 public static java.util.Collection<Object> decorate(java.util.Collection<Object> coll, Transformer transformer)
 {
     return new TransformedCollection(coll, transformer);
 }
 public Customized32HashedMap(int capacity, Transformer <K, byte[]> transformer)
     : this(capacity, new MurmurHash32(), transformer, EqualityComparer <K> .Default.Equals)
 {
 }
 /**
  * Validate method
  *
  * @param transformers  the transformers to validate
  */
 internal static void validate(Transformer[] transformers)
 {
     if (transformers == null)
     {
         throw new java.lang.IllegalArgumentException("The transformer array must not be null");
     }
     for (int i = 0; i < transformers.Length; i++)
     {
         if (transformers[i] == null)
         {
             throw new java.lang.IllegalArgumentException(
                 "The transformer array must not contain a null transformer, index " + i + " was null");
         }
     }
 }
 public Customized32HashedMap(int capacity, Transformer <K, byte[]> transformer, IEqualityComparer <K> comparer)
     : this(capacity, new MurmurHash32(), transformer, comparer.Equals)
 {
     transform = transformer;
 }
Example #53
0
 protected override void gvList_CurrentCellChanged(object sender, EventArgs e)
 {
     this.rowIndex = -1;
     if (this.gvList.SelectedRows.Count > 0)
     {
         this.gvList.BeginEdit(true);
         this.rowIndex = this.gvList.SelectedRows[0].Index;
     }
     if (rowIndex > -1)
     {
         this.gvList["CurrentQty", rowIndex].ReadOnly = false;
         this.gvList["CurrentQty", rowIndex].Value = this.gvList["Qty", rowIndex].Value;
         int Id = int.Parse(this.gvList["Id", rowIndex].Value.ToString());
         if (this.resolver != null && this.resolver.Transformers != null)
         {
             foreach (Transformer transformer in this.resolver.Transformers)
             {
                 if (transformer.OrderLocTransId == Id)
                 {
                     this.currentTransformer = transformer;
                 }
                 else
                 {
                     transformer.CurrentQty = 0;
                 }
             }
         }
     }
 }
 public Customized32HashedMap(int capacity, Transformer <K, byte[]> transformer, Equator <K> isEqual)
     : this(capacity, new MurmurHash32(), transformer, isEqual)
 {
 }
 /**
  * Returns a transformed sorted set backed by the given set.
  * <p>
  * Each object is passed through the transformer as it is added to the
  * Set. It is important not to use the original set after invoking this
  * method, as it is a backdoor for adding untransformed objects.
  *
  * @param set  the set to transform, must not be null
  * @param transformer  the transformer for the set, must not be null
  * @return a transformed set backed by the given set
  * @throws IllegalArgumentException  if the Set or Transformer is null
  */
 public static java.util.SortedSet<Object> transformedSortedSet(java.util.SortedSet<Object> set, Transformer transformer)
 {
     return TransformedSortedSet.decorate(set, transformer);
 }
 public Customized32HashedMap(int capacity, IHashStrategy hasher, Transformer <K, byte[]> transformer, Equator <K> isEqual)
     : base(capacity, new EquatorComparer <K>(isEqual))
 {
     transform   = transformer;
     this.hasher = hasher;
 }
Example #57
0
        private XDocument ToSheet(Meter meter)
        {
            XDocument sheet       = new XDocument();
            XElement  rootElement = new XElement("meterSettingsSheet");

            sheet.Add(rootElement);

            XElement meterElement = new XElement("meter");

            meterElement.Add(new XElement(nameof(meter.ID), meter.ID));
            meterElement.Add(new XElement(nameof(meter.AssetKey), meter.AssetKey));
            meterElement.Add(new XElement(nameof(meter.LocationID), meter.LocationID));
            meterElement.Add(new XElement(nameof(meter.Name), meter.Name));
            meterElement.Add(new XElement(nameof(meter.Alias), meter.Alias));
            meterElement.Add(new XElement(nameof(meter.ShortName), meter.ShortName));
            meterElement.Add(new XElement(nameof(meter.Make), meter.Make));
            meterElement.Add(new XElement(nameof(meter.Model), meter.Model));
            meterElement.Add(new XElement(nameof(meter.TimeZone), meter.TimeZone));
            meterElement.Add(new XElement(nameof(meter.Description), meter.Description));
            rootElement.Add(meterElement);

            XElement locationElement = new XElement("location");

            locationElement.Add(new XElement(nameof(meter.Location.ID), meter.Location.ID));
            locationElement.Add(new XElement(nameof(meter.Location.LocationKey), meter.Location.LocationKey));
            locationElement.Add(new XElement(nameof(meter.Location.Name), meter.Location.Name));
            locationElement.Add(new XElement(nameof(meter.Location.Alias), meter.Location.Alias));
            locationElement.Add(new XElement(nameof(meter.Location.ShortName), meter.Location.ShortName));
            locationElement.Add(new XElement(nameof(meter.Location.Latitude), meter.Location.Latitude));
            locationElement.Add(new XElement(nameof(meter.Location.Longitude), meter.Location.Longitude));
            locationElement.Add(new XElement(nameof(meter.Location.Description), meter.Location.Description));
            rootElement.Add(locationElement);

            // Start With Assets
            IEnumerable <Asset> assets = meter.MeterAssets
                                         .Select(meterLine => meterLine.Asset)
                                         .OrderBy(asset => asset.ID);

            //Save individual Assets (Except LineSegments)
            List <LineSegment>     lineSegments     = new List <LineSegment>();
            List <AssetConnection> assetConnections = new List <AssetConnection>();

            foreach (Asset asset in assets)
            {
                XElement assetElement = new XElement("asset");;

                switch (asset.AssetTypeID)
                {
                case ((int)AssetType.Breaker):
                    assetElement = new XElement("breaker");
                    Breaker breaker = Breaker.DetailedBreaker(asset, asset.ConnectionFactory?.Invoke());
                    assetElement.Add(new XElement(nameof(breaker.VoltageKV), breaker.VoltageKV));
                    assetElement.Add(new XElement(nameof(breaker.ThermalRating), breaker.ThermalRating));
                    assetElement.Add(new XElement(nameof(breaker.Speed), breaker.Speed));
                    assetElement.Add(new XElement(nameof(asset.ID), asset.ID));
                    assetElement.Add(new XElement(nameof(asset.AssetKey), asset.AssetKey));
                    assetElement.Add(new XElement(nameof(asset.Description), asset.Description));
                    assetElement.Add(new XElement(nameof(asset.AssetName), asset.AssetName));
                    break;

                case ((int)AssetType.Bus):
                    assetElement = new XElement("bus");
                    Bus bus = Bus.DetailedBus(asset, asset.ConnectionFactory?.Invoke());
                    assetElement.Add(new XElement(nameof(bus.VoltageKV), bus.VoltageKV));
                    assetElement.Add(new XElement(nameof(asset.ID), asset.ID));
                    assetElement.Add(new XElement(nameof(asset.AssetKey), asset.AssetKey));
                    assetElement.Add(new XElement(nameof(asset.Description), asset.Description));
                    assetElement.Add(new XElement(nameof(asset.AssetName), asset.AssetName));
                    break;

                case ((int)AssetType.CapacitorBank):
                    assetElement = new XElement("capacitorBank");
                    CapBank capBank = CapBank.DetailedCapBank(asset, asset.ConnectionFactory?.Invoke());
                    assetElement.Add(new XElement(nameof(capBank.VoltageKV), capBank.VoltageKV));
                    assetElement.Add(new XElement(nameof(capBank.NumberOfBanks), capBank.NumberOfBanks));
                    assetElement.Add(new XElement(nameof(capBank.CansPerBank), capBank.CansPerBank));
                    assetElement.Add(new XElement(nameof(capBank.CapacitancePerBank), capBank.CapacitancePerBank));
                    assetElement.Add(new XElement(nameof(asset.ID), asset.ID));
                    assetElement.Add(new XElement(nameof(asset.AssetKey), asset.AssetKey));
                    assetElement.Add(new XElement(nameof(asset.Description), asset.Description));
                    assetElement.Add(new XElement(nameof(asset.AssetName), asset.AssetName));
                    break;

                case ((int)AssetType.Transformer):
                    assetElement = new XElement("transformer");
                    Transformer xfr = Transformer.DetailedTransformer(asset, asset.ConnectionFactory?.Invoke());
                    assetElement.Add(new XElement(nameof(xfr.ThermalRating), xfr.ThermalRating));
                    assetElement.Add(new XElement(nameof(xfr.SecondaryVoltageKV), xfr.SecondaryVoltageKV));
                    assetElement.Add(new XElement(nameof(xfr.PrimaryVoltageKV), xfr.PrimaryVoltageKV));
                    assetElement.Add(new XElement(nameof(xfr.Tap), xfr.Tap));
                    assetElement.Add(new XElement(nameof(xfr.X0), xfr.X0));
                    assetElement.Add(new XElement(nameof(xfr.R0), xfr.R0));
                    assetElement.Add(new XElement(nameof(xfr.X1), xfr.X1));
                    assetElement.Add(new XElement(nameof(xfr.R1), xfr.R1));
                    assetElement.Add(new XElement(nameof(asset.ID), asset.ID));
                    assetElement.Add(new XElement(nameof(asset.AssetKey), asset.AssetKey));
                    assetElement.Add(new XElement(nameof(asset.Description), asset.Description));
                    assetElement.Add(new XElement(nameof(asset.AssetName), asset.AssetName));
                    break;

                case ((int)AssetType.Line):
                    assetElement = new XElement("line");
                    Line line = Line.DetailedLine(asset);
                    assetElement.Add(new XElement(nameof(line.VoltageKV), line.VoltageKV));
                    assetElement.Add(new XElement(nameof(line.MaxFaultDistance), line.MaxFaultDistance));
                    assetElement.Add(new XElement(nameof(line.MinFaultDistance), line.MinFaultDistance));
                    assetElement.Add(new XElement(nameof(asset.ID), asset.ID));
                    assetElement.Add(new XElement(nameof(asset.AssetKey), asset.AssetKey));
                    assetElement.Add(new XElement(nameof(asset.Description), asset.Description));
                    assetElement.Add(new XElement(nameof(asset.AssetName), asset.AssetName));
                    lineSegments.AddRange(line.Segments);
                    break;

                case ((int)AssetType.LineSegement):
                    lineSegments.Add(LineSegment.DetailedLineSegment(asset, asset.ConnectionFactory?.Invoke()));
                    break;

                default:
                    assetElement = new XElement("asset");
                    assetElement.Add(new XElement(nameof(asset.ID), asset.ID));
                    assetElement.Add(new XElement(nameof(asset.AssetKey), asset.AssetKey));
                    assetElement.Add(new XElement(nameof(asset.Description), asset.Description));
                    assetElement.Add(new XElement(nameof(asset.AssetName), asset.AssetName));
                    break;
                }

                assetConnections.AddRange(asset.Connections.Where(item => item.ParentID == asset.ID));
                rootElement.Add(assetElement);
            }

            //Deal with special Cases... If it is a line we need to keep the Line Segments...
            foreach (LineSegment lineSegment in lineSegments)
            {
                XElement lineSegmentElement = new XElement("lineSegment");
                lineSegmentElement.Add(new XElement(nameof(lineSegment.ThermalRating), lineSegment.ThermalRating));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.X0), lineSegment.X0));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.R0), lineSegment.R0));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.X1), lineSegment.X1));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.R1), lineSegment.R1));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.ID), lineSegment.ID));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.Length), lineSegment.Length));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.AssetKey), lineSegment.AssetKey));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.Description), lineSegment.Description));
                lineSegmentElement.Add(new XElement(nameof(lineSegment.AssetName), lineSegment.AssetName));
                assetConnections.AddRange(lineSegment.Connections.Where(item => item.ParentID == lineSegment.ID));
                rootElement.Add(lineSegmentElement);
            }

            //Deal with Asset -> Asset Connections.....
            foreach (AssetConnection assetConnection in assetConnections)
            {
                if (assets.Select(item => item.ID).Contains(assetConnection.ChildID) || lineSegments.Select(item => item.ID).Contains(assetConnection.ChildID))
                {
                    XElement assetConnectionElement = new XElement("assetConnection");
                    assetConnectionElement.Add(new XElement(nameof(assetConnection.ID), assetConnection.ID));
                    assetConnectionElement.Add(new XElement(nameof(assetConnection.ChildID), assetConnection.ChildID));
                    assetConnectionElement.Add(new XElement(nameof(assetConnection.ParentID), assetConnection.ParentID));
                    assetConnectionElement.Add(new XElement(nameof(assetConnection.AssetRelationshipTypeID), assetConnection.AssetRelationshipTypeID));
                    rootElement.Add(assetConnectionElement);
                }
            }

            // That is it for Assets

            IEnumerable <Channel> channels = meter.Channels
                                             .OrderBy(channel => channel.ID);

            foreach (Channel channel in channels)
            {
                if (channel.ID == 0)
                {
                    continue;
                }

                XElement channelElement = new XElement("channel");
                channelElement.Add(new XElement(nameof(channel.ID), channel.ID));
                channelElement.Add(new XElement(nameof(channel.MeterID), channel.MeterID));
                channelElement.Add(new XElement(nameof(channel.AssetID), channel.AssetID));
                channelElement.Add(new XElement(nameof(channel.MeasurementTypeID), channel.MeasurementTypeID));
                channelElement.Add(new XElement(nameof(channel.MeasurementType), channel.MeasurementType.Name));
                channelElement.Add(new XElement(nameof(channel.MeasurementCharacteristicID), channel.MeasurementCharacteristicID));
                channelElement.Add(new XElement(nameof(channel.MeasurementCharacteristic), channel.MeasurementCharacteristic.Name));
                channelElement.Add(new XElement(nameof(channel.PhaseID), channel.PhaseID));
                channelElement.Add(new XElement(nameof(channel.Phase), channel.Phase.Name));
                channelElement.Add(new XElement(nameof(channel.Name), channel.Name));
                channelElement.Add(new XElement(nameof(channel.SamplesPerHour), channel.SamplesPerHour));
                channelElement.Add(new XElement(nameof(channel.PerUnitValue), channel.PerUnitValue));
                channelElement.Add(new XElement(nameof(channel.HarmonicGroup), channel.HarmonicGroup));
                channelElement.Add(new XElement(nameof(channel.Description), channel.Description));
                channelElement.Add(new XElement(nameof(channel.Enabled), channel.Enabled));
                rootElement.Add(channelElement);
            }

            IEnumerable <Series> seriesList = meter.Channels
                                              .SelectMany(channel => channel.Series)
                                              .OrderBy(series => series.ID);

            foreach (Series series in seriesList)
            {
                if (series.ID == 0)
                {
                    continue;
                }

                XElement seriesElement = new XElement("series");
                seriesElement.Add(new XElement(nameof(series.ID), series.ID));
                seriesElement.Add(new XElement(nameof(series.ChannelID), series.ChannelID));
                seriesElement.Add(new XElement(nameof(series.SeriesTypeID), series.SeriesTypeID));
                seriesElement.Add(new XElement(nameof(series.SeriesType), series.SeriesType.Name));
                seriesElement.Add(new XElement(nameof(series.SourceIndexes), series.SourceIndexes));
                rootElement.Add(seriesElement);
            }

            IEnumerable <AssetLocation> assetLocations = meter.Location.AssetLocations
                                                         .OrderBy(assetLocation => assetLocation.ID);

            foreach (AssetLocation assetLocation in assetLocations)
            {
                XElement meterLocationLineElement = new XElement("assetLocation");
                meterLocationLineElement.Add(new XElement(nameof(assetLocation.ID), assetLocation.ID));
                meterLocationLineElement.Add(new XElement(nameof(assetLocation.LocationID), assetLocation.LocationID));
                meterLocationLineElement.Add(new XElement(nameof(assetLocation.AssetID), assetLocation.AssetID));
                rootElement.Add(meterLocationLineElement);
            }

            IEnumerable <MeterAsset> meterAssets = meter.MeterAssets
                                                   .OrderBy(meterAsset => meterAsset.ID);

            foreach (MeterAsset meterAsset in meterAssets)
            {
                XElement meterLineElement = new XElement("meterAsset");
                meterLineElement.Add(new XElement(nameof(meterAsset.ID), meterAsset.ID));
                meterLineElement.Add(new XElement(nameof(meterAsset.MeterID), meterAsset.MeterID));
                meterLineElement.Add(new XElement(nameof(meterAsset.AssetID), meterAsset.AssetID));
                rootElement.Add(meterLineElement);
            }

            return(sheet);
        }
Example #58
0
 public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, IChartBase v, float xOrigin, float yOrigin, long duration) :
     base(viewPortHandler, xValue, yValue, trans, v)
 {
     this.xOrigin  = xOrigin;
     this.yOrigin  = yOrigin;
     this.duration = duration;
 }
Example #59
0
        private void HighlightDuplicates(DuplicatesSearcher duplicatesSearcher, Transformer<IComparable,string> keyTransformer)
        {
            List<List<DuplicatesSearcher.DuplicatesSearcherItem>> duplicates = duplicatesSearcher.GetDuplicates();
            foreach (List<DuplicatesSearcher.DuplicatesSearcherItem> list in duplicates)
            {
                Assert.Check(list.Count > 1);

                bool skippedFirst = false;
                foreach (DuplicatesSearcher.DuplicatesSearcherItem item in list)
                {
                    if(!skippedFirst)
                    {
                        skippedFirst = true;
                        continue;
                    }

                    highlightings.Add(
                        new HighlightingInfo(item.Range, new DuplicateMappingHighlighting(keyTransformer(item.Key))));

                }

            }
        }
Example #60
0
 public override int PoderDestructivo(Transformer transformer)
 {
     return(transformer.PoderDestructivoBase * 2);
 }