コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            CuttingTool tool = new CuttingTool(assetId.Text, toolId.Text, serialNumber.Text);
            tool.Description = description.Text;
            tool.Manufacturers = manufacturers.Text;

            List<string> status = new List<string>();
            if (statusUsed.Checked)
                status.Add("USED");
            if (statusNew.Checked)
                status.Add("NEW");
            if (statusAllocated.Checked)
                status.Add("ALLOCATED");
            if (statusMeasured.Checked)
                status.Add("MEASURED");
            if (statusBroken.Checked)
                status.Add("BROKEN");
            tool.AddStatus(status.ToArray());

            MTConnect.CuttingTool.LifeType type = MTConnect.CuttingTool.LifeType.MINUTES;
            if (lifeType.Text == "PART_COUNT")
                type = MTConnect.CuttingTool.LifeType.PART_COUNT;
            else if (lifeType.Text == "WEAR")
                type = MTConnect.CuttingTool.LifeType.WEAR;

            MTConnect.CuttingTool.Direction dir = MTConnect.CuttingTool.Direction.UP;
            if (lifeDirection.Text == "DOWN")
                dir = MTConnect.CuttingTool.Direction.DOWN;

            tool.AddLife(type, dir, lifeValue.Text, lifeInitial.Text, lifeLimit.Text);

            tool.AddProperty("ProcessSpindleSpeed", new string[] 
                 { "nominal", speedNominal.Text,
                   "minimum", speedMin.Text,
                   "maximum", speedMax.Text}, speed.Text);

            tool.AddMeasurement("FunctionalLength", "LF", Double.Parse(lengthVal.Text), Double.Parse(lengthNom.Text),
                Double.Parse(lengthMin.Text), Double.Parse(lengthMax.Text));
            tool.AddMeasurement("CuttingDiameterMax", "DC", Double.Parse(diaVal.Text), Double.Parse(diaNom.Text),
                Double.Parse(diaMin.Text), Double.Parse(diaMax.Text));

            mAdapter.AddAsset(tool);

            this.Close();
        }
コード例 #2
0
        public void should_add_a_measurement()
        {
            CuttingTool tool = new CuttingTool("12345", "AAAA", "12345");
            tool.Description = "A tool description";
            tool.AddStatus(new string[] { "USED", "MEASURED" });

            tool.AddMeasurement("BodyDiameterMax", "BDX", 120.65, 120.60, 120.25, 120.70);

            tool.ToXml(writer);
            writer.WriteEndDocument();
            writer.Close();


            XElement cuttingTool = XElement.Parse(result.ToString());
            XElement life = cuttingTool.Element("CuttingToolLifeCycle");
            Assert.IsNotNull(life);
            XElement measurements = life.Element("Measurements");
            Assert.IsNotNull(measurements);
            XElement bdx = measurements.Element("BodyDiameterMax");
            Assert.IsNotNull(bdx);
            Assert.AreEqual("120.6", bdx.Attribute("nominal").Value);
            Assert.AreEqual("120.25", bdx.Attribute("minimum").Value);
            Assert.AreEqual("120.7", bdx.Attribute("maximum").Value);
            Assert.AreEqual("120.65", bdx.Value);            
        }