예제 #1
0
        void mergePhotcell_OnDeviceDeleted(object sender, EventArgs e)
        {
            CasePhotocell   pC  = sender as CasePhotocell;
            BeltSorterMerge bsm = AllInductPhotoCells.FirstOrDefault(x => x.Value == pC).Key;

            bsm.MergePhotocellName = null;
        }
예제 #2
0
        public override void Scene_OnLoaded()
        {
            base.Scene_OnLoaded();

            if (MainInductName != null && Core.Assemblies.Assembly.Items.ContainsKey(MainInductName))
            {
                MainInduct = Core.Assemblies.Assembly.Items[MainInductName] as BeltSorterInduct;
                MainInduct.WindowTimeout.OnElapsed += WindowTimeout_OnElapsed;
            }

            MergePhotocell = GetMergePhotocell(beltSorterMergeInfo.MergePhotocellName);
        }
예제 #3
0
        //If the devices on the found conveyor are created after this one then subscribe to the devices created
        //event and try and find it then
        void conv_OnDevicesCreated(object sender, EventArgs e)
        {
            StraightBeltConveyor conv = sender as StraightBeltConveyor;

            conv.OnDevicesCreated -= conv_OnDevicesCreated;

            string[] assemDev = beltSorterMergeInfo.MergePhotocellName.Split(',');

            foreach (Assembly device in ((StraightConveyor)sender).Assemblies)
            {
                if (device.Name == assemDev[1])
                {
                    MergePhotocell = device as CasePhotocell;
                    break;
                }
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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;
                }
            }
        }