Exemple #1
0
        private void AddLoadToLog(
            DateTime timeToSkip, IDictionary <int, PalletLocation> devices, MakinoDB.WorkSetResults w)
        {
            //find the location
            PalletLocation loc;

            if (devices.ContainsKey(w.DeviceID))
            {
                loc = devices[w.DeviceID];
            }
            else
            {
                loc = new PalletLocation(PalletLocationEnum.Buffer, "Unknown", 1);
            }

            if (loc.Location != PalletLocationEnum.LoadUnload)
            {
                Log.Error("Creating machine cycle for device that is not a load: " + loc.Location.ToString());
            }

            //calculate the elapsed time
            var elapsed = w.EndDateTimeUTC.Subtract(w.StartDateTimeUTC);

            elapsed = new TimeSpan(elapsed.Ticks / 2);

            //count the number of unloaded parts
            int numParts = 0;

            foreach (var i in w.UnloadNormalQuantities)
            {
                numParts += i;
            }

            //Only process unload cycles if remachine is false
            if (numParts > 0 && !w.Remachine)
            {
                //create the material for unload
                var matList = FindOrCreateMaterial(w.PalletID, w.FixtureNumber, w.EndDateTimeUTC,
                                                   w.UnloadOrderName, w.UnloadPartName, w.UnloadProcessNum, numParts);

                //check if the cycle already exists
                if (timeToSkip == w.EndDateTimeUTC &&
                    _log.CycleExists(w.EndDateTimeUTC, w.PalletID.ToString(), LogType.LoadUnloadCycle, "L/U", loc.Num))
                {
                    return;
                }

                _log.RecordUnloadEnd(
                    mats: matList,
                    pallet: w.PalletID.ToString(),
                    lulNum: loc.Num,
                    timeUTC: w.EndDateTimeUTC,
                    elapsed: elapsed,
                    active: elapsed);
            }

            //Pallet Cycle
            _log.CompletePalletCycle(w.PalletID.ToString(), w.EndDateTimeUTC, "");

            //now the load cycle
            numParts = 0;
            foreach (var i in w.LoadQuantities)
            {
                numParts += i;
            }

            if (numParts > 0)
            {
                //create the material
                var matList = CreateMaterial(w.PalletID, w.FixtureNumber, w.EndDateTimeUTC.AddSeconds(1),
                                             w.LoadOrderName, w.LoadPartName, w.LoadProcessNum, numParts);

                _log.RecordLoadEnd(
                    mats: matList,
                    pallet: w.PalletID.ToString(),
                    lulNum: loc.Num,
                    timeUTC: w.EndDateTimeUTC.AddSeconds(1),
                    elapsed: elapsed,
                    active: elapsed);
            }
        }