#region Namespace using System; using System.Diagnostics; using Asm.As.Oib.Client; using com.itac.mes.proxy.business; using com.itac.oib.client.customextensions; using com.itac.mes.tools; using Constants = com.itac.mes.tools.Constants; using com.itac.oib.siplacepro.contracts.data; using com.itac.oib.traceability.contracts.data; using OibSpiArchObj = Asm.As.Oib.SiplacePro.Proxy.Architecture.Objects; using OibSpiBizObj = Asm.As.Oib.SiplacePro.Proxy.Business.Objects; using OibSpiTypes = Asm.As.Oib.SiplacePro.Proxy.Types; using System.Collections.Generic; #endregion namespace com.itac.oib.siplacepro.service { /// /// Diese Klasse enthält eine Referenz auf eine Siplace pro Session, über die auf die SiplacePro Schnittstelle zugegriffen werden kann. /// public class SiplacePro : ISiplacePro { #region Fields // Eventhandler zur übergabe des Events an Java Server. public OIBEventHandler _eventHandler { set; get; } public OibSpiAccess oibSpiAccess { get; set; } #endregion #region ISiplacePro Member public void RegisterCallback() { LogHandler.log(Constants.LOGGER, TraceEventType.Information, "subscribe SiplacePro events"); try { if (oibSpiAccess.Session != null) { LogHandler.log(Constants.LOGGER, TraceEventType.Information, "SiplacePro Adapter Version: " + oibSpiAccess.Session.OibSiplaceProAdapterVersion); LogHandler.log(Constants.LOGGER, TraceEventType.Information, "SiplacePro Proxy Version: " + oibSpiAccess.Session.OibSiplaceProProxyVersion); oibSpiAccess.Session.ServiceUnreachable += SpiSessionOnServiceUnreachable; oibSpiAccess.Session.ServiceReconnect += SpiSessionOnServiceReconnect; LogHandler.log(Constants.LOGGER, TraceEventType.Information, "SiplacePro events subscribed "); } } catch (Exception ex) { LogHandler.log(Constants.LOGGER, TraceEventType.Error, "Got exception during setting up Subcription mode: ", ex); } } #endregion #region SPI Event Handling private void SpiSessionOnServiceReconnect(string endpoint, string comment) { LogHandler.log(Constants.LOGGER, TraceEventType.Error, "*** SERVICE RECONNECT ***"); if (_eventHandler != null) _eventHandler.onServiceReconnect(); } private void SpiSessionOnServiceUnreachable(string endpoint, string comment) { LogHandler.log(Constants.LOGGER, TraceEventType.Error, "*** SERVICE UNREACHABLE ***"); if (_eventHandler != null) _eventHandler.onServiceDisconnect(); } #endregion #region ISiplacePro Member public BoardElement[] getPlacementForBoard(String boardFullName) { LogHandler.log(Constants.LOGGER, TraceEventType.Information, ".NET get Board"); // PlacementInfo placementInfo = new PlacementInfo(); OibSpiBizObj.Board board = oibSpiAccess.Session.GetObject(boardFullName, OibSpiTypes.ObjectServerType.Board) as OibSpiBizObj.Board; List itacBoardElementList = new List(); com.itac.oib.siplacepro.contracts.data.BoardElement itacBoardElement = new com.itac.oib.siplacepro.contracts.data.BoardElement(); com.itac.oib.siplacepro.contracts.data.Board itacBoard = BoardMapper.get(board); itacBoardElement.Board = itacBoard; //board = BoardElementHelper.DoBoard(board); // itacBoard.producedSide = board.BoardSideProduced.ToString(); itacBoardElementList.Add(itacBoardElement); return itacBoardElementList.ToArray(); } // diese Methode im Download Event ausführen und Ergebnis zurückliefern internal static BoardElement[] GetPlacementForRecipe(OibSpiBizObj.Recipe recipe) { LogHandler.log(Constants.LOGGER, TraceEventType.Information, ".NET get Recipe"); BoardElement[] placementInfo = new BoardElement[0]; // var itacBoardElementList = new List(); try { foreach (var boardelement in recipe.BoardElements) { // itacBoardElementList.Add(BoardElementHelper.DoBoardElement(boardelement)); } // placementInfo.boardElements = itacBoardElementList.ToArray(); } catch (Exception ex) { // bei allen Exceptions Ausgabe machen und null liefern!!! LogHandler.log(Constants.LOGGER, TraceEventType.Error, "converting board information failed, can't continue properly", ex); return null; } return placementInfo; } #endregion #region ISiplacePro Member public BoardCheckInRequest completeCheckinData(BoardCheckInRequest checkinData) { LogHandler.log(Constants.LOGGER, TraceEventType.Information, "complete CheckInData"); if (checkinData == null) { return null; } // Line und Recipe ermitteln, die fehlenden Werte in die übergebene Struktur eintragen und zurückliefern var result = checkinData; LogHandler.log(Constants.LOGGER, TraceEventType.Information, ".NET call getRecipe"); // var recipe = oibSpiAccess.Session.GetObject(checkinData.getRecipeName(), OibSpiTypes.ObjectServerType.Recipe) as OibSpiBizObj.Recipe; // result.setRecipeName(monitoring.contracts.data.RecipeMapper.get(recipe)); // LogHandler.log(Constants.LOGGER, TraceEventType.Information, ".NET call getLine"); // var line = oibSpiAccess.Session.GetObject(checkinData.getLineName(), OibSpiTypes.ObjectServerType.Line) as OibSpiBizObj.Line; // result.setLineName( LineMapper.get(line)); LogHandler.log(Constants.LOGGER, TraceEventType.Information, "complete CheckInData finished"); return checkinData; } private static OibSpiArchObj.Identity GetStationIdentity(OibSpiBizObj.DownloadData downloadData, OibSpiBizObj.ProductionDataManager pdm) { foreach (var dd in pdm.LineControlData.DownloadData) { if (dd.Value.OID == downloadData.OID) { return dd.Key; } } return null; } #endregion internal void Download(Asm.As.Oib.SiplacePro.Contracts.Data.Business.Objects.DownloadData downloadData) { if (_eventHandler != null) { // TODO richtiges download nehmen _eventHandler.DownloadEvent(downloadData); } } public LineChangeoverEventArgs getCurrentLineProductionData() { throw new NotImplementedException(); } #region ISiplacePro Member #endregion } }