Пример #1
0
        public static PosXYZU Create(string posStr)
        {
            var data = posStr.Split(',');

            int i = 0;
            var p = new PosXYZU();

            p.Index       = int.Parse(data[i++]);
            p.Name        = data[i++];
            p.X           = double.Parse(data[i++]);
            p.Y           = double.Parse(data[i++]);
            p.Z           = double.Parse(data[i++]);
            p.U           = double.Parse(data[i++]);
            p.OffsetX     = double.Parse(data[i++]);
            p.OffsetY     = double.Parse(data[i++]);
            p.OffsetZ     = double.Parse(data[i++]);
            p.OffsetU     = double.Parse(data[i++]);
            p.Status      = bool.Parse(data[i++]);
            p.Description = data[i++];
            p.Flag1       = int.Parse(data[i++]);
            p.Flag2       = int.Parse(data[i++]);
            p.Flag3       = int.Parse(data[i++]);

            return(p);
        }
Пример #2
0
        public void LoadPts(string file)
        {
            using (var fs = new FileStream(file, FileMode.Open))
            {
                using (var sr = new StreamReader(fs))
                {
                    //find platform pos start line
                    var line = sr.ReadLine();
                    if (line != null && line.StartsWith(Name))
                    {
                        var propCount = PosType.GetProperties().Length;

                        //start read pos lines
                        line = sr.ReadLine();
                        while (!string.IsNullOrEmpty(line))
                        {
                            var data = line.Split(',');
                            if (data.Length == propCount)
                            {
                                if (PosType == typeof(PosXYZ))
                                {
                                    Positions.Add(PosXYZ.Create(line));
                                }
                                else if (PosType == typeof(PosXYZU))
                                {
                                    Positions.Add(PosXYZU.Create(line));
                                }
                                else if (PosType == typeof(PosXYZUVW))
                                {
                                    Positions.Add(PosXYZUVW.Create(line));
                                }
                                else
                                {
                                    //pos type error
                                }
                            }
                            else
                            {
                                //pos prop length error
                                MessageBox.Show($"{line} Props Count Error");
                            }

                            line = sr.ReadLine();
                        }
                    }
                }
            }
        }
Пример #3
0
        public override void TeachPos(string name)
        {
            var curpos = new PosXYZU(CurPos);

            if (Positions.Exists(p => p.Name == name))
            {
                var teachpos = Positions.FirstOrDefault(p => p.Name == name);
                teachpos?.Update(curpos.Data());
            }
            else
            {
                curpos.Name = name;

                Positions.Add(curpos);
            }
        }