Example #1
0
        /// <summary>結果に指定情報が含まれているかチェックする </summary>
        /// <param name="cdata">パーセプトロン結果ファイル</param>
        /// <param name="InspecName">計測名 Nut1,Hole1など</param>
        /// <param name="element">計測要素 X,Y..など</param>
        /// <param name="pCharacteristic">計測要素の結果格納先</param>
        /// <returns>計測要素が存在する場合は true</returns>
        public static bool IsContains(CPerceptronData cdata, string InspecName, string element, out CInspectionCharacteristic pCharacteristic)
        {
            CInspectionCharacteristic chara = null;
            var ans = false;

            //結果にInspecNameがない場合
            if (cdata.Inspections.All(d => d.name != InspecName))
            {
                pCharacteristic = null;
                return(false);
            }

            //InspecNameで、elementを検索し、合致すれば返す
            var dInspec = cdata.Inspections.First(d => d.name == InspecName);

            if (dInspec.CInspectionCharacteristics.Any(d => d.defaultName == element))
            {
                chara = dInspec.CInspectionCharacteristics.First(d => d.defaultName == element);
                ans   = true;
            }

            //var ans = cdata.Inspections.Any(d =>
            //{
            //    if (d.CInspectionCharacteristics.Any(dd => dd.defaultName == element))
            //    {
            //        chara = d.CInspectionCharacteristics.First(ddd => ddd.defaultName == element);
            //        return true;
            //    }
            //    else
            //    {
            //        return false;
            //    }
            //});

            pCharacteristic = chara;
            return(ans);
        }
Example #2
0
        //xmlファイルを解析して、データを取得する
        public static CPerceptronData LoadFromFile(string fname)
        {
            //Trace.WriteLine(STConst + System.Reflection.MethodBase.GetCurrentMethod().Name);

            //xmlファイルを読み込む
            var xmlData = XElement.Load(fname);

            var ans = new CPerceptronData();

            ans.Cell    = new string[1];
            ans.Cell[0] = xmlData.Element("cell").Element("name").Value;

            ans.Parttype    = new string[1];
            ans.Parttype[0] = xmlData.Element("parttype").Element("name").Value;

            var date = new CPerceptronDate();

            date.year  = int.Parse(xmlData.Element("cycle").Element("date").Element("year").Value);
            date.month = int.Parse(xmlData.Element("cycle").Element("date").Element("month").Value);
            date.day   = int.Parse(xmlData.Element("cycle").Element("date").Element("day").Value);

            var time = new CPerceptronTime();

            time.hour   = int.Parse(xmlData.Element("cycle").Element("time").Element("hour").Value);
            time.minute = int.Parse(xmlData.Element("cycle").Element("time").Element("minute").Value);
            time.second = int.Parse(xmlData.Element("cycle").Element("time").Element("second").Value);

            var partid = new CPerceptronPartID();

            partid.partID    = xmlData.Element("cycle").Element("partid").Element("name").Value;
            partid.partValue = xmlData.Element("cycle").Element("partid").Element("value").Value;

            var processid = new CPerceptronProcessID();

            processid.ProcessID    = xmlData.Element("cycle").Element("processid").Element("name").Value;
            processid.ProcessValue = xmlData.Element("cycle").Element("processid").Element("value").Value;

            ans.Cycle           = new CPerceptronCycle();
            ans.Cycle.Date      = date;
            ans.Cycle.PTime     = time;
            ans.Cycle.PartID    = partid;
            ans.Cycle.ProcessID = processid;

            var ins = xmlData.Elements("inspectionpoint").ToArray();

            var insList = new List <CInspectionPoint>();

            foreach (var xElement in ins)
            {
                var inspect = new CInspectionPoint();
                inspect.name        = xElement.Element("name").Value;
                inspect.featuretype = xElement.Element("featuretype").Value;
                inspect.CInspectionCharacteristics = new List <CInspectionCharacteristic>();

                foreach (var chara in xElement.Elements("characteristic"))
                {
                    var characteristic = new CInspectionCharacteristic();
                    characteristic.defaultName = chara.Element("defaultname").Value;
                    characteristic.aliasName   = chara.Element("aliasname").Value;

                    //characteristic.Measurement = new CMeasurement();
                    //characteristic.Measurement.abusolute =
                    //    double.Parse(chara.Elements("measurement").First().Element("deviation").Value);
                    //characteristic.Measurement.nominal =
                    //    double.Parse(chara.Elements("measurement").First().Element("nominal").Value);
                    //characteristic.Measurement.abusolute =
                    //    double.Parse(chara.Elements("measurement").First().Element("absolute").Value);

                    characteristic.Measurement           = new CMeasurementString();
                    characteristic.Measurement.abusolute =
                        chara.Elements("measurement").First().Element("deviation").Value;
                    characteristic.Measurement.nominal =
                        chara.Elements("measurement").First().Element("nominal").Value;
                    characteristic.Measurement.abusolute =
                        chara.Elements("measurement").First().Element("absolute").Value;


                    inspect.CInspectionCharacteristics.Add(characteristic);
                }
                //inspect.CInspectionCharacteristics = clist.ToArray();
                insList.Add(inspect);
            }

            ans.Inspections = insList;

            return(ans);
        }