Esempio n. 1
0
        public HalRobotMotion Clone()
        {
            var buffer = MvUtil.SerializeBinary(this);
            var rtn    = MvUtil.DeserializeBinary <HalRobotMotion>(buffer);

            return(rtn);
        }
Esempio n. 2
0
        public int MvCfInit()
        {
            this.Mediater            = new MacMachineMediater();
            this.Mediater.MachineMgr = this;

            this.Config = MacMachineMgrCfg.LoadFromXmlFile();                 //先載入整機的Config

            this.HalContext = new MacHalContext(this.Config.ManifestCfgPath); //將Manifest路徑交給HalContext載入
            this.HalContext.MvCfInit();

            foreach (var row in this.Config.MachineCtrls)
            {
                //Create machine controller
                var machine = Activator.CreateInstance(row.MachineCtrlType.Type) as MacMachineCtrlBase;
                this.CtrlMachines[row.ID] = machine;

                //Initial machine controller
                machine.Mediater = this.Mediater;



                //Assign HAL to machine controller
                var hal = this.HalContext.HalDevices.Where(x => x.Value.ID == row.HalId).FirstOrDefault();
                machine.halAssembly = hal.Value as MacHalAssemblyBase;


                machine.halAssembly.HalConnect();
            }
            MvUtil.Foreach(this.CtrlMachines.Values, m => m.MvCfInit());

            return(0);
        }
Esempio n. 3
0
 public int MvCfFree()
 {
     this.MvCfFree();
     MvUtil.Foreach(this.CtrlMachines.Values, m => m.MvCfFree());
     this.DisposeSelf();
     return(0);
 }
Esempio n. 4
0
 public int MvCfUnload()
 {
     this.HalContext.MvCfUnload();
     MvUtil.Foreach(this.CtrlMachines.Values, m => m.MvCfUnload());
     return(0);
 }
Esempio n. 5
0
 protected virtual void DisposeSelf()
 {
     MvUtil.DisposeObjTry(this.CtrlMachines.Values);
 }
Esempio n. 6
0
        public void TestRobotPathSerialize()
        {
            var robotPath = new HalRobotPath()
            {
                Name   = "Test",
                Remark = "Test",
            };

            var robotMotion = new HalRobotMotion()
            {
                X          = 1.1f,
                Y          = 2.2f,
                Z          = 3.3f,
                W          = 4.4f,
                P          = 5.5f,
                R          = 6.6f,
                E1         = 7.7f,
                UserFrame  = 1,
                UserTool   = 1,
                Speed      = 60,
                MotionType = HalRobotEnumMotionType.Position,
            };

            robotPath.Motions.Add(robotMotion);

            robotMotion    = robotMotion.Clone();
            robotMotion.X += 1;
            robotPath.Motions.Add(robotMotion);

            robotMotion    = robotMotion.Clone();
            robotMotion.X += 1;
            robotPath.Motions.Add(robotMotion);



            MvUtil.SaveToXmlFile(robotPath, robotPath.Name + ".xml");
            var loadPath   = MvUtil.LoadFromXmlFile <HalRobotPath>(robotPath.Name + ".xml");
            var loadMotion = loadPath.Motions.LastOrDefault();



            Assert.AreEqual(robotMotion.X, loadMotion.X);
            Assert.AreEqual(robotMotion.Z, loadMotion.Z);
            Assert.AreEqual(robotMotion.Y, loadMotion.Y);
            Assert.AreEqual(robotMotion.W, loadMotion.W);
            Assert.AreEqual(robotMotion.P, loadMotion.P);
            Assert.AreEqual(robotMotion.R, loadMotion.R);
            Assert.AreEqual(robotMotion.E1, loadMotion.E1);

            Assert.AreEqual(robotMotion.J1, loadMotion.J1);
            Assert.AreEqual(robotMotion.J2, loadMotion.J2);
            Assert.AreEqual(robotMotion.J3, loadMotion.J3);
            Assert.AreEqual(robotMotion.J4, loadMotion.J4);
            Assert.AreEqual(robotMotion.J5, loadMotion.J5);
            Assert.AreEqual(robotMotion.J6, loadMotion.J6);
            Assert.AreEqual(robotMotion.J7, loadMotion.J7);

            Assert.AreEqual(robotMotion.UserFrame, loadMotion.UserFrame);
            Assert.AreEqual(robotMotion.UserTool, loadMotion.UserTool);
            Assert.AreEqual(robotMotion.Speed, loadMotion.Speed);
        }
Esempio n. 7
0
 public T GetDevConnStrEnum <T>(string key)
 {
     return(MvUtil.EnumParse <T>(this.DevSettings[key] as string));
 }
Esempio n. 8
0
 /// <summary>
 /// serialize (序列化) manifest object, and save as xml file
 /// </summary>
 /// <param name="cfg">MachineManifest object</param>
 /// <param name="filePath">xml file path for saving</param>
 public static void SaveToXmlFile(MacMachineMgrCfg cfg, string filePath)
 {
     MvUtil.SaveToXmlFile <MacMachineMgrCfg>(cfg, filePath);
 }
Esempio n. 9
0
 /// <summary>
 /// deserialize (反序列化) MachineManifest object from xml file
 /// </summary>
 /// <param name="filePath">xml file path for loading</param>
 /// <returns></returns>
 public static MacMachineMgrCfg LoadFromXmlFile(string filePath = "../../UserData/MachineMgr.config")
 {
     return(MvUtil.LoadFromXmlFile <MacMachineMgrCfg>(filePath));
 }
Esempio n. 10
0
 public void SaveToXmlFile(string fn)
 {
     MvUtil.SaveToXmlFile(this, fn);
 }
Esempio n. 11
0
 /// <summary>
 /// serialize (序列化) manifest object, and save as xml file
 /// </summary>
 /// <param name="manifest">MachineManifest object</param>
 /// <param name="filePath">xml file path for saving</param>
 public static void SaveToXmlFile(MacManifestCfg manifest, string filePath)
 {
     MvUtil.SaveToXmlFile <MacManifestCfg>(manifest, filePath);
 }
Esempio n. 12
0
 /// <summary>
 /// deserialize (反序列化) MachineManifest object from xml file
 /// </summary>
 /// <param name="filePath">xml file path for loading</param>
 /// <returns></returns>
 public static MacManifestCfg LoadFromXmlFile(string filePath)
 {
     return(MvUtil.LoadFromXmlFile <MacManifestCfg>(filePath));
 }