public static Response CreateResponse(string notification, IHubController controller)
        {
            var messageType = MessageTypes.GetByCode(notification.Substring(4, 2));

            if (messageType == MessageTypes.HubProperty)
            {
                return(HandleHubProperty(controller, notification));
            }
            if (messageType == MessageTypes.HubAction)
            {
                return(new HubActionResponse(notification));
            }
            if (messageType == MessageTypes.Error)
            {
                return(new Error(notification));
            }
            if (messageType == MessageTypes.HubAttachedDetachedIO)
            {
                return(HandleIOConnectionStateChange(controller, notification));
            }
            if (messageType == MessageTypes.PortInformation)
            {
                return(new PortInfo(notification));
            }
            if (messageType == MessageTypes.PortModeInformation)
            {
                return(new PortModeInfo(notification));
            }
            if (messageType == MessageTypes.PortValueSingle)
            {
                return(HandlePortValueUpdate(controller, notification));
            }
            if (messageType == MessageTypes.PortInputFormatSingle)
            {
                return(HandleNotificationStateUpdate(controller, notification));
            }
            if (messageType == MessageTypes.PortOutputFeedback)
            {
                return(new PortOutputFeedback(notification));
            }

            return(new Response(notification));
        }
        public Error(string body) : base(body)
        {
            var failedCommandType = MessageTypes.GetByCode(Body.Substring(6, 2));

            if (failedCommandType == MessageTypes.HubProperty)
            {
                FailedCommandType = "Device Info";
            }
            if (failedCommandType == MessageTypes.HubAction)
            {
                FailedCommandType = "Hub Action";
            }

            var errorType = Body.Substring(8, 2);

            ErrorType = errorType switch
            {
                "05" => "Command Not Recognized",
                "06" => "Invalid Use",
                _ => "Unknown",
            };
            NotificationType = GetType().Name;
        }