Esempio n. 1
0
        public void Handle(DirectiveTypeEnum type, DirectiveData data, CommunicationEventArgs comEventArgs)
        {
            OldStatus = Controller.CurrentStatus;

            switch (type)
            {
            case DirectiveTypeEnum.Idle:
                HandleIdle(data, comEventArgs); break;

            case DirectiveTypeEnum.TryStart:
                HandleTryStart(data, comEventArgs); break;

            case DirectiveTypeEnum.Running:
                HandleRunning(data, comEventArgs); break;

            case DirectiveTypeEnum.TryPause:
                HandleTryPause(data, comEventArgs); break;

            case DirectiveTypeEnum.Pausing:
                HandlePausing(data, comEventArgs); break;

            case DirectiveTypeEnum.Close:
                HandleClose(data, comEventArgs); break;

            default:
                HandleError(data, comEventArgs); break;
            }
        }
Esempio n. 2
0
        public static int GetFeedbackLength(this DirectiveTypeEnum dm)
        {
            var len = 0;

            switch (dm)
            {
            case DirectiveTypeEnum.TryStart:
                len = 7;
                break;

            case DirectiveTypeEnum.TryPause:
                len = 7;
                break;

            case DirectiveTypeEnum.Close:
                len = 7;
                break;

            case DirectiveTypeEnum.Idle:
                len = 9;
                break;

            case DirectiveTypeEnum.Running:
                len = 13;
                break;

            case DirectiveTypeEnum.Pausing:
                len = 12;
                break;

            default: break;
            }
            return(len);
//            var enumType = dm.GetType();
//
//            var name = Enum.GetName(enumType, dm);
//            if (null == name) return 0;
//
//            var fi = enumType.GetField(name);
//            if (null == fi) return 0;
//
//            var des = (DirectiveMetaAttribute[])fi.GetCustomAttributes(typeof(DirectiveMetaAttribute), true);
//            return des.FirstOrDefault()?.FeedbackLength ?? 0;
        }
Esempio n. 3
0
        public static int GetDirectiveLength(this DirectiveTypeEnum dm)
        {
            var enumType = dm.GetType();

            var name = Enum.GetName(enumType, dm);

            if (null == name)
            {
                return(0);
            }

            var fi = enumType.GetField(name);

            if (null == fi)
            {
                return(0);
            }

            var des = (DirectiveMetaAttribute[])fi.GetCustomAttributes(typeof(DirectiveMetaAttribute), true);

            return(des.FirstOrDefault()?.DirectiveLength ?? 0);
        }