예제 #1
0
        private string AddDelay(IPathEntity pe)
        {
            var    dpe         = pe as DelayPathEntity;
            string delayString = machineCodes.DelayAmountPrefix + (dpe.Delay * machineCodes.DelayScaleFactor).ToString(machineCodes.DelayStringFormat);

            return(machineCodes.Delay + delayString);
        }
예제 #2
0
        private string BuildLine(IPathEntity pe)
        {
            string line = "";

            switch (pe.Type)
            {
            case BlockType.CCWARC:
            case BlockType.CWARC:
            case BlockType.LINEAR:
            case BlockType.RAPID:
                line = AddMove(pe);
                break;

            case BlockType.COMMAND:
                line = AddCommand(pe);
                break;

            case BlockType.COMMENT:
                line = AddComment(pe);
                break;

            case BlockType.DELAY:
                line = AddDelay(pe);
                break;
            }
            return(line);
        }
예제 #3
0
        private string AddComment(IPathEntity pe)
        {
            var comment = pe.Comment;

            if (comment.Length > machineCodes.CommentMaxLength)
            {
                comment = comment.Substring(0, machineCodes.CommentMaxLength);
            }
            return(machineCodes.ComStart + comment + machineCodes.ComEnd);
        }
예제 #4
0
        private void Awake()
        {
            playerPathFollower = GetComponent <IPlayerPathFollower>();
            pathEntity         = FindObjectsOfType <MonoBehaviour>().OfType <IPathEntity>().FirstOrDefault();
            mainCamera         = Camera.main;
            virtualPlane.SetNormalAndPosition(Vector3.forward, new Vector3(0f, 0f, 0f));
            var screenAspect = (float)Screen.width / (float)Screen.height;
            var cameraHeight = mainCamera.orthographicSize * 2;

            cameraBounds = new Bounds(new Vector3(0f, 0f, 0f), new Vector3(cameraHeight * screenAspect - 1f, cameraHeight - 1f, 0f));
        }
예제 #5
0
 private void AddEntity(IPathEntity pe)
 {
     if (toolpath.Count > 0)
     {
         pe.PrevPosition = new CNCLib.MachinePosition(toolpath.Last().Position);
     }
     else
     {
         pe.PrevPosition = new CNCLib.MachinePosition(pe.Position);
     }
     toolpath.Add(pe);
 }
예제 #6
0
 private void AppendPositions(IPathEntity pe, ref StringBuilder line)
 {
     line.Append("X");
     line.Append(pe.Position.X.ToString(machineCodes.LinearAxisFormat) + machineCodes.Sp);
     line.Append("Y");
     line.Append(pe.Position.Y.ToString(machineCodes.LinearAxisFormat) + machineCodes.Sp);
     line.Append("Z");
     line.Append(pe.Position.Z.ToString(machineCodes.LinearAxisFormat) + machineCodes.Sp);
     line.Append("B");
     line.Append(pe.Position.Bdeg.ToString(machineCodes.RotaryAxisFormat) + machineCodes.Sp);
     line.Append("C");
     line.Append(pe.Position.Cdeg.ToString(machineCodes.RotaryAxisFormat) + machineCodes.Sp);
 }
예제 #7
0
        private string AddMove(IPathEntity pe)
        {
            StringBuilder line = new StringBuilder();

            AppendLineNumber(ref line);
            AppendGCode(pe.Type, ref line);
            AppendPositions(pe, ref line);
            if (pe.Type != BlockType.RAPID)
            {
                AppendFeedrate(pe.Feedrate, ref line);
            }

            return(line.ToString());
        }
예제 #8
0
        public ToolPath ParsePath(List <string> file)
        {
            jeton = false;
            int pathNumber = 0;

            foreach (string line in file)
            {
                BlockType blockT;

                if (!jeton)
                {
                    jeton = IsPathStart(line);
                }
                else
                {
                    jeton = !IsPathEnd(line);
                }

                if (IsPath(line, out blockT))
                {
                    IPathEntity pe = parseString(line, blockT, jeton);


                    path.Add(pe);
                    pathNumber++;
                }
            }
            for (int i = 1; i < path.Count; i++)
            {
                if (path[i].JetOn && !path[i - 1].JetOn)
                {
                    path[i - 1].JetOn          = true;
                    path[i - 1].Feedrate.Value = path[i].Feedrate.Value;
                }
            }
            //calc arc sweep angle and travel time for each segment


            CalcPathLengths();
            FillMissingCoords();
            return(path);
        }
예제 #9
0
 private void Awake()
 {
     pathEntity               = GetComponent <IPathEntity>();
     lineRenderer             = GetComponent <LineRenderer>();
     pathEntity.OnPathUpdate += OnPathUpdate;
 }
예제 #10
0
 public bool Remove(IPathEntity item)
 {
     return(data.Remove(item));
 }
예제 #11
0
 public bool Contains(IPathEntity item)
 {
     return(data.Contains(item));
 }
예제 #12
0
 public void Add(IPathEntity item)
 {
     data.Add(item);
 }
예제 #13
0
 public void Insert(int index, IPathEntity item)
 {
     data.Insert(index, item);
 }
예제 #14
0
 public int IndexOf(IPathEntity item)
 {
     return(data.IndexOf(item));
 }
 private void Awake()
 {
     pathEntity           = FindObjectsOfType <MonoBehaviour>().OfType <IPathEntity>().FirstOrDefault();
     playerCircleEntity   = GetComponent <IPlayerCircleEntity>();
     playerCircleMovement = GetComponent <IPlayerCircleMovement>();
 }
예제 #16
0
 private string AddCommand(IPathEntity pe)
 {
     //TODO return mcode from string and state
     return("Command Not implemented");
     // return machine.getMcode(m, state);
 }