Beispiel #1
0
        static public void ResetAllCases()
        {
            Bitmap screenBmp = null;

            for (byte i = 1; i <= 64; i++)
            {
                screenBmp = ToolBoard.TakePictureCaseColor(i);
                m_dictColorCases[i].Dispose();
                m_dictColorCases[i]     = screenBmp;
                m_DateFirstHitNoCase[i] = default(DateTime);
            }
        }
Beispiel #2
0
        static private void InitGrapheCases()
        {
            Bitmap screenColorBmp = null;

            m_dictColorCases.Clear();

            for (byte i = 1; i <= 64; i++)
            {
                // couleur de la case
                screenColorBmp = ToolBoard.TakePictureCaseColor(i);
                m_dictColorCases.Add(i, screenColorBmp);
                m_DateFirstHitNoCase[i] = default(DateTime);
            }
        }
Beispiel #3
0
        /*
         * Si la piece a ete deplacee il peut arriver que le Web Service n'est pas encore scannee la case et retourne
         * la date de defaut (indiquant que la piece n'a pas ete deplacee encore). Il peut y avoir un decalage d'une seconde ou deux
         * avec le l'application Interface. La mise a jour apres que le Web Service l'ai detecté. On attends donc qu'il
         * l'ai identifié
         */
        static public void SetFirstHit(byte nocase, DateTime def = default(DateTime))
        {
            byte     count = 0;
            DateTime test  = def;

            // Attends que la mise a jour se fasse avant de refaire la mise a jour
            while (test == def && count < 5)
            {
                if (count > 0)
                {
                    Thread.Sleep(1000);
                    File.AppendAllText(@GlobalFile.Log, DateTime.Now.ToString() + "\tWaiting Update..." + Environment.NewLine);
                }
                test = m_DateFirstHitNoCase[nocase];
                count++;
            }

            File.AppendAllText(@GlobalFile.Log, DateTime.Now.ToString() + "\tCase = " + nocase + "\t\tXXX" + Environment.NewLine);

// Ne jamais deplace ces 3 lignes
            m_dictColorCases[nocase].Dispose();
            m_dictColorCases[nocase]     = ToolBoard.TakePictureCaseColor(nocase);
            m_DateFirstHitNoCase[nocase] = def;
        }
Beispiel #4
0
        static private void bw_RunningSquare_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Bitmap    screenBmp    = null;
            byte      i            = 0;
            Stopwatch watch        = null;
            byte      nbCharOnLine = 0;

            while (!m_stopRunning)
            {
                if (!m_Suspend)
                {
                    m_Suspended = false;
                    if (watch != null)
                    {
                        watch.Stop();
                        watch = null;
                    }
                    for (i = 1; i <= 64; i++)
                    {
                        screenBmp = ToolBoard.TakePictureCaseColor(i);
                        if (screenBmp == null)
                        {
                            continue;
                        }

                        if (!ToolBoard.CompareBitmaps((Image)screenBmp, (Image)m_dictColorCases[i]))
                        {
                            if (m_DateFirstHitNoCase[i] == default(DateTime))
                            {
                                File.AppendAllText(@GlobalFile.Log, DateTime.Now.ToString() + "\tCase = " + i + "\t\t\t" + m_DateFirstHitNoCase[i] + Environment.NewLine);
                                m_DateFirstHitNoCase[i] = DateTime.Now;
                                m_dictColorCases[i].Dispose();
                                m_dictColorCases[i] = screenBmp;
                            }
                        }
                    }
                }
                else
                {
                    if (watch == null)
                    {
                        watch = Stopwatch.StartNew();
                    }

                    long elapsedMs = watch.ElapsedMilliseconds;
                    if (elapsedMs > 60000) // 1 minute
                    {
                        if (nbCharOnLine > 200)
                        {
                            File.AppendAllText(@GlobalFile.Log, "." + Environment.NewLine);
                            nbCharOnLine = 0;
                        }
                        else
                        {
                            File.AppendAllText(@GlobalFile.Log, ".");
                            nbCharOnLine++;
                        }


                        watch.Stop();
                        watch = Stopwatch.StartNew();
                    }

                    m_Suspended = true;
                }
            }
        }