Esempio n. 1
0
        private static List <Weld> CreateWelds(List <long> pipeIDs)
        {
            List <Weld> welds = new List <Weld>();

            using (StreamWriter sw = File.CreateText(WELD_FILE))
            {
                int p = 0;

                for (int i = 0; i < parsedArgs.NumWelds; i++)
                {
                    long pipe1ID = pipeIDs[p];
                    p = (p + 1) % pipeIDs.Count;
                    long pipe2ID = pipeIDs[p];
                    Weld weld    = GenerateWeld(pipe1ID, pipe2ID);
                    welds.Add(weld);
                }
            }

            foreach (Weld weld in welds)
            {
                List <WeldPart> parts = new List <WeldPart>();

                for (int j = 0; j < NUM_WELD_PASSES; j++)
                {
                    WeldPart part = GenerateWeldPart(weld.WeldID);
                    parts.Add(part);
                }

                weld.WeldParts = parts.ToArray();
            }

            foreach (Weld weld in welds)
            {
                List <WeldInspection> inspections = new List <WeldInspection>();

                for (int j = 0; j < NUM_WELD_INSPECTIONS; j++)
                {
                    WeldInspection insp = GenerateWeldInspection(weld.WeldID);
                    inspections.Add(insp);
                }

                weld.WeldInspections = inspections.ToArray();
            }

            return(welds);
        }
Esempio n. 2
0
        private static WeldPart GenerateWeldPart(long weldID)
        {
            long weldPartID = GetNextID();

            WeldPart weldPart = new WeldPart()
            {
                WeldPartID             = weldPartID,
                WeldID                 = weldID,
                JobID                  = parsedArgs.JobID,
                CreatedDate            = DateTime.Now,
                LastUpdated            = DateTime.Now,
                MachineBugID1          = "machine bug id 1",
                MachineBugID2          = "machine bug id 2",
                MachineID              = "machine id",
                Position               = "left",
                Position2              = "right",
                WelderName             = "Rock Strongo",
                VisualInspectionPassed = true,
                Types                  = new WeldPartType[]
                {
                    new WeldPartType()
                    {
                        Type = "Root", WeldPartID = weldPartID, WeldPartTypeID = GetNextID()
                    },
                    new WeldPartType()
                    {
                        Type = "Repair", WeldPartID = weldPartID, WeldPartTypeID = GetNextID()
                    }
                }
            };

            weldPart.WeldPartDocuments = new WeldPartDocument[1];

            //calibration image will either be a hard image or a reference number
            if (rand.Next() % 2 == 0)
            {
                weldPart.CalibrationImage1ID = calibrationImages[rand.Next(0, calibrationImages.Count)].CalibrationImageID;
            }
            else
            {
                weldPart.CalibrationRefNum1 = "refnum_" + GetNextID();
            }

            //calibration image will either be a hard image or a reference number
            if (rand.Next() % 2 == 0)
            {
                weldPart.CalibrationImage2ID = calibrationImages[rand.Next(0, calibrationImages.Count)].CalibrationImageID;
            }
            else
            {
                weldPart.CalibrationRefNum2 = "refnum_" + GetNextID();
            }

            //half of the documents will be reference docs
            if (rand.Next() % 2 == 0)
            {
                string refNum = "refnum_" + GetNextID();
                weldPart.WeldPartDocuments[0] = GenerateWeldPartDoc(weldPartID, refNum);
            }
            else
            {
                weldPart.WeldPartDocuments[0] = GenerateWeldPartDoc(weldPartID);
            }

            return(weldPart);
        }