Ejemplo n.º 1
0
            public static Tuple <List <ligne>, Dictionary <string, sectionCercle> > genererLignes(Dictionary <string, List <string> > flux, ref Random r)
            {
                List <ligne> retour = new List <ligne>();

                Dictionary <string, sectionCercle> sections = sectionCercle.genererSections(flux, ref r);

                Console.WriteLine("Enregistrement des lignes");
                int n = 0;

                foreach (KeyValuePair <string, List <string> > kvp in flux)
                {
                    string motCible = kvp.Key;
                    foreach (string motSource in kvp.Value)
                    {
                        if (sections.ContainsKey(motSource))
                        {
                            ligne nl = new ligne(sections[motSource].getTetaOutput(), sections[motCible].getTetaInput(), sections[motSource].couleur);
                            retour.Add(nl);
                            sections[motCible].nbInputReel++;
                            sections[motSource].nbOutputReel++;
                        }
                    }
                    n++;
                    Console.WriteLine(n + " " + flux.Keys.Count);
                }
                return(new Tuple <List <ligne>, Dictionary <string, sectionCercle> >(retour, sections));
            }
Ejemplo n.º 2
0
        static Bitmap diagCirculaire(Dictionary <string, List <string> > flux, int Dim, int R0, int R1, int R2, string font, int maxFont)
        {
            Bitmap retour = new Bitmap(Dim, Dim);
            Random r      = new Random();
            Tuple <List <ligne>, Dictionary <string, sectionCercle> > precalc = ligne.genererLignes(flux, ref r);
            List <ligne> lignes = precalc.Item1;
            Dictionary <string, sectionCercle> sections = precalc.Item2;

            using (Graphics gr = Graphics.FromImage(retour))
            {
                int        nbAttaches       = getNbAttaches(flux);
                int        largeurConnexion = (int)((Math.PI * 2.0 * R1) / (double)nbAttaches);
                double     shiftAngle       = (largeurConnexion / 2.0) / (R1);
                List <int> indices          = new List <int>();
                for (int i = 0; i < lignes.Count; i++)
                {
                    indices.Add(i);
                }
                for (int n = 0; n < lignes.Count; n++)
                {
                    int randsel   = r.Next(indices.Count);
                    int indselect = indices.ElementAt(randsel);
                    indices.RemoveAt(randsel);
                    ligne    l   = lignes.ElementAt(indselect);
                    PointF   p0  = new PointF((float)(Math.Cos(l.teta0 + shiftAngle) * R1 + Dim / 2), (float)(Math.Sin(l.teta0 + shiftAngle) * R1 + Dim / 2));
                    PointF   p0_ = new PointF((float)(Math.Cos(l.teta0 + shiftAngle) * (R1 + R0) / 2.0 + Dim / 2), (float)(Math.Sin(l.teta0 + shiftAngle) * (R1 + R0) / 2.0 + Dim / 2));
                    PointF   p2_ = new PointF((float)(Math.Cos(l.teta1 + shiftAngle) * (R1 + R0) / 2.0 + Dim / 2), (float)(Math.Sin(l.teta1 + shiftAngle) * (R1 + R0) / 2.0 + Dim / 2));
                    PointF   p2  = new PointF((float)(Math.Cos(l.teta1 + shiftAngle) * R1 + Dim / 2), (float)(Math.Sin(l.teta1 + shiftAngle) * R1 + Dim / 2));
                    Pen      pen = new Pen(l.couleur, largeurConnexion);
                    PointF[] pts = new PointF[] { p0, p0_, p2_, p2 };
                    gr.DrawBeziers(pen, pts);
                    Console.WriteLine(n + " " + lignes.Count);
                }
                int epaisseurCercle = R2 - R1;
                int coteCarre       = R2 * 2 - epaisseurCercle;

                double    angleMin = 360.0 * 2.0 / (R1 * Math.PI * 2.0);
                Rectangle rect     = new Rectangle((Dim - coteCarre) / 2, (Dim - coteCarre) / 2, coteCarre, coteCarre);
                int       u        = 0;
                Console.WriteLine("Sections");
                foreach (KeyValuePair <string, sectionCercle> kvp in sections)
                {
                    u++;
                    Pen   pen  = new Pen(kvp.Value.couleur, epaisseurCercle);
                    float swap = (float)Math.Max(rad2Deg(kvp.Value.tetaF - kvp.Value.tetaI), angleMin);
                    gr.DrawArc(pen, rect, (float)(rad2Deg(kvp.Value.tetaI)), swap);
                    ecrireSecteurAngulaire(gr, kvp.Value.tetaI, kvp.Value.tetaF, (R2 + R1) / 2, InverserCouleur(kvp.Value.couleur), kvp.Key, font, maxFont, Dim);
                    Console.WriteLine(u + " " + sections.Count);
                }
            }
            return(retour);
        }
Ejemplo n.º 3
0
        //Ecrire sur les virtual inputs
        private void WriteIED(CancellationToken token)
        {
            if (token.IsCancellationRequested)
            {
                toolStatus.Text = "Cancellation thrown"; return;
            }
            if (IEDConnected)
            {
                try
                {
                    ligne line = new ligne();
                    if (!Dbisopen)
                    {
                        Opendb();
                    }
                    string sql = "select * from vinTable";
                    cmd = new SQLiteCommand(sql, database_connection);

                    using (SQLiteDataReader read = cmd.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            line._val  = ToBool(read.GetInt32(1));
                            line._name = read.GetString(0);
                            ConnectToIED.WriteValue("GEDeviceF650/vinGGIO1." + line._name + "", FunctionalConstraint.CF, new MmsValue(line._val));
                        }
                    }
                    //Closedb();
                }
                catch (Exception er)
                {
                    toolStatus.Text = er.Message;
                    IEDCancelation.Cancel();
                }
            }
            else
            {
                toolStatus.Text = "IED Disconnected";
            }
        }