Ejemplo n.º 1
0
        // Create image temporary & send image to device
        public int SendImg(TextImage img, int effect, int windowNumber)
        {
            m_nWindowNo = windowNumber;
            int ret = 0;

            if (0 == m_nCommType)
            {
                ret = CP5200.CP5200_RS232_SendPicture(m_nCardID, m_nWindowNo, 0, 0, img.Width, img.Height,
                                                      Marshal.StringToHGlobalAnsi(img.path), 0, effect, 3, 0);
            }
            else
            {
                ret = CP5200.CP5200_Net_SendPicture(m_nCardID, m_nWindowNo, 0, 0, img.Width, img.Height,
                                                    Marshal.StringToHGlobalAnsi(img.path), 0, effect, 3, 0);
            }
            return(ret);
        }
Ejemplo n.º 2
0
        private void CallToChildThread()
        {
            try
            {
                MysqlDBConnect mysql = new MysqlDBConnect(tb_hostname.Text, Int32.Parse(tb_port.Text), tb_database.Text, tb_username.Text, tb_password.Text);

                CpowerUse cpu    = null;
                byte      mode   = 1; // 1 is use network
                int       CardID = 1;
                cpu = new CpowerUse(mode, 600, CardID, tb_ip.Text, 5200, tb_idcode.Text);


                while (true)
                {
                    // start thread get data from server
                    List <TemporaryEntity> row = mysql.Select("SELECT * FROM `" + tb_table.Text + "` WHERE ip = '" + tb_ip.Text + "' AND `status` = '1'");

                    if (flag_thread != false)
                    {
                        break;
                    }
                    int i = 0;

                    if (row.Count > 0)
                    {
                        if (row[i].running_text.Contains(';'))
                        {
                            string[] words = row[i].running_text.Split(';');
                            if (words.Count() > 1)
                            {
                                cpu.InitComm(1);
                                // Window 1
                                TextImage tempImg = new TextImage(words[0] + " ", TextImage.defaultFont, Color.Red, Color.Black);
                                cpu.SendImg(tempImg, 0, 0);

                                // remove output image 1
                                try
                                {
                                    File.Delete(tempImg.path);
                                }catch (Exception e)
                                {
                                    Console.WriteLine(e.Message);
                                }

                                // Window 2
                                TextImage tempImg2 = new TextImage(words[1] + " ", TextImage.defaultFont, Color.Red, Color.Black);
                                cpu.SendImg(tempImg2, 0, 1);

                                // remove output image 1
                                try
                                {
                                    File.Delete(tempImg2.path);
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e.Message);
                                }
                            }
                        }
                        else
                        {
                            cpu.InitComm(0);
                            cpu.SendTextToNetwork(row[i].running_text);
                        }

                        mysql.Update("UPDATE `" + tb_table.Text + "` SET `status` = '0' WHERE `id` = '" + row[i].id + "'");
                    }

                    Thread.Sleep(1000);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                enabled_all_element();
            }
            finally
            {
                Console.WriteLine("Couldn't catch the Thread Exception");
            }
        }