Exemplo n.º 1
0
        private void scannerDataReceived(object sender, EventArgs e)
        {
            if (this.InvokeRequired)
            {
                UpdateControls delegado = new UpdateControls(AssociateExamOrStudent);
                this.BeginInvoke(delegado);

                // AssociateExamToStudent();
            }
            else
            {
                AssociateExamOrStudent();
            }
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            FileName = "";
            StopFlag = false;
            OnData             onData       = new OnData(OnDataReceived);
            OnMessageReadyToTx onMsgRead4Tx = new OnMessageReadyToTx(OnMsgRead4Tx);
            OnEnd onEnd = new OnEnd(OnTransationEnd);

            try
            {
                receiverPackLib = new ReceiverPackLib.ReceiverPackLib(onData, onEnd, null, onMsgRead4Tx);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Fatal");
            }
            updateStatus   = new UpdateStatus(Update_Status);
            updateControls = new UpdateControls(Update_Controls);
            Disposed      += new EventHandler(Form1_Disposed);
        }
Exemplo n.º 3
0
        public TCPServerUnity(int port, DebugLogDelegate pLogDelegate, UpdateControls pUpMotors, Object pLock)
        {
            // Set Delegate to log
            mDebug += pLogDelegate;

            // Set Delegate to update Motors values
            mUpdateControls += pUpMotors;

            stopListen = false;

            // Set the lock between threads (Defined on the unity script)
            thisLock = pLock;

            // Create TcpListerner object
            this.tcpListener = new TcpListener(IPAddress.Any, port);

            // Doing like this we're not going to block ...
            this.listenThread = new Thread(new ThreadStart(ListenForClients));

            // Start thread
            this.listenThread.Start();
        }
Exemplo n.º 4
0
        void DoTest(object arg)
        {
            string         fileName       = (string)arg;
            UpdateControls updateControls = new UpdateControls(Update_Controls);

            if (File.Exists("received_file"))
            {
                File.Delete("received_file");
            }
            FileStream fs = File.OpenRead(fileName);

            if (fs == null)
            {
                return;
            }
            byte[] raw_file = new byte[fs.Length];
            if (fs.Read(raw_file, 0, raw_file.Length) != raw_file.Length)
            {
                return;
            }
            fs.Close();
            fs = null;
            DateTime initialStamp, finishStamp;
            bool     firstIteration = true;
            ulong    ticks_sum      = 0;
            ulong    iterations     = 0;

            byte[] buf;

            OnData onData = new OnData(OnDataReceived);
            OnEnd  onEnd  = new OnEnd(OnTransactionEnd);

            do
            {
                initialStamp = DateTime.Now;
                buf          = raw_file;

                if (File.Exists("received_file"))
                {
                    File.Delete("received_file");
                }

                ReceiverPackLib.ReceiverPackLib receiverPackLib = new ReceiverPackLib.ReceiverPackLib(onData, onEnd, null);
                SenderPackLib.SenderPackLib     senderPackLib   = new SenderPackLib.SenderPackLib(buf);
                senderPackLib.AddData(buf, false);
#if false
                senderPackLib.AddLast();
                bool SameChunk;
                while ((buf = senderPackLib.GetChunk(out SameChunk)) != null)
                {
                    byte[] predMsg = receiverPackLib.ReceiverOnData(buf, 0);
                    if (predMsg != null)
                    {
                        byte[] predAckMsg = senderPackLib.SenderOnData(predMsg, 0);
                        receiverPackLib.ReceiverOnData(predAckMsg, 0);
                    }
                }
#endif
                finishStamp = DateTime.Now;
                object[] args = new object[4];
                args[0] = firstIteration;
                if (firstIteration)
                {
                    args[1]        = (ulong)(finishStamp.Ticks - initialStamp.Ticks);
                    firstIteration = false;
                }
                else
                {
                    ticks_sum += (ulong)(finishStamp.Ticks - initialStamp.Ticks);
                    iterations++;
                    args[1] = ticks_sum / iterations;
                }
                args[2] = (ulong)iterations;
                args[3] = true;
                Invoke(updateControls, args);
                while (checkBoxPause.Checked)
                {
                    Thread.Sleep(1000);
                }
            } while (checkBoxDoUntilStopped.Checked);
        }
Exemplo n.º 5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     updateControls = new UpdateControls(Update_Controls);
     Disposed += new EventHandler(Form1_Disposed);
 }
Exemplo n.º 6
0
        void DoTest(object arg)
        {
            string fileName = (string)arg;
            UpdateControls updateControls = new UpdateControls(Update_Controls);
            if (File.Exists("received_file"))
            {
                File.Delete("received_file");
            }
            FileStream fs = File.OpenRead(fileName);
            if (fs == null)
            {
                return;
            }
            byte[] raw_file = new byte[fs.Length];
            if (fs.Read(raw_file, 0, raw_file.Length) != raw_file.Length)
            {
                return;
            }
            fs.Close();
            fs = null;
            DateTime initialStamp,finishStamp;
            bool firstIteration = true;
            ulong ticks_sum = 0;
            ulong iterations = 0;
            byte[] buf;

            OnData onData = new OnData(OnDataReceived);
            OnEnd onEnd = new OnEnd(OnTransactionEnd);

            do
            {
                initialStamp = DateTime.Now;
                buf = raw_file;

                if (File.Exists("received_file"))
                {
                    File.Delete("received_file");
                }

                ReceiverPackLib.ReceiverPackLib receiverPackLib = new ReceiverPackLib.ReceiverPackLib(onData,onEnd,null);
                SenderPackLib.SenderPackLib senderPackLib = new SenderPackLib.SenderPackLib(buf);
                senderPackLib.AddData(buf,false);
            #if false
                senderPackLib.AddLast();
                bool SameChunk;
                while ((buf = senderPackLib.GetChunk(out SameChunk)) != null)
                {
                    byte[] predMsg = receiverPackLib.ReceiverOnData(buf,0);
                    if (predMsg != null)
                    {
                        byte[] predAckMsg = senderPackLib.SenderOnData(predMsg, 0);
                        receiverPackLib.ReceiverOnData(predAckMsg, 0);
                    }
                }
            #endif
                finishStamp = DateTime.Now;
                object[] args = new object[4];
                args[0] = firstIteration;
                if (firstIteration)
                {
                    args[1] = (ulong)(finishStamp.Ticks - initialStamp.Ticks);
                    firstIteration = false;
                }
                else
                {
                    ticks_sum += (ulong)(finishStamp.Ticks - initialStamp.Ticks);
                    iterations++;
                    args[1] = ticks_sum / iterations;
                }
                args[2] = (ulong)iterations;
                args[3] = true;
                Invoke(updateControls, args);
                while (checkBoxPause.Checked)
                {
                    Thread.Sleep(1000);
                }
            } while (checkBoxDoUntilStopped.Checked);
        }
Exemplo n.º 7
0
 private void Form1_Load(object sender, EventArgs e)
 {
     updateControls = new UpdateControls(Update_Controls);
     Disposed      += new EventHandler(Form1_Disposed);
 }