Exemple #1
0
        public void EndWork()
        {
            // Release the workstation in use
            this.wstation.IsCurrentlyWorking = false;

            // Put the test tray away
            TestTray tt = this.kdb.TestTrays.Find(this.currentTestTrayId);

            tt.IsCurrentlyInUse = false;
            kdb.SaveChanges();
        }
Exemple #2
0
        /*  DESCRIPTION :
         *  PARAMETERS  :
         *  ALTERS      :
         *  RETURNS     :
         */
        public void SendRunner()
        {
            // Runner needs to replenish part bins AND replace test tray if full

            // We actually need to check if the parts have reached their minimum yet...
            if (this.harnessBin <= Worker.harnessBinMin)
            {
                this.harnessBin = Worker.harnessBinMax;
            }

            if (this.reflectorBin <= Worker.reflectorBinMin)
            {
                this.reflectorBin = Worker.reflectorBinMax;
            }

            if (this.housingBin <= Worker.housingBinMin)
            {
                this.housingBin = Worker.housingBinMax;
            }

            if (this.lensBin <= Worker.lensBinMin)
            {
                this.lensBin = Worker.lensBinMax;
            }

            if (this.bulbBin <= Worker.bulbBinMin)
            {
                this.bulbBin = Worker.bulbBinMax;
            }

            if (this.bezelBin <= Worker.bezelBinMin)
            {
                this.bezelBin = Worker.bezelBinMax;
            }


            // Now replace the test tray, if needed
            TestTray tt = this.kdb.TestTrays.Find(this.currentTestTrayId);

            if (tt.IsCompleted)
            {
                // Grab a new test tray
                TestTray newtt = new TestTray();
                newtt.IsCompleted      = false;
                newtt.IsCurrentlyInUse = true;
                this.kdb.TestTrays.Add(newtt);

                this.kdb.SaveChanges();
                this.currentTestTrayId = this.kdb.TestTrays.Count();
            }
        }
Exemple #3
0
        /*  DESCRIPTION :
         *  PARAMETERS  :
         *  ALTERS      :
         *  RETURNS     :
         */
        private bool simulateWorkOnDb()
        {
            // Get a hold of the current test tray we are working on
            TestTray tt = kdb.TestTrays.Find(this.currentTestTrayId);


            if (tt.IsCompleted)
            {
                // Tray is complete and we are still waiting on runner; return
                return(false);
            }



            int nextFogLampId = tt.FogLamps.Count + 1;



            while ((nextFogLampId <= 60) && (this.fogLampsMade > 0))
            {
                FogLamp fl = new FogLamp();
                fl.FogLampId = nextFogLampId;
                fl.ExperienceLevelOfAssembler = (int)this.experienceLevel;
                fl.TestTrayId = this.currentTestTrayId;

                kdb.FogLamps.Add(fl);

                nextFogLampId++;
                if (nextFogLampId == 61)
                {
                    // Mark tray as complete
                    tt.IsCompleted = true;
                }
            }


            this.kdb.Workstations.Find(this.wstation.WorkstationId).BezelAmount     = this.bezelBin;
            this.kdb.Workstations.Find(this.wstation.WorkstationId).BulbAmount      = this.bulbBin;
            this.kdb.Workstations.Find(this.wstation.WorkstationId).HarnessAmount   = this.harnessBin;
            this.kdb.Workstations.Find(this.wstation.WorkstationId).HousingAmount   = this.housingBin;
            this.kdb.Workstations.Find(this.wstation.WorkstationId).LensAmount      = this.lensBin;
            this.kdb.Workstations.Find(this.wstation.WorkstationId).ReflectorAmount = this.reflectorBin;


            kdb.SaveChanges();
            return(true);
        }
Exemple #4
0
        /*  DESCRIPTION :
         *  PARAMETERS  :
         *  ALTERS      :
         *  RETURNS     :
         */
        private bool simulateWorkOnDb()
        {
            // Get a hold of the current test tray we are working on
            TestTray tt = kdb.TestTrays.Find(this.currentTestTrayId);


            if (tt.IsCompleted)
            {
                // Tray is complete and we are still waiting on runner; return
                return(false);
            }



            int nextFogLampId = tt.FogLamps.Count + 1;



            while ((nextFogLampId <= 60) && (this.fogLampsMade > 0))
            {
                FogLamp fl = new FogLamp();
                fl.FogLampId = nextFogLampId;
                fl.ExperienceLevelOfAssembler = (int)this.experienceLevel;
                fl.TestTrayId = this.currentTestTrayId;

                kdb.FogLamps.Add(fl);

                nextFogLampId++;
                if (nextFogLampId == 61)
                {
                    // Mark tray as complete
                    tt.IsCompleted = true;
                }
            }


            kdb.SaveChanges();
            return(true);
        }
Exemple #5
0
        /*  DESCRIPTION :
         *  PARAMETERS  :
         *  ALTERS      :
         *  RETURNS     :
         */
        private bool setupWorkstation()
        {
            // Set up static maxes for each bin (retrieved from Config)
            Worker.harnessBinMax   = Int32.Parse(this.kdb.ConfigTables.Find("HarnessCapacity").SystemValue);
            Worker.reflectorBinMax = Int32.Parse(this.kdb.ConfigTables.Find("ReflectorCapacity").SystemValue);
            Worker.housingBinMax   = Int32.Parse(this.kdb.ConfigTables.Find("HousingCapacity").SystemValue);
            Worker.lensBinMax      = Int32.Parse(this.kdb.ConfigTables.Find("LensCapacity").SystemValue);
            Worker.bulbBinMax      = Int32.Parse(this.kdb.ConfigTables.Find("BulbCapacity").SystemValue);
            Worker.bezelBinMax     = Int32.Parse(this.kdb.ConfigTables.Find("BezelCapacity").SystemValue);

            // Set up static minimums for each bin (runner will refill bin if at this amount or lower)
            Worker.harnessBinMin   = Int32.Parse(this.kdb.ConfigTables.Find("HarnessMinimum").SystemValue);
            Worker.reflectorBinMin = Int32.Parse(this.kdb.ConfigTables.Find("ReflectorMinimum").SystemValue);
            Worker.housingBinMin   = Int32.Parse(this.kdb.ConfigTables.Find("HousingMinimum").SystemValue);
            Worker.lensBinMin      = Int32.Parse(this.kdb.ConfigTables.Find("LensMinimum").SystemValue);
            Worker.bulbBinMin      = Int32.Parse(this.kdb.ConfigTables.Find("BulbMinimum").SystemValue);
            Worker.bezelBinMin     = Int32.Parse(this.kdb.ConfigTables.Find("BezelMinimum").SystemValue);


            // Query to find an available workstation
            IQueryable <Workstation> queryWorkstations =
                from station in this.kdb.Workstations
                where station.IsCurrentlyWorking == false
                select station;


            // TODO: check that queryWorkstations actually returns smthn
            // If not, the worker cannot work!
            if (queryWorkstations.Any())
            {
                this.wstation = queryWorkstations.First();
                wstation.IsCurrentlyWorking = true;

                // Set each bin to whatever they were left at the workstation last time
                // If this is the first time this workstation is being used, it will be set
                //  to the capacities of each bin.
                this.harnessBin   = (int)wstation.HarnessAmount;
                this.reflectorBin = (int)wstation.ReflectorAmount;
                this.housingBin   = (int)wstation.HousingAmount;
                this.lensBin      = (int)wstation.LensAmount;
                this.bulbBin      = (int)wstation.BulbAmount;
                this.bezelBin     = (int)wstation.BezelAmount;


                // Set assembly time variance based on experience level
                switch (this.experienceLevel)
                {
                case ExperienceLevel_t.Rookie:
                    this.assemblyTimeVariance = Double.Parse(
                        this.kdb.ConfigTables.Find("RookieAssemblyTimeVariance").SystemValue);
                    break;

                case ExperienceLevel_t.Experienced:
                    this.assemblyTimeVariance = Double.Parse(
                        this.kdb.ConfigTables.Find("ExperiencedAssemblyTimeVariance").SystemValue);
                    break;

                case ExperienceLevel_t.Senior:
                    this.assemblyTimeVariance = Double.Parse(
                        this.kdb.ConfigTables.Find("SeniorAssemblyTimeVariance").SystemValue);
                    break;

                default:
                    this.assemblyTimeVariance = 0.0;
                    break;
                }

                // Now, grab a new test tray for this workstation
                // TODO: Check if any incomplete test trays have been left... grab that one instead
                IQueryable <TestTray> queryTestTrays =
                    from testt in this.kdb.TestTrays
                    where testt.IsCompleted == false
                    where testt.IsCurrentlyInUse == false
                    select testt;

                if (queryTestTrays.Any())
                {
                    // There is a test tray from before with some parts on it...
                    // Let's use it! How many parts are on it tho?
                    var query =
                        from thingy in this.kdb.TestTrays
                        join otherthingy in this.kdb.FogLamps on thingy equals otherthingy.TestTray
                        select new {
                        testTrayId    = thingy.TestTrayId,
                        fogLampsSoFar = thingy.FogLamps.Count
                    };
                    var firstAvailableTestTray = query.FirstOrDefault();

                    this.currentTestTrayId  = firstAvailableTestTray.testTrayId;
                    this.fogLampsOnTestTray = firstAvailableTestTray.fogLampsSoFar;

                    // Now find this particular test tray and make sure that it is in use
                    TestTray currtt = this.kdb.TestTrays.Find(this.currentTestTrayId);
                    currtt.IsCurrentlyInUse = true;
                }
                else
                {
                    this.kdb.TestTrays.Add(new TestTray());
                    this.currentTestTrayId  = this.kdb.TestTrays.Count() + 1;
                    this.fogLampsOnTestTray = 0;
                }


                this.kdb.SaveChanges();

                return(true);
            }

            else
            {
                // all workstations are taken up...
                // Don't let this Worker work!! Get outta here!!
                return(false);
            }
        }