Example #1
0
 public TargetCommunication()
 {
     this.TargetPC = new xPCTargetPC();
     this.TargetPC.TcpIpTargetAddress   = TargetIPaddress;
     this.TargetPC.TcpIpTargetPort      = TargetPort;
     this.TargetPC.CommunicationTimeOut = ModelConstants.REBOOT_TIMEOUT_PERIOD;
 }
Example #2
0
 /// <summary>
 /// Constructor for generic Simulink RT controller
 /// </summary>
 /// <param name="ipAdress">IP Adress of the controller</param>
 /// <param name="port">Port used to communicate with the controller</param>
 public SimulinkRTController(string ipAdress, string port)
 {
     //this.State = ControllerState.Error;
     _tg = new xPCTargetPC();
     _ipAdress = ipAdress;
     _port = port;
 }
Example #3
0
        public void TargetConnectionTests()
        {
            _targetPC = new xPCTargetPC();
            _targetPC.TcpIpTargetAddress = "192.168.7.1";
            _targetPC.TcpIpTargetPort    = "22222";
            _targetPC.Connect();

            _targetApplication = _targetPC.Load();
        }
Example #4
0
        void demo()
        {
            // xPCTargetPC设置IP和端口
            xPCTargetPC xPCTarget = new xPCTargetPC();

            xPCTarget.TcpIpTargetAddress = "192.168.88.189";
            xPCTarget.TcpIpTargetPort    = "22222";
            try
            {
                // 建立连接
                xPCTarget.Connect();
                if (xPCTarget.IsConnected == true)
                {
                    Console.WriteLine(true);
                    // 装载模型,并获取target机的应用
                    xPCApplication           application = xPCTarget.Load("C:\\Users\\Closer\\Desktop\\matlab\\xpctank1.dlm");
                    xPCTargetScopeCollection tScopes     = application.Scopes.TargetScopes;
                    tScopes.Refresh();

                    // 指定参数
                    xPCParameters param = xPCTarget.Application.Parameters;
                    // 先清空参数
                    param.Refresh();
                    // 获取参数的坐标和参数名
                    xPCParameter p      = param["SetPoint", "Value"];
                    Double[]     values = new Double[] { 5.0 };
                    // 指定参数值
                    p.SetParam(values);

                    // 设置采样时间
                    application.SampleTime = 0.01;
                    // 设置结束时间 单位秒  -1是永不停止
                    application.StopTime = 60;
                    // target机开始运行
                    application.Start();
                }
                else
                {
                    //Call the Disconnect methods to close the communication channel with the target PC.
                    xPCTarget.Disconnect();
                }
            }
            catch (xPCException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #5
0
 public Form1()
 {
     xPCTarget = new xPCTargetPC();
     InitializeComponent();
 }