public string RegisterBox(string boxId, string materialId, int amount)
        {
            logger.Debug("Calling RegisterBox");

            // Getting Service Object from Spring
            IApplicationContext ctx         = ContextRegistry.GetContext();
            IMaterialMgtService materialMgt = (IMaterialMgtService)ctx.GetObject("materialMgtServiceObjectWSBinding");

            string locationId = "RS"; //TODO: register a new box always on RS!

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                logger.Info("****************************************************** STARTING TRANSACTION");

                // Registrating new box

                bool boxCreated       = materialMgt.CreateBox(boxId);
                bool materialInserted = materialMgt.InsertMaterial(boxId, materialId, amount);
                if (boxCreated && materialInserted)
                {
                    logger.Debug(string.Format("Box registered! boxId = {0}, materialId = {1}, amount = {2}", boxId,
                                               materialId, amount));
                    logger.Info("****************************************************** TRANSACTION COMPLETED");
                    scope.Complete();
                }
                else
                {
                    logger.Info("****************************************************** TRANSACTION ABORTED");
                    locationId = "";
                }
            }
            return(locationId);
        }
示例#2
0
        public void MoveFinished(string boxId, string locationId)
        {
            //logger.Debug("TransportFinished! boxId, locationId " + transported);


            // Getting Service Objects from Spring
            IApplicationContext ctx         = ContextRegistry.GetContext();
            IMaterialMgtService materialMgt = (IMaterialMgtService)ctx.GetObject("materialMgtServiceObjectWSBinding");

            // set location
            bool locationSet = materialMgt.SetLocation(boxId, locationId);


            // getting transport entry to find the endDestinationId
            string endDestinationId;
            List <Transportentry> trEntries = materialMgt.GetTransportentries().ToList();
            Transportentry entry = trEntries.Find(
                delegate(Transportentry t)
            {
                return(t.box_id == boxId);
            }
                );

            endDestinationId = entry.bin_id;


            if (!(endDestinationId.Equals(locationId)))
            {
                // box is not at the endDestination => CallCCSTransport again!
                GeneralTransportServiceProp.CallCCSTransport(boxId, endDestinationId);
            }
            else
            {
                // callback to TransportPlanning that transport was finished
                //callback.TransportFinished(boxId, endDestinationId); TODO
                logger.Debug("Box was transported to " + endDestinationId);
                //IGeneralTransportServiceCallback gTcallback = OperationContext.Current.GetCallbackChannel<IGeneralTransportServiceCallback>();
                //gTcallback.TransportFinished(boxId, endDestinationId);


                GeneralTransportServiceProp.GTcallback.TransportFinished(boxId, endDestinationId);
                //IGeneralTransportService ct = (IGeneralTransportService) OperationContext.Current.Channel;
                logger.Debug("fertig");
            }



            //logger.Debug("TransportFinished! boxId =" + boxId + " new binId=" + endDestId);
        }
示例#3
0
        public void TransportFinished(string boxId, string endDestId)
        {
            // box is at the endDestination!

            IApplicationContext ctx         = ContextRegistry.GetContext();
            IMaterialMgtService materialMgt = (IMaterialMgtService)ctx.GetObject("materialMgtServiceObjectWSBinding");

            //IGeneralTransportService generalTransport = (IGeneralTransportService)ctx.GetObject("generalTransportObject");

            // 1. +++++++++++++++++ DELETE TRANSPORT ENTRY +++++++++++++++++
            materialMgt.DeleteTransportentry(boxId);

            // 2. +++++++++++++++++ UNRESERVATION +++++++++++++++++
            materialMgt.UnReserveBin(endDestId);
            logger.Debug("TransportFinished! boxId =" + boxId + " new binId=" + endDestId);
        }
        public bool CallCCSTransport(string boxId, string endDestId)
        {
            logger.Debug("calling CallCCSTransport");

            // Getting Service Objects from Spring
            IApplicationContext ctx         = ContextRegistry.GetContext();
            IRoutingService     routing     = (IRoutingService)ctx.GetObject("routingServiceObjectWSBinding");
            IMaterialMgtService materialMgt = (IMaterialMgtService)ctx.GetObject("materialMgtServiceObjectWSBinding");
            //IConveyorControlService ccsService = (IConveyorControlService)ctx.GetObject("CCSServiceObjectWSBinding");
            ICCSMockService ccsService = (ICCSMockService)ctx.GetObject("ccsMockServiceObjectWSBinding"); //duplex


            Context       c               = new Context();
            wmsdbEntities entities        = c.GetWMSEntities();
            var           query           = from b in entities.Boxes where b.id == boxId select b;
            var           boxes           = query.ToList();
            Box           box             = boxes.First();
            string        nextDestId      = "";
            string        transportMedium = "";

            nextDestId = routing.GetNextDestination(boxId, endDestId);
            if (string.IsNullOrEmpty(nextDestId))
            {
                logger.Debug("the box is at location or error");
                return(true); // null if error, empty if the box is already at the location
            }

            transportMedium = routing.GetNextTransportMedium(boxId);

            /*
             * ////////////////// EVENT-DRIVEN asynch call
             * CCSMockServiceClient cl = new CCSMockServiceClient();                                       // init client
             * cl.TransportCompleted += new EventHandler<TransportCompletedEventArgs>(TransportCallback);  // add event handler to TransportCallback
             * cl.TransportAsync(boxId, transportMedium, box.location_id, nextDestId);                     // call Transport asynchronously
             * ////////////////// asynch call test end);
             */

            ///////////////// CHANNEL FACTORY asynch call
            //// ccsService.Transport(boxId, box.location_id, nextDestId);
            //IAsyncResult arTransport = ccsService.BeginTransport(boxId, transportMedium, box.location_id, nextDestId, TransportCallback, ccsService);
            ccsService.Move(boxId, transportMedium, box.location_id, nextDestId);
            logger.Debug(string.Format("ASYNCHRONOUS CCS MOCK CALL! box_id = {0}, transportMedium = {1}; currentLocation = {2}, nextDestination = {3}", boxId, transportMedium, box.location_id, nextDestId));
            //System.Threading.Thread.Sleep(2000);
            return(true);
        }
        // sends existing boxes and storageBins from MaterialMgtService to Simulation WebSite
        private void ReloadSimulation(WebSocketSession wss)
        {
            // Getting Service Object from Spring
            IApplicationContext ctx         = ContextRegistry.GetContext();
            IMaterialMgtService materialMgt = (IMaterialMgtService)ctx.GetObject("materialMgtServiceObjectWSBinding");

            wss.SendResponse(RELOAD_SIMULATION);

            List <Location> storageBins = materialMgt.GetStorageBins().ToList();

            foreach (Location sb in storageBins)
            {
                wss.SendResponse(CREATE_STORAGEBIN + " " + sb.id);
            }

            List <Box> boxes = materialMgt.GetBoxes().ToList();

            foreach (Box box in boxes)
            {
                wss.SendResponse(CREATE_BOX + " " + box.id + " " + box.location_id);
            }
        }
        public string StoreBox(string boxId)
        {
            // Getting Service Objects from Spring
            IApplicationContext ctx = ContextRegistry.GetContext();

            IStorageBinSearchService storageBinSearch =
                (IStorageBinSearchService)ctx.GetObject("storageBinSearchServiceObjectWSBinding");
            IMaterialMgtService      materialMgt      = (IMaterialMgtService)ctx.GetObject("materialMgtServiceObjectWSBinding");
            IGeneralTransportService generalTransport = (IGeneralTransportService)ctx.GetObject("generalTransportServiceObject");
            //IGeneralTransportService generalTransport = new
            //    DuplexChannelFactory<IGeneralTransportService>(new CallbackHandler(), "WSDualHttpBinding_IGeneralTransportService").
            //        CreateChannel();

            bool   freeBinFound         = false;
            bool   freeBinReserved      = false;
            string nextFreeBin          = null;
            bool   transportEntyCreated = false;

            // 1. +++++++++++++++++ RESERVATION +++++++++++++++++

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                logger.Info("****************************************************** STARTING TRANSACTION");

                // find next free bin
                nextFreeBin = storageBinSearch.SearchNextFreeBin(boxId);
                if (nextFreeBin != null)
                {
                    freeBinFound = true;
                }

                // reserve free bin
                if (freeBinFound)
                {
                    freeBinReserved = materialMgt.ReserveBin(nextFreeBin);
                }

                // 2. +++++++++++++++++ CREATE TRANSPORT ENTRY +++++++++++++++++
                if (freeBinReserved)
                {
                    transportEntyCreated = materialMgt.CreateTransportentry(boxId, nextFreeBin);
                }

                // transport box to the reserved bin
                if (transportEntyCreated)
                {
                    logger.Info("****************************************************** TRANSACTION COMPLETED");
                    scope.Complete();
                }
                else
                {
                    logger.Info("****************************************************** TRANSACTION ABORTED");
                }
            }



            // 3. +++++++++++++++++ INITIATE TRANSPORT +++++++++++++++++
            if (transportEntyCreated)
            {
                generalTransport.InitiateTransport(boxId, nextFreeBin);
                return(nextFreeBin);

                /*
                 *
                 * DuplexChannelFactory<IGeneralTransportServiceChannel> generalTransportFactory = new DuplexChannelFactory<IGeneralTransportServiceChannel>
                 *  (new CallbackHandler(), "WSDualHttpBinding_IGeneralTransportService");
                 * IGeneralTransportService generalTransportChannel = generalTransportFactory.CreateChannel();
                 * generalTransportChannel.InitiateTransport("", "");
                 */
            }

            return("");
        }