Esempio n. 1
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"));
        }
        public void should_add_tool_life()
        {
            CuttingTool tool = new CuttingTool("12345", "AAAA", "12345");

            tool.Description = "A tool description";
            tool.AddStatus(new string[] { "USED", "MEASURED" });

            tool.AddLife(CuttingTool.LifeType.MINUTES, CuttingTool.Direction.UP, "100", "0", "200", "175");

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

            XElement cuttingTool = XElement.Parse(result.ToString());
            XElement cycle       = cuttingTool.Element("CuttingToolLifeCycle");

            Assert.IsNotNull(cycle);
            XElement life = cycle.Element("ToolLife");

            Assert.IsNotNull(life);
            Assert.AreEqual("0", life.Attribute("initial").Value);
            Assert.AreEqual("200", life.Attribute("limit").Value);
            Assert.AreEqual("175", life.Attribute("warning").Value);
            Assert.AreEqual("100", life.Value);
            Assert.AreEqual("MINUTES", life.Attribute("type").Value);
            Assert.AreEqual("UP", life.Attribute("countDirection").Value);
        }
        public void should_add_a_status()
        {
            CuttingTool tool = new CuttingTool("12345", "AAAA", "12345");

            tool.Description = "A tool description";
            tool.AddStatus(new string[] { "USED", "MEASURED" });

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

            XElement cuttingTool = XElement.Parse(result.ToString());
            XElement life        = cuttingTool.Element("CuttingToolLifeCycle");

            Assert.IsNotNull(life);
            XElement status = life.Element("CutterStatus");

            Assert.IsNotNull(status);
            XNode child = status.FirstNode;

            Assert.AreEqual("USED", ((XElement)child).Value);
            XNode next = child.NextNode;

            Assert.AreEqual("MEASURED", ((XElement)next).Value);
        }
        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);
        }
Esempio n. 5
0
    private Vector3 GetCollisionPoint(CuttingTool knife)
    {
        Vector3 distToObject = transform.position - knife.Origin;
        Vector3 proj         = Vector3.Project(distToObject, knife.BladeDirection);

        Vector3 collisionPoint = knife.Origin + proj;

        return(collisionPoint);
    }
Esempio n. 6
0
    public void EnableCut(Transform cuttingSrc, Collider cuttingSrcCollider)
    {
        canCut            = true;
        cuttingSrcExtents = cuttingSrcCollider.bounds.extents.magnitude;
        this.cuttingSrc   = cuttingSrc.GetComponent <CuttingTool>();
        hits = 0;

        Heating heatScript = GetComponent <Heating>();

        hitsToCut = (heatScript != null ? (int)(19.0f * (1.0f - DeformableBase.FindClosestHeatFactor(heatScript, cuttingSrc.position))) + 1 : defaultHitsToCut);

        if (deformableMesh)
        {
            deformableMesh.enabled = false;
        }
    }
Esempio n. 7
0
    private IEnumerator Slice(CuttingTool knife)
    {
        // The call from OnTriggerEnter, so some object positions are wrong.
        // We have to wait for next frame to work with correct values
        yield return(null);

        Vector3 point  = GetCollisionPoint(knife);
        Vector3 normal = Vector3.Cross(knife.MoveDirection, knife.BladeDirection);
        Plane   plane  = new Plane(normal, point);

        if (_sliceableAsync != null)
        {
            knife.BeginNewSlice();

            _sliceableAsync.Slice(plane, knife.SliceID, null);
        }
    }
        public void should_create_xml_document()
        {
            CuttingTool tool = new CuttingTool("12345", "AAAA", "12345");

            tool.Description   = "A tool description";
            tool.Manufacturers = "SMPY";

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

            XElement cuttingTool = XElement.Parse(result.ToString());

            Assert.AreEqual("CuttingTool", cuttingTool.Name.ToString());
            Assert.AreEqual("12345", cuttingTool.Attributes("assetId").First().Value);
            Assert.AreEqual("A tool description", cuttingTool.XPathSelectElement("//Description").Value);
            Assert.AreEqual("SMPY", cuttingTool.Attributes("manufactures").First().Value);
        }
Esempio n. 9
0
        private void AddToolEventClick(object sender, RoutedEventArgs e)
        {
            //Create the tool
            CuttingTool SomeTool = new CuttingTool()
            {
                ToolName     = toolNameTextBx.Text,
                ToolDiameter = double.Parse(tooldiaTextBx.Text),
                ToolType     = toolfuncTextBx.Text
            };


            // initialize to connect to db

            using (SQLiteConnection tooldbConnection = new SQLiteConnection(App.DatabasePath))
            {
                tooldbConnection.CreateTable <CuttingTool>();
                tooldbConnection.Insert(SomeTool);
            };
            // make connection and write to db

            Close();
        }
        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);
        }
Esempio n. 11
0
 private void CuttingButtonClick(object sender, EventArgs e)
 {
     outputPanel.Add(CuttingTool.Build());
     Invalidate(true);
 }
Esempio n. 12
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();
        }
        public void should_add_cutting_item()
        {
            CuttingTool tool = new CuttingTool("12345", "AAAA", "12345");

            tool.Description = "A tool description";
            tool.AddStatus(new string[] { "USED", "MEASURED" });

            CuttingTool.CuttingItem item = new CuttingTool.CuttingItem("1-10", null, "440", "KMT");
            item.Description = "An insert";
            item.AddProperty("Locus", "22");
            item.AddLife(CuttingTool.LifeType.MINUTES, CuttingTool.Direction.UP, "100", "0", "150");
            item.AddMeasurement("FunctionalLength", "LF", 100);
            tool.AddItem(item);

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

            XElement cuttingTool = XElement.Parse(result.ToString());
            XElement cycle       = cuttingTool.Element("CuttingToolLifeCycle");

            Assert.IsNotNull(cycle);
            XElement cuttingItems = cycle.Element("CuttingItems");

            Assert.IsNotNull(cuttingItems);
            XElement cuttingItem = cuttingItems.Element("CuttingItem");

            Assert.IsNotNull(cuttingItem);

            Assert.AreEqual("1-10", cuttingItem.Attribute("indices").Value);
            Assert.AreEqual("440", cuttingItem.Attribute("grade").Value);
            Assert.AreEqual("KMT", cuttingItem.Attribute("manufacturers").Value);

            XElement desc = cuttingItem.Element("Description");

            Assert.IsNotNull(desc);
            Assert.AreEqual("An insert", desc.Value);

            XElement locus = cuttingItem.Element("Locus");

            Assert.IsNotNull(locus);
            Assert.AreEqual("22", locus.Value);


            XElement life = cuttingItem.Element("ItemLife");

            Assert.IsNotNull(life);
            Assert.AreEqual("MINUTES", life.Attribute("type").Value);
            Assert.AreEqual("100", life.Value);

            XElement measurements = cuttingItem.Element("Measurements");

            Assert.IsNotNull(measurements);
            XElement lf = measurements.Element("FunctionalLength");

            Assert.IsNotNull(lf);
            Assert.IsNull(lf.Attribute("warning"));
            Assert.IsNull(lf.Attribute("initial"));
            Assert.IsNull(lf.Attribute("limit"));
            Assert.AreEqual("100", lf.Value);
        }