public override void GetAll(IIndicatorValues Ind)
        {
            IDivergentIndicator studyIndicator      = (IDivergentIndicator)this.IndicatorParameters.List[0];
            IDivergentIndicator divergenceIndicator = (IDivergentIndicator)this.IndicatorParameters.List[1];

            if (!Ind.Divergence(studyIndicator, divergenceIndicator).IsPopulated)
            {
                int oldCurrentBar = Ind.Bar.CurrentBar;
                for (int i = 1; i <= Ind.Bar.MaxBar; i++)
                {
                    Ind.Bar.CurrentBar = i;

                    object prototype = null;
                    if (i == 1)
                    {
                        prototype = new Divergence();
                    }
                    else
                    {
                        prototype = (Divergence)Ind.Divergence(studyIndicator, divergenceIndicator)[1].Clone();
                    }

                    Get(ref prototype, Ind);

                    Ind.Divergence(studyIndicator, divergenceIndicator)[0] = (Divergence)prototype;

                    Ind.Divergence(studyIndicator, divergenceIndicator).IsPopulated = true;                     // set here so instance is guaranteed to exits
                }

                Ind.Bar.CurrentBar = oldCurrentBar;
            }
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            w    = GraphicsDevice.Viewport.Bounds.Width;
            h    = GraphicsDevice.Viewport.Bounds.Height;
            data = new uint[w * h];
            sw   = GraphicsDevice.Viewport.Bounds.Width;
            sh   = GraphicsDevice.Viewport.Bounds.Height;

            // texture = new Texture2D(GraphicsDevice, w, h);
            textureFade = new Texture2D(GraphicsDevice, 1, 1);
            textureFade.SetData(new uint[] { 0x0f000000 });
            textureWhite = new Texture2D(GraphicsDevice, 1, 1);
            textureWhite.SetData(new uint[] { 0xFFFFFFFF });

            // Setup our BasicEffect for drawing the quad
            worldMatrix = Matrix.CreateScale(w / (float)h, 1, 1);
            display     = Content.Load <Effect>("basic");
            depthEffect = Content.Load <Effect>("depth");

            Matrix projection = Matrix.CreateOrthographicOffCenter(0,
                                                                   GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0, 1);
            Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);

            display.Parameters["MatrixTransform"].SetValue(halfPixelOffset * projection);
            depthEffect.Parameters["MatrixTransform"].SetValue(halfPixelOffset * projection);

            // Create a vertex declaration
            vertexDeclaration = new VertexDeclaration(
                new VertexElement[] {
                new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
                new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
                new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
            });

            velocity           = new RenderTargetDouble(GraphicsDevice, w, h);
            density            = new RenderTargetDouble(GraphicsDevice, w, h);
            velocityDivergence = new RenderTargetDouble(GraphicsDevice, w, h);
            velocityVorticity  = new RenderTargetDouble(GraphicsDevice, w, h);
            pressure           = new RenderTargetDouble(GraphicsDevice, w, h);

            advect               = new Advect(w, h, timestep, Content);
            boundary             = new Boundary(w, h, Content);
            diffuse              = new Jacobi(Content.Load <Effect>("jacobivector"), w, h);
            divergence           = new Divergence(w, h, Content);
            poissonPressureEq    = new Jacobi(Content.Load <Effect>("jacobiscalar"), w, h);
            gradient             = new Gradient(w, h, Content);
            splat                = new Splat(w, h, Content);
            vorticity            = new Vorticity(w, h, Content);
            vorticityConfinement = new VorticityConfinement(Content.Load <Effect>("vorticityforce"), w, h, timestep);

            // this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();
            this.depthFrameReader = this.kinectSensor.DepthFrameSource.OpenReader();
            this.kinectSensor.Open();
            // this.bodyFrameReader.FrameArrived += this.Reader_FrameArrived;
            this.depthFrameReader.FrameArrived += DepthFrameReader_FrameArrived;
        }
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            Divergence divergence = Data.Divergence(IndicatorParameters)[Instant.ExposureDate];

            string upValue   = Convert.ToString((Data as IIndicatorValues).Bar[Instant.ExposureDate].Close * 0.99M);
            string downValue = Convert.ToString((Data as IIndicatorValues).Bar[Instant.ExposureDate].Close * 1.01M);

            return(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|",
                                 divergence.StudyPeakToPeakValue,
                                 divergence.StudyDipToDipValue,
                                 divergence.DivergencePeakToPeakValue,
                                 divergence.DivergenceDipToDipValue,
                                 (divergence.IsUp) ? upValue : "",
                                 (divergence.IsDown) ? downValue : "",
                                 (int)divergence.Direction,
                                 divergence.Direction));
        }
Exemple #4
0
        static void Main(string[] cmdArgs)
        {
            // Draw Figure A
            var args = new DivergenceArgs {
                Scale      = DivergenceScale.Medium,
                Spacing    = new DivergenceSpacing(8, 8),
                Background = Color.FromArgb(224, 224, 224),
            };
            string text = "Oslo II";

            using (Bitmap bmp = Divergence.Draw(text, args))
                bmp.Save("OsloII.png");

            // Draw Figure B
            args.Scale   = DivergenceScale.Small;
            args.Spacing = new DivergenceSpacing(5, 5);
            DateTime date = DateTime.Now;

            text = $"{date:MM\\/dd\\/yy}\n{date.TimeOfDay:hh\\:mm\\:ss}";
            using (Bitmap bmp = Divergence.Draw(text, args))
                bmp.Save("DateTime.png");

            // Draw Figure C
            args = new DivergenceArgs {
                Scale      = DivergenceScale.Small,
                Background = "EV_Z02A.PNG",                 // The CG background
            };
            text = "1.130426";
            Divergence.CalculateSpacingFor(1920 / 2, 1080 / 2, text, ref args, left: 5, top: 2);
            using (Bitmap bmp = Divergence.Draw(text, args))
                bmp.Save("Original Worldline.png");

            // Draw Figure D
            args = new DivergenceArgs {
                Scale      = DivergenceScale.Small,
                Background = Color.Black,
                Escape     = DivergenceEscape.NewLines,
            };
            text = @"#1\n#2";
            using (Bitmap bmp = Divergence.Draw(text, args))
                bmp.Save("Command Line Example.png");
        }
 public FileRow(DateTime meterReadDateTime, double granularMeterRead)
 {
     this.OccurrenceDateTime = meterReadDateTime;
     this.DataValue          = granularMeterRead;
     this.Divergence         = Divergence.AcceptableDivergence;// Default Acceptance unless overridden
 }
Exemple #6
0
 static void Save(string text, DivergenceArgs args, string path)
 {
     Divergence.Draw(text, args).SaveAndDispose(path);
 }
Exemple #7
0
 static void Test(string text, DivergenceArgs args)
 {
     Divergence.Draw(text, args).OpenInMSPaint();
 }
        static void Main(string[] args)
        {
            Console.Title           = "Divergence Meter Input";
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("======== Divergence Input ========");
            Console.ResetColor();
            Console.Write("Enter ");
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write("back");
            Console.ResetColor();
            Console.Write(" during any input to go to the previous input. Enter ");
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write("exit");
            Console.ResetColor();
            Console.WriteLine(" to exit. (case-sensitive)");

            string input = null;

            Divergence.EnableLimits = false;
            char[]         invalidNameChars = Path.GetInvalidFileNameChars();
            int            inputIndex       = 0;
            DivergenceArgs dargs            = new DivergenceArgs {
                Alignment    = System.Drawing.StringAlignment.Near,
                Authenticity = DivergenceAuthenticity.Lax,
                Background   = DivergenceBackground.None,
                Escape       = DivergenceEscape.NewLines,
                Scale        = DivergenceScale.Small,
                AlignTubes   = false,
                UsePadding   = false,
            };
            string text = null;
            string file = null;

            WriteHeader();
            while (true)
            {
                try {
                    switch (inputIndex)
                    {
                    case 0:
                        do
                        {
                            input = GetInput("Size (s/m/l)", ConsoleColor.Cyan, "l");
                        } while (input != "s" && input != "m" && input != "l");
                        if (input == "s")
                        {
                            dargs.Scale = DivergenceScale.Small;
                        }
                        if (input == "m")
                        {
                            dargs.Scale = DivergenceScale.Medium;
                        }
                        if (input == "l")
                        {
                            dargs.Scale = DivergenceScale.Large;
                        }
                        break;

                    case 1:
                        do
                        {
                            text = GetInput("  Meter Text", ConsoleColor.Yellow);
                        } while (text.Length == 0);
                        break;

                    case 2:
                        do
                        {
                            file = GetInput("Save to File", ConsoleColor.White, GetNextFile());
                            if (file.Any(c => Array.IndexOf(invalidNameChars, c) != -1))
                            {
                                WriteError("  Invalid path characters!");
                                file = null;
                            }
                        } while (file == null);

                        using (var bitmap = Divergence.Draw(text, dargs))
                            bitmap.Save(file, ImageFormat.Png);
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine($"  Saved text \"{text}\" to file \"{file}\"!");
                        Console.ResetColor();

                        do
                        {
                            input = GetInput(" Open? (y/n)", ConsoleColor.White, "n");
                        } while (input != "y" && input != "yes" && input != "n" && input != "no");
                        if (input == "yes" || input == "y")
                        {
                            ProcessStartInfo startInfo = new ProcessStartInfo {
                                FileName        = file,
                                Verb            = "open",
                                UseShellExecute = true,
                            };
                            Process.Start(startInfo)?.Dispose();
                        }

                        WriteHeader();

                        break;
                    }
                    inputIndex = (inputIndex + 1) % 3;
                } catch (BackException) {
                    inputIndex = Math.Max(0, inputIndex - 1);
                } catch (ExitException) {
                    return;
                } catch (Exception ex) {
                    WriteError("  An error occurred!");
                    WriteError(ex);
                    File.WriteAllText("error.txt", ex.ToString());

                    WriteHeader();
                }
            }
        }