Beispiel #1
0
        private void WriteOut_Main(string data, FanucSocketOptions options)
        {
            FanucChunk[] chunks;

            opCancelToken.ThrowIfCancellationRequested();

            WriteOut_Prepare(out chunks, ref data, options);

            bool OkayToSend = false;
            int  lastCode   = 0;
            int  cId        = 0;

            ChangeState(FanucSocketState.Waiting);

            while (cId < chunks.Length)
            {
                lastCode = WriteOut_GetCode();

                if ((lastCode == 0x11) && !OkayToSend)
                {
                    OkayToSend = true; //Got DC1, Cleared to send
                    ChangeState(FanucSocketState.Sending);
                }
                else if ((lastCode == 0x13) && OkayToSend)
                {
                    OkayToSend = false; //Got DC3, Pause until its cleared
                    ChangeState(FanucSocketState.Waiting);
                }

                if (OkayToSend)
                {
                    WriteOut_SendChunk(chunks[cId]);
                    cId++;

                    if (ChunkSent != null)
                    {
                        ChunkSent.Invoke(this, Math.Round((cId / (double)chunks.Length) * 100, 1));
                    }
                }

                //opCancelToken.ThrowIfCancellationRequested();

                Thread.Sleep(SendDelay);

                opCancelToken.ThrowIfCancellationRequested();
            }

            bool isWaiting = true;
            int  tempTimer = 0;

            while (isWaiting)
            {
                lastCode = WriteOut_GetCode();

                if ((lastCode == 0x13) || tempTimer >= 30)
                {
                    isWaiting = false;
                }

                tempTimer++;
                Thread.Sleep(1000);

                opCancelToken.ThrowIfCancellationRequested();
            }

            opCancelToken.ThrowIfCancellationRequested();
        }
 private void OnChunkSent(long coda)
 {
     ChunkSent?.Invoke(coda); OnChunkProcceeded(coda);
 }
Beispiel #3
0
 private void OnChunkSent(long coda)
 {
     ChunkSent?.Invoke(coda);
 }