ADAMS与外部程序通信(Adams Command Server)

Issuing Commands
import socket client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 5002)) # formulate valid Adams View command language that starts with the string "cmd"
cmd = "cmd point create point_name = POINT__1 location = 10 , 15 , 10 relative_to = ground "
client_socket.send(cmd) # receives feedback from the server. The server responds with the string "cmd: 0" for successful command processing
response = client_socket.recv(1024) print response
# Returns: cmd: 0 (on success) cmd: 1 (error detected in View command)
cmd指令在相对于ground的(10, 15, 10)位置处创建了一个点,命名为POINT_1:


import socket
import time cmds = ["cmd variable create variable_name=integer_numbers integer_value=12 range=10,20",
"cmd variable set variable_name=integer_numbers integer_value=16"] # Each command must be sent to the server over a new socket
for cmd in cmds:
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
start_time = time.time()
dt = time.time() - start_time
while dt < 60: # wait for a new server connection:
dt = time.time() - start_time
try:
client_socket.connect(("localhost", 5002))
break
except socket.error:
pass print "Connected to socket, sending cmd: %s" % cmd
client_socket.send(cmd)
data = client_socket.recv(1024)
print "Response from cmd was: %s" % data

Issuing Queries
下面代码查询了零件PART_2的位置信息:
import socket # create a socket & connect to the proper port/host
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 5002)) # queries must always start with the string "query" followed by an Adams View expression
the_query = "query part_2.location"
client_socket.send(the_query) # server replies with a description of the data
query_description = client_socket.recv(1024) # Description of result: query: float : 3 : 12 # server waits for an "OK" command before sending the actual data
client_socket.send("OK")
query_data = client_socket.recv(1024) # accepts the actual server data # parse query data based on type:
description_list = query_description.split(':')
data_type = description_list[1]
data_length = int(description_list[2])
data_bytes = int(description_list[3]) print "Query returned %i values of data type %s" % (data_length, data_type)
print "Query data as a string is: %s" % query_data
输出如下:

ADAMS与外部程序通信(Adams Command Server)的更多相关文章
- Hadoop源码解析之 rpc通信 client到server通信
rpc是Hadoop分布式底层通信的基础,无论是client和namenode,namenode和datanode,以及yarn新框架之间的通信模式等等都是采用的rpc方式. 下面我们来概要分析一下H ...
- JAVA ANDROID SOCKET通信检测(SERVER)连接是否断开
Pre 解决思路 代码后记: 客户端app上的部分代码 调用: 服务器上: 客户端判断服务器是否还活着代码: PRE 在利用socket写通讯程序的时候,想检测服务器是否还活着. 从网上找了很多资料, ...
- C# 管道通信 (client —— server)Framework2.0版本也可用
//管道服务类public class PipServer { [DllImport("kernel32.dll", SetLastError = true)] public st ...
- iSight集成Adams/View:Adams组件
iSight本身支持特定版本的Adams/View,在Adams中添加isight的插件方法如下: 1.在iSight安装目录下搜索isight.bin文件,将其复制到Adams安装路径下的win32 ...
- adams/car 怎么进入template builder模块
打开C:\Documents and Settings\Administrator文件夹下的acar.cfg文件,将 Desired user mode (standard/expert)ENVIRO ...
- TCP/UDP通信中server和client是如何知道对方IP地址的
在TCP通信中 client是主动连接的一方,client对server的IP的地址提前已知的.如果是未知则是没办法通信的. server是在accpet返回的时候知道的,因为数据包中包含客户端的IP ...
- 用PHP的socket实现客户端到服务端的通信
服务端 <?php error_reporting(E_ALL); set_time_limit(0); ob_implicit_flush(); //本地IP $address = 'loca ...
- Socket编程之聊天程序 - 模拟Fins/ModBus协议通信过程
设备控制软件编程涉及到的基本通信方式主要有TCP/IP与串口,用到的数据通信协议有Fins与ModBus. 更高级别的通信如.net中的Remoting与WCF在进行C/S架构软件开发时会采用. 本篇 ...
- Erlang下与其他程序和语言的通信机制(1)
在Erlang运行时中,提供了几种机制来实现与其它程序或者语言的通信.一种为分布式Erlang,一种为端口,其中端口分为普通端口和链入式驱动端口,还有后面引入的NIFs. 分布式Erlang:一个Er ...
随机推荐
- .Net Excel操作之NPOI(二)常用操作封装
一.Excel数据导出常用操作 1.指定表头和描述 2.指定数据库中读出的数据集合 二.ExcelExport封装 /// <summary> /// Excel常用的表格导出逻辑封装 / ...
- Intel的AVX2指令集解读
原文链接:http://blog.csdn.net/vbskj/article/details/38408213 在Intel Sandy Bridge微架构中,Intel引入了256位SIMD扩展A ...
- Oracle选择性系统授权
Selective System Grants 问题: 我只想授予XX用户alter system set user_dump_dest 权限! I want to give users the ab ...
- 相声段子:How Are You
/**************************************************************** File name : HowAreYou Author : 叶飞影 ...
- maven-shade-plugin 入门指南
1. Why? 通过 maven-shade-plugin 生成一个 uber-jar,它包含所有的依赖 jar 包. 2. Goals Goal Description shade:help Dis ...
- C++11 std::shared_ptr总结与使用
最近看代码,智能指针用的比较多,自己平时用的少,周末自己总结总结.方便后续使用. std::shared_ptr大概总结有以下几点: (1) 智能指针主要的用途就是方便资源的管理,自动释放没有指针引用 ...
- C++ 模板学习 函数模板、类模板、迭代器模板
使用模板能够极大到使得代码可重用. 记录一下,方便后续使用. 1. 函数模板,支持多种类型参数 #include <stdio.h> #include <math.h> //函 ...
- [leetcode]Length of Last Word @ Python
原题地址:https://oj.leetcode.com/problems/length-of-last-word/ 题意: Given a string s consists of upper/lo ...
- 引用外部jquery.js
使用 Google 的 CDN <head> <script type="text/javascript" src="http://ajax.googl ...
- 如何三招帮你排查Linux中的硬件问题
下列贴士帮助你更快速更轻松地为Linux中的硬件排查故障.许多不同的因素可能导致Linux硬件出现问题:在你开始尝试诊断之前,了解最常见的问题以及最有可能找到原因的环节是明智之举. Linux服务器在 ...