【Rhapsody学习笔记(二)】Linux环境下的Rhapsody集成引擎安装部署

        Rhapsody的安装部署包括Rhapsody引擎的部署(服务端),以及Rhapsody IDE(客户端)的安装部署,其中,IDE可以安装在多台不同的windows客户机上,本文仅介绍CentOS7环境下的rhapsody集成引擎部署,IDE根据安装程序提示进行安装即可。

CentOS 7 环境下的Rhapsody集成引擎安装部署


1、使用root用户登录服务器,可以使用 MobaXterm、Xshell等ssh工具连接,并进行服务器配置优化,包括limit配置、防火墙设置、时区设置或更改、ssh配置优化等,具体服务器配置优化方法此处不展开说明。

2、添加rhapsody用户并设置密码;

useradd rhapsody
passwd rhapsody

操作结果如下:

 3、在指定目录下新建rhapsody文件夹,例如/home/rhapsody

mkdir /home/rhapsody

 创建结果如下:

4、通过ssh工具,将rhapsody集成引擎安装包上传到该文件夹下

(以 rhapsody-6_5_0-linux-x64 版本为例)

上传结果如下:

5、授予执行权限

chmod a+x /home/rhapsody/rhapsody-6_5_0-linux-x64.sh

 执行结果如下:

6、切换到rhapsody用户,执行安装命令

[root@localhost rhapsody]# su rhapsody
[rhapsody@localhost ~]$ cd /home/rhapsody/
[rhapsody@localhost ~]$ ./rhapsody-6_5_0-linux-x64.sh -c

执行结果如下:

7、按照提示,进行引擎配置预设

        如下所示,每一行中的 # 符号处为安装过程中需要输入的位置,若需要更改某一配置项,输入后按下回车即跳转到下一项配置。若要以默认值(即上一行 [ ] 内所显示的值)进行设置,则直接按下回车即可。

OK [o, Enter], Cancel [c]
o #输入o 并按下回车开始安装

Where should Rhapsody be installed?
[/home/rhapsody/rhapsody/rhapsody-engine-6]
#此处可输入rhapsody引擎的安装路径

Where should the data directory be located?
[/home/rhapsody/rhapsody/rhapsody-engine-6/rhapsody/data]
#此处可以输入rhapsody引擎数据文件存放路径

What memory settings should be used?
Specify the initial memory and the maximum memory to allocate to the Rhapsody Engine.
The recommended JVM memory allocation for a production environment can be
found in the "Rhapsody Hardware Recommendation Guide" document located
within the Documents folder.
JVM Initial Memory (MB)
[512]
#此处输入引擎JVM可占内存最小值,根据实际需要设置

JVM Max Memory (MB)
[1024]
#此处输入引擎JVM可占内存的最大值,根据实际需要设置

What port settings should be used?
Specify the ports that Rhapsody should use. These must be changed if they
are not available.
IDE Port
[3041]
#IDE连接端口,无特殊需要则保持默认

IDE Broadcast Port
[4031]
#IDE广播端口,无特殊需要则保持默认

Secure Management Console Port
[8444]
#Management Console(rhapsody集成引擎后台)应用端口,无特殊需要保持默认

Secure Web Services Port
[8449]
#web服务端口,无特殊需要则保持默认

 8、安装完成后,进入rhapsody安装路径下的bin目录,执行以下命令,启动rhapsody引擎

[rhapsody@localhost bin]$ cd /home/rhapsody/rhapsody/rhapsody-engine-6/bin/
[rhapsody@localhost bin]$ ./rhapsody.sh start

 启动成功后如下所示:

以此类推,关闭或重启引擎命令如下:

关闭rhapsody引擎

[rhapsody@localhost bin]$ cd /home/rhapsody/rhapsody/rhapsody-engine-6/bin/
[rhapsody@localhost bin]$ ./rhapsody stop

重启rhapsody引擎: 

[rhapsody@localhost bin]$ cd /home/rhapsody/rhapsody/rhapsody-engine-6/bin/
[rhapsody@localhost bin]$ ./rhapsody restart

 

### ESP32 控制步进电机的上位机软件实现 #### 使用串口通信控制步进电机 为了实现在PC端通过上位机软件发送命令给ESP32从而控制步进电机,可以采用简单的串口通信协议。该方案允许用户在计算机界面上输入想要执行的动作(如转动的角度或步数),并通过USB线缆传输至ESP32设备。 对于这种应用场景,在ESP32一侧编写接收来自COM端口数据并解析成具体动作指令的固件是非常重要的[^3]。下面是一个简化版的MicroPython脚本例子: ```python import machine from time import sleep_ms, sleep_us step_pin = machine.Pin(5, machine.Pin.OUT) dir_pin = machine.Pin(4, machine.Pin.OUT) def move(steps): direction = steps >= 0 dir_pin.value(direction) for _ in range(abs(steps)): step_pin.on() if direction: sleep_us(600) # Adjust according to your motor's requirement else: sleep_us(600) step_pin.off() sleep_us(600) while True: try: command = input().strip() # Read from serial port angle_or_steps = int(command) if abs(angle_or_steps) <= 360: # Assuming degree input steps = round((angle_or_steps / 360) * 4096) else: steps = angle_or_steps move(steps) except ValueError as e: print("Invalid Input:", str(e)) ``` 这段代码展示了如何读取从串行接口传来的字符串形式的数据,并将其转换为整数值以决定要移动多少步以及方向。这里假设每圈对应于4096个脉冲信号,这可能需要依据实际使用的步进马达规格做适当修改。 #### 开发上位机界面 针对上述硬件配置,可以在Windows/Linux/MacOS平台上利用多种图形化工具创建友好的用户交互界面(UI),比如PyQt、Tkinter或者其他GUI库。这些框架能够帮助快速搭建一个具有按钮点击事件响应功能的应用程序,用于向连接着ESP32板子的虚拟串行端口发送预定义的消息包。 作为实例的一部分,考虑使用Python中的`pyserial`库来处理与ESP32之间的低层通讯细节。以下是一段简化的Python客户端代码片段,它负责构建UI并与远程MCU交换信息: ```python import sys import tkinter as tk import serial import threading class StepperControlApp(tk.Tk): def __init__(self, com_port='COM3', baud_rate=115200): super().__init__() self.title('Stepper Motor Control') self.geometry('300x200') frame = tk.Frame(self) frame.pack(pady=20) label = tk.Label(frame, text="Enter Steps or Angle:") entry = tk.Entry(frame, width=20) send_btn = tk.Button( frame, text="Send", command=lambda: self.send_command(entry.get()) ) widgets = (label, entry, send_btn) for widget in widgets: widget.pack(side=tk.LEFT, padx=(5)) self.ser = serial.Serial(com_port, baud_rate, timeout=1) thread = threading.Thread(target=self.listen_to_esp32) thread.daemon = True thread.start() def listen_to_esp32(self): while True: response = self.ser.readline().decode().strip() if response != '': print(f"Received message: {response}") def send_command(self, cmd_str): try: value = float(cmd_str.strip()) formatted_cmd = f"{value}\n" self.ser.write(formatted_cmd.encode()) except Exception as ex: print(ex) if __name__ == '__main__': app = StepperControlApp(*sys.argv[1:]) app.mainloop() ``` 此应用程序提供了一个文本框供用户键入目标位置(既可以是以度表示也可以是具体的步数),还有一个“发送”按钮用来触发消息传递过程。当按下这个按键时,会将用户的输入转化为适合ESP32解释的形式并通过选定的串行端口发出。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值