WebService 服务是 J2EE 架构的服务程序,部署在 Tomcat 7 以上版本,服务器要求采用 Linux 64 为系统,硬件配置 CPU 双核、内存 4G 以上、硬盘 200G 以上。
消费终端前置机为网关提供接入服务。该程序支持 Linux Centos6 64 位或 Windows 64 位。服务器硬件配置要求 单核 CPU、内存 4G 以上、硬盘 200G 以上。
新卡普网关为专用设备,负责将 POS 机的 CAN 协议数据转换成 TCP 协议数据,并发送给消费终端前置机
消费终端前置机程序包括主程序 newcapec-can-<os> 和配置文件 newcapec-can.cfg。Linux 平台程序名 newcapec-can-linux , Windows 平台程序名 newcapec-can-win.exe。
前置程序不需要其它依赖环境既可运行
# log level log_level=info # server config, listen port , default 9876 can_port=9876 tcp_port=9877 rpc_port=12451 # app config appid=100001 appsecret=3072a87ece234b728b519ded8dd152b1 baseurl=https://172.28.200.122:18443/epayapi/services # 验证 ssl 证书合法性, 可选值 true , false ssl_verify=false # upgrade rom rom_name=SWPos.bin
Windows 平台 在 Windows 下直接运行 newcapec-can-win.exe 既可。
Linux 平台
推荐使用 Centos 7 / RedHat 7 版本, 系统要求 64 位。
在 Linux 下运行 ./newcapec-can-linux 启动服务;如果需要在后台运行服务用以下命令:
$ nohup ./newcapec-can-linux &
在系统中建立 ecard 用户,并在创建前置工作目录
$ groupadd -g 10005 ecard $ useradd -u 10005 -g ecard ecard $ mkdir -p /opt/newcapec-pos-svr $ chown -R ecard.ecard /opt/newcapec-pos-svr
将在前置程序上传到 /opt/newcapec-pos-svr 工作目录下,并保证有执行权限。你可以通过手工运行前置程序生成默认的配置文件,配置文件名 newcapec-can.cfg 。
拷贝 newcapecsvr.service 到 /etc/systemd/system/ 目录下, 用 root 用户执行以下配置命令。
$ systemctl daemon-realod $ systemctl enable newcapecsvr $ systemctl start newcapecsvr $ systemctl status newcapecsvr # 检查服务启动情况 ● newcapecsvr.service - Supwisdom Newcapec POS Server Loaded: loaded (/etc/systemd/system/newcapecsvr.service; disabled; vendor preset: disabled) Active: active (running) since 三 2016-08-03 16:43:28 CST; 21h ago Main PID: 195463 (newcapec-can-li) CGroup: /system.slice/newcapecsvr.service └─195463 /opt/newcapec-pos-svr/newcapec-can-linux -config=/opt/newcapec-pos-svr/newcapec-can.cfg 8月 03 16:43:28 yktdev2 systemd[1]: Started Supwisdom Newcapec POS Server. 8月 03 16:43:28 yktdev2 systemd[1]: Starting Supwisdom Newcapec POS Server... 8月 03 16:43:28 yktdev2 newcapec-can-linux[195463]: time="2016-08-03T16:43:28+08:00" level=info msg="服务启动侦听端口,time=2016-08-03 16:43:28.46119326 +0800 CST" 8月 03 16:43:28 yktdev2 newcapec-can-linux[195463]: time="2016-08-03T16:43:28+08:00" level=info msg="newcapecCANPort=9876,newcapecTCPPort=9877,huiduoCANPort=9878" 8月 03 16:43:28 yktdev2 newcapec-can-linux[195463]: time="2016-08-03T16:43:28+08:00" level=info msg="Go version: go1.6.3" 8月 03 16:43:28 yktdev2 newcapec-can-linux[195463]: time="2016-08-03T16:43:28+08:00" level=debug msg="Info TotalAlloc=746280 Bytes, Free=606 Bytes" 8月 03 16:44:28 yktdev2 newcapec-can-linux[195463]: time="2016-08-03T16:44:28+08:00" level=info msg="System GC at 2016-08-03 16:44:28.461495496 +0800 CST" 8月 03 16:44:28 yktdev2 newcapec-can-linux[195463]: time="2016-08-03T16:44:28+08:00" level=debug msg="Info TotalAlloc=755360 Bytes, Free=2086 Bytes"
前置服务可以通过监控命令获取运行状态报告,命令如下。该命令可以在 Window 电脑上运行, 运行的程序是 newcapec-can-win.exe。
$ ./newcapec-can-osx -showinfo -agent 172.28.200.128 服务启动时间: 2015-08-19 10:08:32.481028525 +0800 CST 程序版本: 1.1.0, Build: 2015-08-19.10:06:20 Go Version: go1.5rc1 Goroutines: 26 ==================================================== 连接数: 1, 最高连接数: 1 最大处理POS机数 0 CAN 统计信息 ==================================== 帧统计: 接收 11886 , 发送 0 消息统计: 处理 2379, 丢弃 0 请求统计信息(micro secs) ============================ Cmd Min Max Cnt FCnt Total(ms) Avg(ms) CANMin CANMax 0xA6 63882 63882 1 0 63 63 320 320 0xB0 33959 133170 17 0 1142 67 182 593 0xB2 19770 158987 15 0 699 46 115 290 0xB4 27425 99000 4 0 251 62 92 186 0xB6 28332 77213 9 0 431 47 356 718 0xE0 30456 75669 4 0 169 42 88 155 0xE1 52325 99456 4 0 286 71 227 514 0xE2 956 3002509 2324 7 105096 45 47 851 0xE4 32971 32971 1 0 32 32 93 93 统计生成时间:2015-08-20 13:33:28.08915124 +0800 CST
使用浏览器登录网关管理界面 http://192.168.1.250, 默认用户名密码都是 admin。 登录成功后在菜单中选择“网络参数” => "LAN 配置“,在以下界面中输入新的网络地址。
消费网关通过 SSH 远程登录到控制台进行参数配置和更新应用程序,默认 SSH 用户名和密码是 root 。
网关应用程序包括主程序 can_gateway 和配置文件 can_cfg.ini 两个文件。配置文件如下:
[upserver] upserver_count=2 # server 1 upserver_ip_1=172.28.43.13 upserver_port_1=9876 # server 2 upserver_ip_2=172.28.43.45 upserver_port_2=9876 # server 3 upserver_ip_3= upserver_port_3= # server 4 upserver_ip_4= upserver_port_4= [can] # can configuration # can baud rate , optinal value are 100000 , 250000 can1_baud=100000 can2_baud=100000 can3_baud=100000 can4_baud=100000 [log] # log define # 10 means 10 MBytes log_size=10 [ntp] ntp_server=
upserver 部分参数是消费前置机相关配置, upserver_count 表示前置机数量可选值 1 ~ 4。upserver_ip_<num> 表示前置机 IP 地址, upserver_port_<num> 端口号默认 9876 。
can 部分配置是 CAN 模块的波特率,可选值 100000 kbps 或 250000 kbps, 默认值 100000 kbps,这个值必须和 POS 上配置的通讯参数一致。
ntp 部分配置是网关自动进行 ntp 校时的服务器 IP。如果连接不通只是不能自动校时,不会影响网关正常工作。网关时钟不正确也不会影响 POS 机的时钟,POS 是通过前置机校时的。
程序部署
需要现在一台电脑上 tftp server , 然后将网关程序拷贝到 tftp 下载目录下。然后在网关控制台上执行以下命令下载程序。
$ cd /home/bin $ tftp -g -l can_cfg.ini -r can_cfg.ini <tftp 服务器IP> $ tftp -g -l can_gateway -r can_gateway <tftp 服务器IP>
需要在一台 Linux 电脑上安装配置 nfs 服务,让后将网关程序拷贝到共享的目录下,执行以下命令
$ mount -t nfs -o nolock <Linux 电脑 Ip>:/home/ykt /home/nfs & $ cp /home/nfs/can_gateway /home/bin/ $ cp /home/nfs/can_cfg.ini /home/bin/
配置网关启动任务,当网关重启能自动运行网关应用程序。网关启动配置文件路径 /etc/init.d/rcS,需要将原配置一行注释掉,增加一行配置。配置完成后如下:
#/home/bin/dtg & cd /home/bin && ./can_gateway &