Example #1
0
        public void SendInterrupted(string message)
        {
            if (lockStatus != PrinterConnection.LockStatus.Locked)
            {
                return;
            }

            BroadcastServer.SendMessageToClient(clientID, message);
        }
Example #2
0
        public void BroadcastPluginMessage(SpoolerMessage message)
        {
            if (message.Type != MessageType.PluginMessage)
            {
                return;
            }

            if (clientID != Guid.Empty)
            {
                BroadcastServer.SendMessageToClient(clientID, message.Serialize());
            }
            else
            {
                BroadcastServer.BroadcastMessage(message.Serialize());
            }
        }
Example #3
0
        private bool ProcessConnectedPrinter()
        {
            try
            {
                if (Status == PrinterStatus.Error_PrinterNotAlive)
                {
                    return(false);
                }

                if (!IsOpen)
                {
                    Status = PrinterStatus.Error_PrinterNotAlive;
                }

                BaseController controllerSelf = ControllerSelf;
                if (controllerSelf != null)
                {
                    controllerSelf.DoConnectionLogic();
                    if (!controllerSelf.IsWorking || Status == PrinterStatus.Firmware_PrintingPaused)
                    {
                        var num = CurrentRPC_id.Value;
                        if (num != 0U && (int)num != (int)Info.synchronization.LastCompletedRPCID)
                        {
                            Info.synchronization.LastCompletedRPCID = num;
                        }
                    }
                    else
                    {
                        lock (lockResetTimer)
                        {
                            if (lockResetTimer.IsRunning)
                            {
                                lockResetTimer.Restart();
                            }
                        }
                    }
                    if (lockStatus == PrinterConnection.LockStatus.Pending && Status != PrinterStatus.Connecting && (!controllerSelf.IsWorking && !controllerSelf.IsPrinting || Status == PrinterStatus.Firmware_PrintingPaused))
                    {
                        lockStatus = PrinterConnection.LockStatus.Locked;
                        Info.synchronization.Locked = true;
                        BroadcastServer.SendMessageToClient(clientID, new SpoolerMessage(MessageType.LockConfirmed, Info.serial_number, lockID.ToString()).Serialize());
                    }
                    if (controllerSelf.Idle && lockStatus == PrinterConnection.LockStatus.Locked)
                    {
                        lock (lockResetTimer)
                        {
                            if (!lockResetTimer.IsRunning)
                            {
                                lockResetTimer.Restart();
                            }

                            if (lockResetTimer.Elapsed.TotalSeconds > 30.0)
                            {
                                DoBreakLock();
                            }
                        }
                    }
                    else
                    {
                        lock (lockResetTimer)
                        {
                            if (lockResetTimer.IsRunning)
                            {
                                lockResetTimer.Stop();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.ToString().ToLower() != "unable to write program memory.  the serial port is not open.")
                {
                    ErrorLogger.LogException("PrinterConnection Exception", ex);
                }

                Shutdown();
                return(false);
            }
            return(true);
        }
Example #4
0
 private void DoBreakLock()
 {
     BroadcastServer.SendMessageToClient(clientID, new SpoolerMessage(MessageType.LockResult, Info.serial_number, 0.ToString("D8") + CommandResult.LockLost_TimedOut.ToString()).Serialize());
     var num = (int)ReleaseLock(lockID);
 }