コード例 #1
0
ファイル: rtc6.cs プロジェクト: li1794/rtclib
        public bool CtlGetStatus(RtcStatus status)
        {
            bool result = false;
            uint busy, position;

            busy = position = 0;
            switch (status)
            {
            case RtcStatus.Busy:
                RTC6Wrap.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 = RTC6Wrap.n_read_status(this.Index + 1);
                result = Convert.ToBoolean(l1Status & 0x0F);
                break;

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

            case RtcStatus.NoError:
                bool aborted   = this.CtlGetStatus(RtcStatus.Aborted);
                uint lastError = RTC6Wrap.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 = RTC6Wrap.n_get_head_status(this.Index + 1, 1);
                result = Convert.ToBoolean(posAckStatus & 0x0F + posAckStatus & 0x10);
                break;

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

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