Пример #1
0
        public void ReflectionNotify(ServiceType type, string data)
        {
            var result = JsonConvert.DeserializeObject <DataBoundary>(data);

            var returnedAnswer = result.Attributes.FirstOrDefault(r => r.Key.Equals("Result"));

            if (!returnedAnswer.IsNull())
            {
                NotifyClient?.Invoke(this, returnedAnswer.Value, type);
            }
            else
            {
                NotifyClient?.Invoke(this, result, type);
            }
        }
Пример #2
0
        public void SetClock(SetClockOps SubOp, object ClockData)
        {
            // Local Storage
            int intMode = 0;

            // Validate the input
            switch (SubOp)
            {
            case SetClockOps.CurrentDateTime:
            case SetClockOps.CalendarDateTime:
                HPRequest mReq = GetRequest(PrinterOps.SetClock, (int)SubOp);
                mReq.Data1 = ClockData.ToString();
                IssueRequest(mReq);
                break;

            case SetClockOps.CalendarTimeControl:
            case SetClockOps.TwelveTwentyFour:
                if (int.TryParse(ClockData.ToString(), out intMode))
                {
                    if (intMode == 1 | intMode == 2)
                    {
                        mReq       = GetRequest(PrinterOps.SetClock, (int)SubOp);
                        mReq.Data1 = PadLeftZeros(intMode, 1);
                        IssueRequest(mReq);
                    }
                    else
                    {
                        NotifyClient?.Invoke(this, new HPEventArgs("Invalid Set Clock Mode!"));
                    }
                }
                else
                {
                    NotifyClient?.Invoke(this, new HPEventArgs("Invalid Set Clock Mode!"));
                }
                break;

            default:
                NotifyClient?.Invoke(this, new HPEventArgs("Invalid Set Clock Sub-type!"));
                break;
            }
        }
Пример #3
0
        public void RetrievePattern(RetrievePatternOps SubOp, string Font, int Page, int KbType)
        {
            int[] SizeRX   = new int[] { 8, 8, 8, 16, 16, 32, 32, 72, 128, 32, 5, 5, 7, 200, 288 };
            int[] CountRX  = new int[] { 37, 37, 37, 37, 37, 15 };
            int[] HeaderRX = new int[] { 4, 3 };

            int[] SizePXR = new int[] { 8, 8, 16, 32, 72, 128, 16 };
            int[,] CountPXR = new int[, ] {
                { 45, 45, 38 }, { 46, 44, 0 }
            };
            int[] HeaderPXR = new int[] { 4, 2 };

            // Local Storage
            int intCharSize  = 0;
            int intRcvLength = 0;

            // Translate the font
            intCharSize = GetFont(Font, true)[0] - '0';

            // Was the font invalid
            if (intCharSize < 0)
            {
                NotifyClient?.Invoke(this, new HPEventArgs("Invalid font specified!"));
                return;
            }

            // Is the page number valid
            switch (SubOp)
            {
            case RetrievePatternOps.Standard:
                if (Page < 1 || Page > 3)
                {
                    Page = -1;
                }
                break;

            case RetrievePatternOps.User:
                if (rxClass)
                {
                    if (Page < 1 || Page > 6)
                    {
                        Page = -1;
                    }
                }
                else
                {
                    if (Page < 1 || Page > 3)
                    {
                        Page = -1;
                    }
                }
                break;
            }

            // Is the page number invalid
            if (Page < 0)
            {
                NotifyClient?.Invoke(this, new HPEventArgs("Invalid page number specified!"));
                return;
            }

            // Get the number of characters expected and issue operation
            if (rxClass)
            {
                if (SubOp == RetrievePatternOps.User)
                {
                    intRcvLength = (SizeRX[intCharSize] + HeaderRX[(int)SubOp]) * CountRX[Page - 1] + 2;
                }
                else
                {
                    if (KbType == 1)
                    {
                        if (Page == 2)
                        {
                            intRcvLength = 2;
                        }
                        else
                        {
                            intRcvLength = (SizeRX[intCharSize] + HeaderRX[(int)SubOp]) * 38 + 2;
                        }
                    }
                    else
                    {
                        intRcvLength = (SizeRX[intCharSize] + HeaderRX[(int)SubOp]) * 26 + 2;
                    }
                }
            }
            else
            {
                intRcvLength = (SizePXR[intCharSize] + HeaderPXR[(int)SubOp]) * CountPXR[(int)SubOp, Page - 1] + 2;
            }
            HPRequest mReq = GetRequest(PrinterOps.RetrievePattern, (int)SubOp);

            mReq.CharSize  = intCharSize;
            mReq.Page      = Page;
            mReq.RcvLength = RcvLength;
            mReq.KbType    = KbType;
            mReq.Retries   = 0;
            IssueRequest(mReq);
        }