private void lineDispatcher_OnFreeStations(object sender, DispatcherStationArgs e) { try { if (productBuffer.Count == 0) { this.fillProductBuffer(); this.fillProductBufferFromInbox(); } if (this.productBuffer.Count > 0) { Product productInBuffer = this.productBuffer.Peek(); List <string> stationNames = productInBuffer.Router.NextStationNames(productInBuffer.Router.State); foreach (string stName in stationNames) { if (stName == e.Station.Name) { this.loadProductOnLine(); } } } } catch (Exception ex) { this.myLog.LogAlert(AlertType.Error, id.ToString(), this.GetType().ToString(), "lineDispatcher_OnFreeStations()", ex.Message, "system"); this.myLog.LogAlert(AlertType.Error, id.ToString(), this.GetType().ToString(), "lineDispatcher_OnFreeStations()", ex.StackTrace.ToString(), "system"); } }
private void LineStation_onFinished(object sender, DispatcherStationArgs e) { Timer timer = new Timer(); timer.Interval = FINISH_TIMEOUT; timer.Elapsed += new ElapsedEventHandler((_s, _e) => { timer.Stop(); timer.Dispose(); this.BitState = this.BitState | (int)BSFlag.Finished; this.finishPublished = true; if (this.OnFinished != null) { this.OnFinished(this, new DispatcherStationArgs() { Product = e.Product, Station = e.Station }); } //if (this.OnFinished != null) // EventQueue<object>.Add(this.OnFinished, this, new DispatcherStationArgs() { Product = e.Product, Station = e.Station }); }); timer.Start(); }
private void station_OnFree(object sender, DispatcherStationArgs e) { if (this.moveType == MoveType.Async) { try { this.myLog.LogAlert(AlertType.System, id.ToString(), this.GetType().ToString(), "station_OnFree()", String.Format("{0} - OnFree() opened.", e.Station.Name), "system"); Product waitingProduct = null; List <IStation> waitingStations = this.findWatingProducts(e.Station); if (waitingStations != null && waitingStations.Count > 0) { foreach (IStation waitingStation in waitingStations) { waitingProduct = waitingStation.CurrentProduct; if (waitingProduct != null) { this.MoveProduct(waitingProduct, waitingStation); } else { // } } } else { if (this.OnFreeStations != null) { this.OnFreeStations(this, new DispatcherStationArgs() { Product = null, Station = e.Station }); } } //this.myLog.LogAlert(AlertType.System, id.ToString(), this.GetType().ToString(), "station_OnFree()", // String.Format("{0} - OnFree() closed.", e.Station.Name), "system"); } catch (Exception ex) { Console.WriteLine(ex); this.myLog.LogAlert(AlertType.Error, id.ToString(), this.GetType().ToString(), "station_OnFree()", ex.Message, "system"); this.myLog.LogAlert(AlertType.Error, id.ToString(), this.GetType().ToString(), "station_OnFree()", ex.StackTrace.ToString(), "system"); } } }
private void station_OnFinished(object sender, DispatcherStationArgs e) { try { Console.WriteLine(String.Format("{0} {1} - OnFinised opened.", DateTime.Now.ToString(), e.Station.Name)); this.myLog.LogAlert(AlertType.System, id.ToString(), this.GetType().ToString(), "station_OnFinished()", String.Format("{0} - OnFinised opened.", e.Station.Name), "system"); if (e.Product != null) { if (this.moveType == MoveType.Async) { bool isAnyNextState = (e.Product.Router.FindNextState(e.Station.Name) != ""); if (isAnyNextState) { this.MoveProduct(e.Product, e.Station); } else { e.Station.ResetFinish(); this.myLog.LogAlert(AlertType.System, id.ToString(), this.GetType().ToString(), "station_OnFinished()", String.Format("{0} finish button reset! {1}", e.Station.Name, e.Product.Name), "system"); } } } else { Console.WriteLine(String.Format("Error! Station: {0} - product is null!", e.Station.Name)); } //Console.WriteLine(String.Format("{0} {1} - OnFinised closed.", DateTime.Now.ToString(), e.Station.Name)); //this.myLog.LogAlert(AlertType.System, id.ToString(), this.GetType().ToString(), "station_OnFinished()", // String.Format("{0} - OnFinised closed.", e.Station.Name), "system"); } catch (Exception ex) { this.myLog.LogAlert(AlertType.Error, id.ToString(), this.GetType().ToString(), "station_OnFinished()", String.Format("{0} - OnFinised exception: {1}", e.Station.Name, ex.ToString()), "system"); } }