public void AddPalletInfo(int fixutrePalletID, int fixtureNum, int fixtureID, int palletNum, PalletLocation loc) { _fixPalIDToFixNum.Add(fixutrePalletID, fixtureNum); _fixPalIDToFixID.Add(fixutrePalletID, fixtureID); _fixPalIDToPalNum.Add(fixutrePalletID, palletNum); if (!_fixIDToPallets.ContainsKey(fixtureID)) { _fixIDToPallets.Add(fixtureID, new List <int>()); } _fixIDToPallets[fixtureID].Add(palletNum); if (_pallets.ContainsKey(palletNum.ToString())) { var p = _pallets[palletNum.ToString()]; p.NumFaces = Math.Max(p.NumFaces, fixtureNum); return; } PalletStatus pal; pal = new PalletStatus() { Pallet = palletNum.ToString(), CurrentPalletLocation = loc, NumFaces = fixtureNum, OnHold = false, }; _pallets.Add(palletNum.ToString(), pal); }
public void UpdatePalletState(int palletId, int planId, PalletStatus palletStatus) { String url = Global_Object.url + "pallet/updatePalletStatus"; dynamic product = new JObject(); product.palletId = palletId; product.planId = planId; product.palletStatus = palletStatus.ToString(); product.updUsrId = Global_Object.userLogin; String collectionData = RequestDataProcedure_POST(product.ToString(), url); Console.WriteLine(collectionData); }
public object ExitScan(List <int> FulOrderIdList, int PalletId) { try { List <FulOrder> FulOrderList = new List <FulOrder>(); FulOrderList = (from fo in context.FulOrder where FulOrderIdList.Contains(fo.FulOrderId) && fo.PalletId == PalletId select fo).ToList(); if (FulOrderList.Count == 0) { return new { status = false, message = _iconfiguration["NO_FO_ON_PALLET"] } } ; /* Considerting all the FO are in Palletized status and updateing all at a time */ FulOrderStatus FulOrderStatusObj = (from fos in context.FulOrderStatus where fos.Name.ToUpper() == _iconfiguration["EXITSCAN"] select fos).FirstOrDefault(); Pallet PalletObj = (from p in context.Pallet where p.PalletId == PalletId select p).FirstOrDefault(); if (PalletObj == null) { return new { status = false, message = _iconfiguration["PALLETID_NOTFOUND"] } } ; PalletStatus palletStatusObj = (from ps in context.PalletStatus where ps.Name.ToUpper() == _iconfiguration["CLOSED"] select ps).FirstOrDefault(); foreach (FulOrder FulOrderObj in FulOrderList) { FulOrderObj.FulOrderStatusId = FulOrderStatusObj.FulOrderStatusId; } PalletObj.PalletStatusId = palletStatusObj.PalletStatusId; context.Pallet.Update(PalletObj); context.FulOrder.UpdateRange(FulOrderList); context.SaveChanges(); return(new { status = true, message = _iconfiguration["EXISSCAN_SUCCESS"] }); } catch (Exception Ex) { LogServiceObj.LogException(Ex); MailServiceObj.SendMail(Ex.Message ?? "", (Ex.InnerException != null) ? Ex.InnerException.Message : "", Ex.StackTrace ?? ""); return(new { status = false, message = _iconfiguration["ERROR_EXITSCAN"] }); } }
public EuroPallet GetEuroPallet(Route route, float position, PalletStatus status) { EuroPallet palletLoad = CreateEuroPallet(PalletLoadHeight, PalletLoadWidth, PalletLoadLength, PalletLoadWeight, DefaultLoadColor.ToString(), status); if (route != null) { ((ATCEuroPallet)palletLoad).SetYaw(((Pallet.Assemblies.PalletStraight)route.Parent.Parent).ConveyorType); ((ATCEuroPallet)palletLoad).PresetStateCode = "OK"; if (position == 0) { if (palletLoad.Yaw == 0) { position = position + (palletLoad.Length / 2); } else { position = position + (palletLoad.Width / 2); } } route.Add(palletLoad, position); } return(palletLoad); }
private static void AddUnloads(JobLogDB log, IEnumerable <LoadAction> currentActions, PalletStatus pallet, TimeSpan?elapsedLoadTime, List <BlackMaple.MachineWatchInterface.LogEntry> oldCycles, CurrentStatus status) { // For some reason, sometimes parts to unload don't show up in PalletSubStatus table. // So create them here if that happens foreach (var unload in currentActions) { if (unload.LoadEvent) { continue; } if (unload.LoadStation != pallet.CurrentPalletLocation.Num) { continue; } var matIDs = new Queue <long>(FindMatIDsFromOldCycles(oldCycles, unload.Unique, unload.Process)); status.Jobs.TryGetValue(unload.Unique, out InProcessJob job); for (int i = 0; i < unload.Qty; i += 1) { string face = unload.Process.ToString(); long matID = -1; if (matIDs.Count > 0) { matID = matIDs.Dequeue(); } var matDetails = log.GetMaterialDetails(matID); var inProcMat = new InProcessMaterial() { MaterialID = matID, JobUnique = unload.Unique, PartName = unload.Part, Process = unload.Process, Path = unload.Path, Serial = matDetails?.Serial, WorkorderId = matDetails?.Workorder, SignaledInspections = log.LookupInspectionDecisions(matID) .Where(x => x.Inspect) .Select(x => x.InspType) .ToList(), Location = new InProcessMaterialLocation() { Type = InProcessMaterialLocation.LocType.OnPallet, Pallet = pallet.Pallet, Face = unload.Process }, Action = new InProcessMaterialAction() { Type = InProcessMaterialAction.ActionType.UnloadToCompletedMaterial, ElapsedLoadUnloadTime = elapsedLoadTime } }; if (job != null) { if (unload.Process == job.NumProcesses) { inProcMat.Action.Type = InProcessMaterialAction.ActionType.UnloadToInProcess; } var queue = job.GetOutputQueue(process: unload.Process, path: unload.Path); if (!string.IsNullOrEmpty(queue)) { inProcMat.Action.UnloadIntoQueue = queue; } } status.Material.Add(inProcMat); } } }
public static CurrentStatus Build(JobDB jobDB, JobLogDB log, FMSSettings fmsSettings, IMachineGroupName machineGroupName, IQueueSyncFault queueSyncFault, MazakDbType dbType, MazakAllData mazakData, DateTime utcNow) { //Load process and path numbers Dictionary <string, int> uniqueToMaxPath; Dictionary <string, int> uniqueToMaxProcess; CalculateMaxProcAndPath(mazakData, out uniqueToMaxPath, out uniqueToMaxProcess); var currentLoads = new List <LoadAction>(mazakData.LoadActions); var curStatus = new CurrentStatus(); foreach (var k in fmsSettings.Queues) { curStatus.QueueSizes[k.Key] = k.Value; } if (mazakData.Alarms != null) { foreach (var alarm in mazakData.Alarms) { if (!string.IsNullOrEmpty(alarm.AlarmMessage)) { curStatus.Alarms.Add(alarm.AlarmMessage); } } } if (queueSyncFault.CurrentQueueMismatch) { curStatus.Alarms.Add("Queue contents and Mazak schedule quantity mismatch."); } var jobsBySchID = new Dictionary <long, InProcessJob>(); var pathBySchID = new Dictionary <long, MazakPart.IProcToPath>(); foreach (var schRow in mazakData.Schedules) { if (!MazakPart.IsSailPart(schRow.PartName)) { continue; } MazakPartRow partRow = null; foreach (var p in mazakData.Parts) { if (p.PartName == schRow.PartName) { partRow = p; break; } } if (partRow == null) { continue; } //Parse data from the database var partName = partRow.PartName; int loc = partName.IndexOf(':'); if (loc >= 0) { partName = partName.Substring(0, loc); } string jobUnique = ""; MazakPart.IProcToPath procToPath = null; bool manual = false; if (!string.IsNullOrEmpty(partRow.Comment)) { MazakPart.ParseComment(partRow.Comment, out jobUnique, out procToPath, out manual); } if (!uniqueToMaxProcess.ContainsKey(jobUnique)) { continue; } int numProc = uniqueToMaxProcess[jobUnique]; int maxProc1Path = uniqueToMaxPath[jobUnique]; InProcessJob job; //Create or lookup the job if (curStatus.Jobs.ContainsKey(jobUnique)) { job = curStatus.Jobs[jobUnique]; } else { var jobPaths = new int[numProc]; for (int i = 0; i < numProc; i++) { jobPaths[i] = maxProc1Path; } job = new InProcessJob(jobUnique, numProc, jobPaths); job.PartName = partName; job.JobCopiedToSystem = true; curStatus.Jobs.Add(jobUnique, job); } jobsBySchID.Add(schRow.Id, job); pathBySchID.Add(schRow.Id, procToPath); //Job Basics job.SetPlannedCyclesOnFirstProcess(procToPath.PathForProc(proc: 1), schRow.PlanQuantity); AddCompletedToJob(schRow, job, procToPath); job.Priority = schRow.Priority; if (((HoldPattern.HoldMode)schRow.HoldMode) == HoldPattern.HoldMode.FullHold) { job.HoldEntireJob.UserHold = true; } else { job.HoldEntireJob.UserHold = false; } AddRoutingToJob(mazakData, partRow, job, machineGroupName, procToPath, dbType); } var loadedJobs = new HashSet <string>(); foreach (var j in jobsBySchID.Values) { if (loadedJobs.Contains(j.UniqueStr)) { continue; } loadedJobs.Add(j.UniqueStr); AddDataFromJobDB(jobDB, j); } //Now add pallets foreach (var palRow in mazakData.Pallets) { if (palRow.PalletNumber > 0 && !curStatus.Pallets.ContainsKey(palRow.PalletNumber.ToString())) { var palName = palRow.PalletNumber.ToString(); var palLoc = FindPalletLocation(machineGroupName, mazakData, dbType, palRow.PalletNumber); //Create the pallet PalletStatus status = new PalletStatus() { Pallet = palName, CurrentPalletLocation = palLoc, FixtureOnPallet = palRow.Fixture, NumFaces = 1, OnHold = false }; curStatus.Pallets.Add(status.Pallet, status); var oldCycles = log.CurrentPalletLog(palName); //Add the material currently on the pallet foreach (var palSub in mazakData.PalletSubStatuses) { if (palSub.PalletNumber != palRow.PalletNumber) { continue; } if (palSub.FixQuantity <= 0) { continue; } if (!jobsBySchID.ContainsKey(palSub.ScheduleID)) { continue; } status.NumFaces = Math.Max(status.NumFaces, palSub.PartProcessNumber); var job = jobsBySchID[palSub.ScheduleID]; var procToPath = pathBySchID[palSub.ScheduleID]; var matIDs = new Queue <long>(FindMatIDsFromOldCycles(oldCycles, job.UniqueStr, palSub.PartProcessNumber)); for (int i = 1; i <= palSub.FixQuantity; i++) { int face = palSub.PartProcessNumber; long matID = -1; if (matIDs.Count > 0) { matID = matIDs.Dequeue(); } var matDetails = log.GetMaterialDetails(matID); var inProcMat = new InProcessMaterial() { MaterialID = matID, JobUnique = job.UniqueStr, PartName = job.PartName, Process = palSub.PartProcessNumber, Path = procToPath.PathForProc(palSub.PartProcessNumber), Serial = matDetails?.Serial, WorkorderId = matDetails?.Workorder, SignaledInspections = log.LookupInspectionDecisions(matID) .Where(x => x.Inspect) .Select(x => x.InspType) .Distinct() .ToList(), LastCompletedMachiningRouteStopIndex = oldCycles.Any( c => c.LogType == LogType.MachineCycle && !c.StartOfCycle && c.Material.Any(m => m.MaterialID == matID && m.Process == palSub.PartProcessNumber) ) ? (int?)0 : null, Location = new InProcessMaterialLocation() { Type = InProcessMaterialLocation.LocType.OnPallet, Pallet = status.Pallet, Face = face }, Action = new InProcessMaterialAction() { Type = InProcessMaterialAction.ActionType.Waiting } }; curStatus.Material.Add(inProcMat); //check for unloading or transfer var loadNext = CheckLoadOfNextProcess(currentLoads, job.UniqueStr, palSub.PartProcessNumber, palLoc); var unload = CheckUnload(currentLoads, job.UniqueStr, palSub.PartProcessNumber, palLoc); if (loadNext != null) { var start = FindLoadStartFromOldCycles(oldCycles, matID); inProcMat.Action = new InProcessMaterialAction() { Type = InProcessMaterialAction.ActionType.Loading, LoadOntoFace = palSub.PartProcessNumber + 1, LoadOntoPallet = status.Pallet, ProcessAfterLoad = palSub.PartProcessNumber + 1, PathAfterLoad = procToPath.PathForProc(palSub.PartProcessNumber + 1), ElapsedLoadUnloadTime = start != null ? (TimeSpan?)utcNow.Subtract(start.EndTimeUTC) : null }; } else if (unload != null) { var start = FindLoadStartFromOldCycles(oldCycles, matID); inProcMat.Action = new InProcessMaterialAction() { Type = palSub.PartProcessNumber == job.NumProcesses ? InProcessMaterialAction.ActionType.UnloadToCompletedMaterial : InProcessMaterialAction.ActionType.UnloadToInProcess, UnloadIntoQueue = job.GetOutputQueue( process: palSub.PartProcessNumber, path: procToPath.PathForProc(palSub.PartProcessNumber)), ElapsedLoadUnloadTime = start != null ? (TimeSpan?)utcNow.Subtract(start.EndTimeUTC) : null }; } else { // detect if machining var start = FindMachineStartFromOldCycles(oldCycles, matID); if (start != null) { var machStop = job.GetMachiningStop(inProcMat.Process, inProcMat.Path).FirstOrDefault(); var elapsedTime = utcNow.Subtract(start.EndTimeUTC); inProcMat.Action = new InProcessMaterialAction() { Type = InProcessMaterialAction.ActionType.Machining, ElapsedMachiningTime = elapsedTime, ExpectedRemainingMachiningTime = machStop != null?machStop.ExpectedCycleTime.Subtract(elapsedTime) : TimeSpan.Zero }; } } } } if (palLoc.Location == PalletLocationEnum.LoadUnload) { var start = FindLoadStartFromOldCycles(oldCycles); var elapsedLoad = start != null ? (TimeSpan?)utcNow.Subtract(start.EndTimeUTC) : null; AddLoads(log, currentLoads, status.Pallet, palLoc, elapsedLoad, curStatus); AddUnloads(log, currentLoads, status, elapsedLoad, oldCycles, curStatus); } } } //now queued var seenMatIds = new HashSet <long>(curStatus.Material.Select(m => m.MaterialID)); foreach (var mat in log.GetMaterialInAllQueues()) { // material could be in the process of being loaded if (seenMatIds.Contains(mat.MaterialID)) { continue; } var matLogs = log.GetLogForMaterial(mat.MaterialID); int lastProc = 0; foreach (var entry in log.GetLogForMaterial(mat.MaterialID)) { foreach (var entryMat in entry.Material) { if (entryMat.MaterialID == mat.MaterialID) { lastProc = Math.Max(lastProc, entryMat.Process); } } } var matDetails = log.GetMaterialDetails(mat.MaterialID); curStatus.Material.Add(new InProcessMaterial() { MaterialID = mat.MaterialID, JobUnique = mat.Unique, PartName = mat.PartName, Process = lastProc, Path = 1, Serial = matDetails?.Serial, WorkorderId = matDetails?.Workorder, SignaledInspections = log.LookupInspectionDecisions(mat.MaterialID) .Where(x => x.Inspect) .Select(x => x.InspType) .Distinct() .ToList(), Location = new InProcessMaterialLocation() { Type = InProcessMaterialLocation.LocType.InQueue, CurrentQueue = mat.Queue, QueuePosition = mat.Position, }, Action = new InProcessMaterialAction() { Type = InProcessMaterialAction.ActionType.Waiting } }); } var notCopied = jobDB.LoadJobsNotCopiedToSystem(DateTime.UtcNow.AddHours(-WriteJobs.JobLookbackHours), DateTime.UtcNow); foreach (var j in notCopied.Jobs) { if (curStatus.Jobs.ContainsKey(j.UniqueStr)) { //The copy to the cell succeeded but the DB has not yet been updated. //The thread which copies jobs will soon notice and update the database //so we can ignore it for now. } else { curStatus.Jobs.Add(j.UniqueStr, new InProcessJob(j)); } } foreach (var j in curStatus.Jobs) { foreach (var d in jobDB.LoadDecrementsForJob(j.Value.UniqueStr)) { j.Value.Decrements.Add(d); } } return(curStatus); }
public static EuroPallet FeedEuroPallet(ITransportSection transportSection, float distance, BasePalletData palletData, PalletStatus palletStatus) { EuroPallet PalletLoad; IEmulationController controller = Core.Assemblies.Assembly.Items.Values.ToList().FirstOrDefault(x => x is IEmulationController) as IEmulationController; if (controller != null) { PalletLoad = controller.GetEuroPallet(transportSection.Route, 0, palletStatus); if (PalletLoad != null) //It is not necesary to implement this just return null Pallet load from the controller and a standard load will be created { return(PalletLoad); } } try { EuroPalletInfo palletInfo = new EuroPalletInfo(); palletInfo.color = Color.Peru; palletInfo.Status = palletStatus; palletInfo.filename = EuroPallet.Mesh; //LoadHeight includes the height of the pallet (145mm) palletInfo.LoadHeight = 2.2f; palletInfo.LoadWidth = 0.9f; palletInfo.LoadLength = 1.3f; //Set the dimensions of a EuroPallet (This is the standard size) palletInfo.length = 1.2f; palletInfo.width = 0.8f; palletInfo.height = 0.14f; // Actual size is 0.144f but reduced so visible space can be added in stack (0.005f space) EuroPallet palletLoad = new EuroPallet(palletInfo); //palletLoad.Part = (RigidLoadPart)new PalletPart(0.008f, palletInfo.color, palletInfo.length, palletInfo.height, palletInfo.width, true, palletInfo.density, Pallet_Load.Size(PalletType.EuroPallet), palletInfo.rigid); palletLoad.Pallet_Data = palletData; palletLoad.Pallet_Data.Weight = 60.0f; transportSection.Route.Add(palletLoad, distance); Load.Items.Add(palletLoad); string SSCCBarcode = GetSSCCBarcode(); if (SSCCBarcode != "") { palletLoad.SSCCBarcode = SSCCBarcode; palletLoad.Identification = SSCCBarcode; } return(palletLoad); } catch (Exception se) { Core.Environment.Log.Write(se); Core.Environment.Scene.Pause(); return(null); } }
/// <summary> /// Create the EuroPallet load from a message from ATC /// </summary> public virtual ATCEuroPallet CreateEuroPallet(TelegramTypes Type, string[] Telegram) { ATCEuroPallet newLoad = null; float length; bool lengthIsFloat = float.TryParse(Telegram.GetFieldValue(TelegramFields.length), out length); float width; bool widthIsFloat = float.TryParse(Telegram.GetFieldValue(TelegramFields.width), out width); float height; bool heightIsFloat = float.TryParse(Telegram.GetFieldValue(TelegramFields.height), out height); float weight; bool weightIsFloat = float.TryParse(Telegram.GetFieldValue(TelegramFields.weight), out weight); string color = Telegram.GetFieldValue(TelegramFields.color); PalletStatus palletStatus = PalletStatus.Loaded; EmulationATC emulation = Core.Assemblies.Assembly.Items.Values.ToList().FirstOrDefault(x => x is EmulationATC) as EmulationATC; if (emulation != null) { length = (!lengthIsFloat || length == 0f) ? emulation.PalletLoadLength : length / 1000; width = (!widthIsFloat || width == 0f) ? emulation.PalletLoadWidth : width / 1000; height = (!heightIsFloat || height == 0f) ? emulation.PalletLoadHeight : height / 1000; weight = (!weightIsFloat || weight == 0f) ? emulation.PalletLoadWeight : weight; } if (Type == TelegramTypes.StartTransportTelegram) { newLoad = CreateEuroPallet( Telegram.GetFieldValue(TelegramFields.mts), Telegram.GetFieldValue(TelegramFields.tuIdent), Telegram.GetFieldValue(TelegramFields.tuType), Telegram.GetFieldValue(TelegramFields.source), //Source Telegram.GetFieldValue(TelegramFields.destination), Telegram.GetFieldValue(TelegramFields.presetStateCode), height, width, length, weight, LoadColor(Telegram.GetFieldValue(TelegramFields.color)), palletStatus); } else if (Type == TelegramTypes.CreateTuTelegram) { newLoad = CreateEuroPallet( Telegram.GetFieldValue(TelegramFields.mts), Telegram.GetFieldValue(TelegramFields.tuIdent), Telegram.GetFieldValue(TelegramFields.tuType), Telegram.GetFieldValue(TelegramFields.location), //Location Telegram.GetFieldValue(TelegramFields.destination), Telegram.GetFieldValue(TelegramFields.presetStateCode), height, width, length, weight, LoadColor(Telegram.GetFieldValue(TelegramFields.color)), palletStatus); } if (newLoad != null) { //Add project fields to load foreach (string field in ProjectFields) { string fieldValue = Telegram.GetFieldValue(field); if (fieldValue != null) { // Update if field already exists | Insert New if (newLoad.ProjectFields.ContainsKey(field)) { newLoad.ProjectFields[field] = fieldValue; } else { newLoad.ProjectFields.Add(field, fieldValue); } } } return(newLoad); } return(null); }
protected ATCEuroPallet CreateEuroPallet(float height, float width, float length, float weight, string color, PalletStatus status) { return(CreateEuroPallet("", FeedLoad.GetSSCCBarcode(), "", "", "", "OK", height, width, length, weight, LoadColor(color), status)); }
protected ATCEuroPallet CreateEuroPallet(string mts, string tuIdent, string tuType, string source, string destination, string presetStateCode, float height, float width, float length, float weight, Color color, PalletStatus status) { EuroPalletInfo palletInfo = new EuroPalletInfo(); palletInfo.LoadColor = color;//LoadColor(color); palletInfo.Status = status; palletInfo.filename = Experior.Dematic.Base.EuroPallet.Mesh; palletInfo.color = Color.Peru; //LoadHeight includes the height of the pallet (145mm) palletInfo.LoadHeight = height; palletInfo.LoadWidth = width; palletInfo.LoadLength = length; //TODO: Weight //Set the dimensions of a EuroPallet (This is the standard size) palletInfo.length = 1.2f; palletInfo.width = 0.8f; palletInfo.height = 0.145f; ATCEuroPallet palletLoad = new ATCEuroPallet(palletInfo); palletLoad.TUIdent = tuIdent; palletLoad.TUType = tuType; palletLoad.Source = source; palletLoad.Destination = destination; palletLoad.PresetStateCode = presetStateCode; palletLoad.PalletWeight = weight; //Add project fields to load Load.Items.Add(palletLoad); if (ProjectFields.Count > 0) { foreach (string field in ProjectFields) { palletLoad.ProjectFields.Add(field, ""); } } return(palletLoad); }