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();
        }
Example #2
0
        public void should_add_a_generic_property()
        {
            CuttingTool tool = new CuttingTool("12345", "AAAA", "12345");
            tool.Description = "A tool description";
            tool.AddProperty("ProcessSpindleSpeed",
                            new string[] { "minimum", "1000", "maximum", "10000", },
                            "2500");

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

            XElement cuttingTool = XElement.Parse(result.ToString());
            XElement life = cuttingTool.Element("CuttingToolLifeCycle");
            Assert.IsNotNull(life);
            XElement prop = life.Element("ProcessSpindleSpeed");
            Assert.IsNotNull(prop);
            Assert.AreEqual("1000", prop.Attribute("minimum").Value);
            Assert.AreEqual("10000", prop.Attribute("maximum").Value);
            Assert.AreEqual("2500", prop.Value);
        }
Example #3
0
        public void should_send_cutting_tool()
        {
            Event avail = new Event("avail");
            adapter.AddDataItem(avail);
            avail.Value = "AVAILABLE";
            adapter.SendChanged();

            adapter.addClientStream(stream);
            long pos = stream.Position;

            CuttingTool tool = new CuttingTool("12345", "AAAA", "12345");
            tool.Description = "A tool description";
            tool.AddProperty("ProcessSpindleSpeed",
                            new string[] { "minimum", "1000", "maximum", "10000", },
                            "2500");
            tool.AddStatus(new string[] { "USED", "MEASURED" });

            adapter.AddAsset(tool);

            stream.Seek(pos, SeekOrigin.Begin);
            byte[] buffer = new byte[1024];
            int count = stream.Read(buffer, 0, 1024);
            String line = encoder.GetString(buffer, 0, count);
            Assert.IsTrue(line.EndsWith("|@ASSET@|12345|CuttingTool|--multiline--ABCD\n<CuttingTool toolId=\"AAAA\" serialNumber=\"12345\" assetId=\"12345\"><Description>A tool description</Description><CuttingToolLifeCycle><ProcessSpindleSpeed minimum=\"1000\" maximum=\"10000\">2500</ProcessSpindleSpeed><CutterStatus><Status>USED</Status><Status>MEASURED</Status></CutterStatus></CuttingToolLifeCycle></CuttingTool>\n--multiline--ABCD\n"));
        }