private IEnumerable <JobLogDB.EventLogMaterial> CreateUnloadMaterial(MessageState state, string pal, IReadOnlyList <LogEntry> oldEvents = null) { var oldMat = FindMaterial(pal, oldEvents)[0]; var ret = new List <JobLogDB.EventLogMaterial>(); string partName = ""; int count = 1; if (state.PartCompletedMessagesBySetup.Count > 0) { // use highest setup value var msgs = state.PartCompletedMessagesBySetup.ElementAt(state.PartCompletedMessagesBySetup.Count - 1).Value; count = msgs.Count; partName = msgs[0].PartName; } Log.Debug("During unload, found {cnt} parts with name {part} that were unloaded/completed", count, partName); _log.SetDetailsForMaterialID(oldMat.MaterialID, null, partName, null); if (_settings.SerialType == BlackMaple.MachineFramework.SerialType.AssignOneSerialPerCycle || _settings.SerialType == BlackMaple.MachineFramework.SerialType.AssignOneSerialPerMaterial ) { _log.RecordSerialForMaterialID(oldMat, _settings.ConvertMaterialIDToSerial(oldMat.MaterialID).PadLeft(_settings.SerialLength, '0'), state.LastSeenMessage.TimeUTC); } ret.Add(oldMat); var oldMatDetails = _log.GetMaterialDetails(oldMat.MaterialID); //allocate new materials, one per completed part in addition to the existing one for (int i = 1; i < count; i++) { var newId = _log.AllocateMaterialID(oldMatDetails.JobUnique, oldMatDetails.PartName, 1); var newMat = new JobLogDB.EventLogMaterial() { MaterialID = newId, Process = 1, Face = "" }; if (_settings.SerialType == BlackMaple.MachineFramework.SerialType.AssignOneSerialPerCycle) { _log.RecordSerialForMaterialID(newMat, oldMatDetails.Serial, state.LastSeenMessage.TimeUTC); } else if (_settings.SerialType == BlackMaple.MachineFramework.SerialType.AssignOneSerialPerMaterial) { _log.RecordSerialForMaterialID(newMat, _settings.ConvertMaterialIDToSerial(newId).PadLeft(_settings.SerialLength, '0'), state.LastSeenMessage.TimeUTC); } ret.Add(newMat); } return(ret); }
private SortedList <string, JobLogDB.EventLogMaterial> ParseMaterialFromPreviousEvents(string jobPartName, int proc, int fixQty, bool isUnloadEnd, IList <MWI.LogEntry> oldEvents) { var byFace = new SortedList <string, JobLogDB.EventLogMaterial>(); //face -> material for (int i = oldEvents.Count - 1; i >= 0; i -= 1) { // When looking for material for an unload event, we want to skip over load events, // since an ending load event might have come through with the new material id that is loaded. if (isUnloadEnd && oldEvents[i].Result == "LOAD") { continue; } foreach (LogMaterial mat in oldEvents[i].Material) { if (mat.PartName == jobPartName && mat.Process == proc && mat.MaterialID >= 0 && !byFace.ContainsKey(mat.Face)) { string newFace; if (fixQty == 1) { newFace = proc.ToString(); } else { int idx = mat.Face.IndexOf('-'); if (idx >= 0 && idx < mat.Face.Length) { newFace = proc.ToString() + mat.Face.Substring(idx); } else { newFace = proc.ToString(); } } byFace[newFace] = new JobLogDB.EventLogMaterial() { MaterialID = mat.MaterialID, Process = proc, Face = newFace }; } } } return(byFace); }
public void WithoutInspectProgram() { DateTime now = DateTime.UtcNow; var mat1 = new JobLogDB.EventLogMaterial() { MaterialID = 1, Process = 1 }; var mat2 = new JobLogDB.EventLogMaterial() { MaterialID = 2, Process = 1 }; _insp.ForceInspection(mat1, "myinspection", true, now); _insp.ForceInspection(mat2, "myinspection", false, now); _insp.MakeInspectionDecisions(1, 1, null, now); _insp.MakeInspectionDecisions(2, 1, null, now); CheckDecision(1, "myinspection", "", true, now, true); CheckDecision(2, "myinspection", "", false, now, true); }
public static void CreateSerial(long matID, string jobUniqe, string partName, int process, string face, JobLogDB _log, FMSSettings Settings) { foreach (var stat in _log.GetLogForMaterial(matID)) { if (stat.LogType == LogType.PartMark && stat.LocationNum == 1) { foreach (LogMaterial mat in stat.Material) { if (mat.Process == process) { //We have recorded the serial already return; } } } } var serial = Settings.ConvertMaterialIDToSerial(matID); //length 10 gets us to 1.5e18 which is not quite 2^64 //still large enough so we will practically never roll around serial = serial.Substring(0, Math.Min(Settings.SerialLength, serial.Length)); serial = serial.PadLeft(Settings.SerialLength, '0'); Log.Debug("Recording serial for matid: {matid} {serial}", matID, serial); var logMat = new JobLogDB.EventLogMaterial() { MaterialID = matID, Process = process, Face = face }; _log.RecordSerialForMaterialID(logMat, serial); }