void mergePhotcell_OnDeviceDeleted(object sender, EventArgs e) { CasePhotocell pC = sender as CasePhotocell; BeltSorterMerge bsm = AllInductPhotoCells.FirstOrDefault(x => x.Value == pC).Key; bsm.MergePhotocellName = null; }
void photoCellPlacment_OnElapsed(Timer sender) { try { StraightBeltConveyor photocellBelt = photoCellCreator.Route.Parent.Parent as StraightBeltConveyor; //TODO what about other types --- really need a Dematic base conveyor CasePhotocellInfo pcinfo = new CasePhotocellInfo() { name = "Induct_" + ((KeyValuePair <string, float>)eSortedTeachTimes.Current).Key, distance = photoCellCreator.Distance, distanceFrom = PositionPoint.Start, type = photocellBelt.beltControl.constructDevice.DeviceTypes["Add Photocell"].Item1 }; CasePhotocell pc = beltControl.constructDevice.InsertDevice(pcinfo, photocellBelt as IConstructDevice) as CasePhotocell; photocellBelt.DeviceInfos.Add(pcinfo); //Add the device info to the assembly that it was created on so that it will be saved when the user saves the model BeltSorterMerge bsm = Experior.Core.Assemblies.Assembly.Items[((KeyValuePair <string, float>)eSortedTeachTimes.Current).Key] as BeltSorterMerge; bsm.MergePhotocellName = string.Format("{0},{1}", photocellBelt.Name, pc.Name); if (eSortedTeachTimes.MoveNext()) //reset the timer ready for the next photocell { KeyValuePair <string, float> photoCellInfo = (KeyValuePair <string, float>)eSortedTeachTimes.Current; photoCellPlacment.Timeout = photoCellInfo.Value - previousTime; previousTime += photoCellInfo.Value - previousTime; photoCellPlacment.Reset(); photoCellPlacment.Start(); } else //After all photocells have been created subcribe to there deleted event { AssignMergePhotoCellDeleted(); } } catch (Exception ex) { Log.Write("Error in photoCellPlacment_OnElapsed: " + ex.Message); } }
private void AssignMergePhotoCellDeleted() { using (IEnumerator <Assembly> eAssem = Experior.Core.Assemblies.Assembly.Items.Values.GetEnumerator()) { while (eAssem.MoveNext()) { if (eAssem.Current is BeltSorterMerge) { BeltSorterMerge current = eAssem.Current as BeltSorterMerge; lbsm.Add(current); } } } foreach (BeltSorterMerge bsm in lbsm) { if (!string.IsNullOrEmpty(bsm.MergePhotocellName)) { CasePhotocell mergePhotcell = bsm.GetMergePhotocell(bsm.MergePhotocellName); AllInductPhotoCells.Add(bsm, mergePhotcell); mergePhotcell.OnDeviceDeleted += mergePhotcell_OnDeviceDeleted; } } }
public BeltSorterMergeArgs(BeltSorterMerge beltSorterMerge, Load load) { _beltSorterMerge = beltSorterMerge; _load = load; }