Ejemplo n.º 1
0
        private bool IsListReady(uint count)
        {
            if (this.CtlGetStatus(RtcStatus.Aborted))
            {
                return(false);
            }
            const uint RTC5_LIST_BUFFER_MAX = 4000;

            if ((this.listCount + count) >= RTC5_LIST_BUFFER_MAX)
            {
                uint busy, position;
                busy = position = 0;
                RTC5Wrap.n_get_status(this.Index + 1, out busy, out position);
                if (0 != busy)
                {
                    RTC5Wrap.n_set_end_of_list(this.Index + 1);
                    RTC5Wrap.n_execute_list(this.Index + 1, this.listIndex);
                    this.listIndex = this.listIndex ^ 0x03;
                    RTC5Wrap.n_set_start_list(this.Index + 1, this.listIndex);
                }
                else
                {
                    RTC5Wrap.n_set_end_of_list(this.Index + 1);
                    if (this.CtlGetStatus(RtcStatus.Aborted))
                    {
                        return(false);
                    }

                    RTC5Wrap.n_auto_change(this.Index + 1);
                    uint readStatus = 0;
                    switch (this.listIndex)
                    {
                    case 1:
                        do
                        {
                            readStatus = RTC5Wrap.n_read_status(this.Index + 1);
                            System.Threading.Thread.Sleep(1);
                        }while (Convert.ToBoolean(readStatus & 0x20));
                        break;

                    case 2:
                        do
                        {
                            readStatus = RTC5Wrap.n_read_status(this.Index + 1);
                            System.Threading.Thread.Sleep(1);
                        }while (Convert.ToBoolean(readStatus & 0x10));
                        break;
                    }
                    if (this.CtlGetStatus(RtcStatus.Aborted))
                    {
                        return(false);
                    }
                    this.listIndex = this.listIndex ^ 0x03;
                    RTC5Wrap.n_set_start_list(this.Index + 1, this.listIndex);
                }
                this.listCount = count;
            }
            this.listCount += count;
            return(true);
        }
Ejemplo n.º 2
0
        public bool CtlGetStatus(RtcStatus status)
        {
            bool result = false;
            uint busy, position;

            busy = position = 0;
            switch (status)
            {
            case RtcStatus.Busy:
                RTC5Wrap.n_get_status(this.Index + 1, out busy, out position);
                result = Convert.ToBoolean(busy > 0);
                break;

            case RtcStatus.NotBusy:
                result = !this.CtlGetStatus(RtcStatus.Busy);
                break;

            case RtcStatus.List1Busy:
                uint l1Status = RTC5Wrap.n_read_status(this.Index + 1);
                result = Convert.ToBoolean(l1Status & 0x0F);
                break;

            case RtcStatus.List2Busy:
                uint l2Status = RTC5Wrap.n_read_status(this.Index + 1);
                result = Convert.ToBoolean(l2Status & 0x10);
                break;

            case RtcStatus.NoError:
                bool aborted   = this.CtlGetStatus(RtcStatus.Aborted);
                uint lastError = RTC5Wrap.n_get_last_error(this.Index + 1);
                bool error     = 0 != lastError;
                result = !aborted && !error;
                break;

            case RtcStatus.Aborted:
                result = this.aborted;
                break;

            case RtcStatus.PositionAckOK:
                uint posAckStatus = RTC5Wrap.n_get_head_status(this.Index + 1, 1);
                result = Convert.ToBoolean(posAckStatus & 0x0F + posAckStatus & 0x10);
                break;

            case RtcStatus.PowerOK:
                uint powStatus = RTC5Wrap.n_get_head_status(this.Index + 1, 1);
                result = Convert.ToBoolean(powStatus & 0x80);
                break;

            case RtcStatus.TempOK:
                uint tempStatus = RTC5Wrap.n_get_head_status(this.Index + 1, 1);
                result = Convert.ToBoolean(tempStatus & 0x40);
                break;
            }
            return(result);
        }