Exemplo n.º 1
0
Arquivo: Printer.cs Projeto: urish/M3D
 private Printer(PrinterProfile profile, SpoolerClient client)
 {
     this.client             = client;
     mylockID                = Guid.Empty;
     m_printer_profile.Value = profile;
     thread_sync             = new object();
     spool_lock              = new object();
     spool_up_to_date        = false;
     incoming_data           = null;
     Found = new ThreadSafeVariable <bool>
     {
         Value = false
     };
     _connected = new ThreadSafeVariable <bool>
     {
         Value = false
     };
     log                       = new CircularArray <string>(200);
     LogWaits                  = true;
     LogFeedback               = true;
     waiting_object            = null;
     waiting_object_lock       = new object();
     lockstatus                = new ThreadSafeVariable <PrinterLockStatus>(PrinterLockStatus.Unlocked);
     lockstepmode              = new ThreadSafeVariable <bool>(true);
     lockTimeOutSeconds        = new ThreadSafeVariable <int>(0);
     keeplockalive_clock       = new Stopwatch();
     keeplockalive_limit_clock = new Stopwatch();
     finished_lock             = new object();
     m_ChangedKeyValuePairs    = new ConcurrentDictionary <string, string>();
 }
Exemplo n.º 2
0
        public Logger(ThreadSafeVariable <bool> shared_shutdown, string printer_serial)
        {
            this.shared_shutdown = shared_shutdown;
            string path2;

            if (!string.IsNullOrEmpty(printer_serial))
            {
                _printerSerial = new ThreadSafeVariable <string>(printer_serial);
                path2          = printer_serial + "--" + DateTime.Now.ToString("yyyy-MM-dd_H-mm-ss") + ".txt";
            }
            else
            {
                _printerSerial = new ThreadSafeVariable <string>("Detecting");
                path2          = Guid.NewGuid().ToString() + ".txt";
            }
            _logFile     = Path.Combine(Paths.LogPath, path2);
            _logReads    = new ThreadSafeVariable <bool>(true);
            _logWrites   = new ThreadSafeVariable <bool>(true);
            _logWaits    = new ThreadSafeVariable <bool>(false);
            _logToFile   = new ThreadSafeVariable <bool>(true);
            _logFeedback = new ThreadSafeVariable <bool>(false);
            _logToScreen = new ThreadSafeVariable <bool>(true);
            _buffer      = new List <string>();
            _writeThread = new Thread(new ThreadStart(WriteThread))
            {
                IsBackground = true,
                Name         = "Write Log"
            };
            _writeThread.IsBackground = true;
            _fileLock                 = new object();
            _file                     = null;
            _writeThread.Priority     = ThreadPriority.Lowest;
            _writeThread.IsBackground = true;
            _writeThread.Start();
        }
Exemplo n.º 3
0
 public ConnectionMeter(ConnectionMeter.Mode mode, uint firmwareCodeBufferSize)
 {
     this.firmwareCodeBufferSize = firmwareCodeBufferSize;
     _delayMode             = new ThreadSafeVariable <ConnectionMeter.Mode>(mode);
     OKsBeforeRSSampleData  = new SampleSet(20);
     TimeBeforeRSSampleData = new SampleSet(20);
 }
Exemplo n.º 4
0
 private void OnPrinterConnectionManagerStopped(object sender, ThreadSafeVariable <bool> shared_shutdown)
 {
     foreach (KeyValuePair <string, PrinterConnection> printer in printers)
     {
         printer.Value.Shutdown();
     }
 }
Exemplo n.º 5
0
 private void InitConnection()
 {
     shared_shutdown               = new ThreadSafeVariable <bool>(false);
     internal_logger               = new Logger(shared_shutdown);
     printerInfo                   = new PrinterInfo();
     CurrentRPC_id.Value           = printerInfo.synchronization.LastCompletedRPCID = (uint)(SpoolerServer.RandomGenerator.Next() % byte.MaxValue);
     printerInfo.hardware.com_port = _safeSerialPort.PortName;
     Info.serial_number            = PrinterSerialNumber.Undefined;
     Status     = PrinterStatus.Uninitialized;
     lockID     = Guid.Empty;
     clientID   = Guid.Empty;
     lockStatus = PrinterConnection.LockStatus.Unlocked;
     lock_sync  = new object();
 }
Exemplo n.º 6
0
 public SpoolerServer()
 {
     shared_shutdown       = new ThreadSafeVariable <bool>(false);
     profile_dictionary    = new PrinterProfileDictionary();
     broadcastserver       = null;
     rpc_invoker           = new RPCInvoker(this);
     thread_sync           = new object();
     printer_handshake     = new object();
     logging_queue         = new List <SpoolerMessage>();
     network_logging_timer = new ThreadBasedTimer(null, shared_shutdown)
     {
         Interval = 100,
         Tick     = new EventHandler(onLogger_Tick)
     };
     network_logging_timer.Start();
 }
Exemplo n.º 7
0
        public void Start(ThreadSafeVariable <bool> shared_shutdown)
        {
            if (runThread != null)
            {
                return;
            }

            runThread = new SharedShutdownThread(new SharedShutdownThreadStart(Run), shared_shutdown)
            {
                DelayBetweenIterations = 600,
                Name            = nameof(PrinterConnectionManager),
                IsBackground    = false,
                OnThreadAborted = new EventHandler <ThreadSafeVariable <bool> >(OnPrinterConnectionManagerStopped)
            };
            runThread.Start();
        }
Exemplo n.º 8
0
 public SpoolerClient(DebugLogger logger)
 {
     MyDebugLogger         = logger;
     thread_sync           = new object();
     tick_sync             = new object();
     new_printer_list_sync = new object();
     HasNewPrinterList     = new ThreadSafeVariable <bool>
     {
         Value = false
     };
     connected_printers   = new List <Printer>();
     connectedSpoolerInfo = new ThreadSafeVariable <SpoolerInfo>(null);
     message_queue        = new ConcurrentQueue <RPCInvoker.RPC>();
     message_thread       = null;
     queue_lock           = new object();
     isprinting_lock      = new object();
 }
Exemplo n.º 9
0
 public SpoolerConnection(PopupMessageBox messagebox, MessagePopUp informationbox, SettingsManager settingsManager)
 {
     this.messagebox      = messagebox;
     this.informationbox  = informationbox;
     this.settingsManager = settingsManager;
     thread_sync          = new object();
     connected_printers   = new List <PrinterObject>();
     PrinterCount         = new ThreadSafeVariable <int>
     {
         Value = 0
     };
     printerIDList    = new List <string>();
     selected_printer = new ThreadSafeVariable <PrinterObject>
     {
         Value = null
     };
     general_log = new CircularArray <string>(200);
 }
Exemplo n.º 10
0
 public Logger(ThreadSafeVariable <bool> shared_shutdown)
     : this(shared_shutdown, null)
 {
 }
Exemplo n.º 11
0
        public BootloaderController(int bootloader_version, PrinterConnection base_printer, PrinterInfo info, Logger logger, ThreadSafeVariable <bool> shared_shutdown, IBroadcastServer broadcastserver, InternalPrinterProfile printerProfile)
            : base(base_printer, info, logger, broadcastserver, printerProfile)
        {
            PersistantDetails.bootloader_version = bootloader_version;
            if (bootloader_version >= 1 && bootloader_version <= 5)
            {
                mInterfaceVersion = BootloaderController.BootloaderInterfaceVersion.V1;
            }
            else
            {
                if (bootloader_version < 6 || bootloader_version > 8)
                {
                    throw new Exception(string.Format("Unsupported Bootloader Interface - {0}", bootloader_version));
                }

                mInterfaceVersion = BootloaderController.BootloaderInterfaceVersion.V2;
            }
            mCheckedFirmwareStatus = new Dictionary <char, BootloaderController.FirmwareStatus>();
            foreach (KeyValuePair <char, FirmwareDetails> firmware in MyPrinterProfile.ProductConstants.FirmwareList)
            {
                mCheckedFirmwareStatus.Add(firmware.Key, BootloaderController.FirmwareStatus.Unknown);
            }

            StartBootloaderMode();
        }