private void AddInspection(MakinoDB.MachineResults m, IList <JobLogDB.EventLogMaterial> material) { if (_jobDB == null && _log == null) { return; } var job = _jobDB.LoadJob(m.OrderName); if (job == null) { return; } if (m.ProcessNum != job.NumProcesses) { return; } foreach (var mat in material) { _log.MakeInspectionDecisions(mat.MaterialID, m.ProcessNum, job.GetInspections()); } }
private void AddMachineToLog( DateTime timeToSkip, IDictionary <int, PalletLocation> devices, MakinoDB.MachineResults m) { //find the location PalletLocation loc; if (devices.ContainsKey(m.DeviceID)) { loc = devices[m.DeviceID]; } else { loc = new PalletLocation(PalletLocationEnum.Buffer, "Unknown", 0); } if (loc.Location != PalletLocationEnum.Machine) { Log.Error("Creating machine cycle for device that is not a machine: " + loc.Location.ToString()); } //count the number of parts int numParts = 0; foreach (var i in m.OperQuantities) { numParts += i; } if (numParts <= 0) { return; } //create the material var matList = FindOrCreateMaterial(m.PalletID, m.FixtureNumber, m.EndDateTimeUTC, m.OrderName, m.PartName, m.ProcessNum, numParts); var elapsed = m.EndDateTimeUTC.Subtract(m.StartDateTimeUTC); //check if the cycle already exists if (timeToSkip == m.EndDateTimeUTC && _log.CycleExists(m.EndDateTimeUTC, m.PalletID.ToString(), LogType.MachineCycle, "MC", loc.Num)) { return; } var extraData = new Dictionary <string, string>(); if (matList.Count > 0) { var matID1 = matList[0].MaterialID; Log.Debug( "Starting load of common values between the times of {start} and {end} on DeviceID {deviceID}." + "These values will be attached to part {part} with serial {serial}", m.StartDateTimeLocal, m.EndDateTimeLocal, m.DeviceID, m.PartName, Settings.ConvertMaterialIDToSerial(matID1)); foreach (var v in _makinoDB.QueryCommonValues(m)) { Log.Debug("Common value with number {num} and value {val}", +v.Number, v.Value); extraData[v.Number.ToString()] = v.Value; } } _log.RecordMachineEnd( mats: matList, pallet: m.PalletID.ToString(), statName: "MC", statNum: loc.Num, program: m.Program, result: "", timeUTC: m.EndDateTimeUTC, elapsed: elapsed, active: TimeSpan.FromSeconds(m.SpindleTimeSeconds), extraData: extraData); AddInspection(m, matList); }