#!/bin/sh #HOME=/ BIN=PLCXPro stoprun() { PID=`ps -ef --cols=200|grep -v stopapp |grep "$1" | awk '{print $2 " " $8}'|sed -e '/grep/d' -e 's/^ *//' -e 's/ .*//'` if [ -n "$PID" ] then echo "$1 id is $PID, kill normal process!" kill -3 $PID else echo "$1 id $PID is down! it's over!" fi } stoprunstart() { PID=`ps -ef --cols=200|grep -v stopapp |grep "$1"|grep start | awk '{print $2 " " $8}'|sed -e '/grep/d' -e 's/^ *//' -e 's/ .*//'` if [ -n "$PID" ] then echo "$1 id is $PID, kill normal process!" kill -9 $PID else echo "$1 id $PID is down! it's over!" fi } runtest() { PID=`ps -ef --cols=200|grep -v stopapp |grep "$1" | awk '{print $2 " " $8}'|sed -e '/grep/d' -e 's/^ *//' -e 's/ .*//'` if [ -n "$PID" ] then ## echo $1 id is $PID, sys normal process! sleep 30 else echo $1 is down! reload the process! date echo nohup $BIN & nohup ./$BIN > /dev/null & fi }怎么开启或者重启这个PLCXPro
时间: 2024-03-05 17:52:53 浏览: 64
可以运行以下命令来重启 PLCXPro 进程:
```
./stopapp.sh PLCXPro
```
该命令会执行 stoprun 函数,查找并终止名为 PLCXPro 的进程。
然后再执行以下命令来启动 PLCXPro 进程:
```
./runapp.sh PLCXPro
```
该命令会执行 runtest 函数,查找名为 PLCXPro 的进程是否已经存在,若不存在则启动 PLCXPro 进程。
相关问题
def medianBlur(image,winSize): # 图像的高、宽 rows,cols = image.shape[:2] # 窗口的高、宽,均为奇数 winH,winW = winSize halfWinH = (winH-1)/2 halfWinW = (winW-2)/2 # 中值滤波后的输出图像 medianBlurImg = np.zeros(image.shape,image.dtype) for r in range(rows): for c in range(cols): # 判断边界 rTop = 0 if r-halfWinH<0 else r-halfWinH rBottom = rows-1 if r+halfWinH > rows-1 else r+halfWinH cLeft = 0 if c-halfWinW < 0 else c-halfWinW cRight = cols-1 if c+halfWinW > cols-1 else c+halfWinW print(rTop,rBottom,cLeft,cRight) # 取邻域 region = image[rTop:rBottom,cLeft:int(cRight)] # 求中值 medianBlurImg[r][c] = np.median(region) return medianBlurImg。出现错误:TypeError: slice indices must be integers or None or have an index method
看起来是在取邻域时出现了问题。错误提示中说“slice indices must be integers or None or have an index method”,也就是说切片的索引必须是整数或者是 `None`,或者是具有 `__index__` 方法的对象。
在你的代码中,`cLeft` 和 `cRight` 的计算中出现了一个小错误。应该改为:
```python
cLeft = 0 if c-halfWinW < 0 else c-halfWinW
cRight = cols-1 if c+halfWinW > cols-1 else c+halfWinW+1 # 注意这里加 1
```
原因是切片操作是左闭右开区间,所以右边界要加 1。
另外,`halfWinH` 和 `halfWinW` 的计算也应该改为:
```python
halfWinH = (winH-1) // 2
halfWinW = (winW-1) // 2
```
这样可以保证窗口的大小为奇数。
修改后的代码如下:
```python
def medianBlur(image, winSize):
# 图像的高、宽
rows, cols = image.shape[:2]
# 窗口的高、宽,均为奇数
winH, winW = winSize
halfWinH = (winH-1) // 2
halfWinW = (winW-1) // 2
# 中值滤波后的输出图像
medianBlurImg = np.zeros(image.shape, image.dtype)
for r in range(rows):
for c in range(cols):
# 判断边界
rTop = 0 if r-halfWinH < 0 else r-halfWinH
rBottom = rows-1 if r+halfWinH > rows-1 else r+halfWinH
cLeft = 0 if c-halfWinW < 0 else c-halfWinW
cRight = cols-1 if c+halfWinW > cols-1 else c+halfWinW+1
# 取邻域
region = image[rTop:rBottom, cLeft:cRight]
# 求中值
medianBlurImg[r][c] = np.median(region)
return medianBlurImg
```
希望这个答案能够帮到你!
create_walls(){ const g = []; for(let r = 0; r < this.rows; r ++ ){ g[r] = []; for(let c = 0; c < this.cows; c ++ ){ g[r][c] = false; } } //四周加墙 for(let r = 0; r < this.rows; r ++ ){ g[r][0] = g[r][this.cols - 1] = true; } for(let c = 0; c < this.cols; c ++ ){ g[0][c] = g[this.rows - 1][c] = true; } //随机化 for(let i = 0; i < this.inner_walls_count; i ++){ for (let j = 0; j < 1000; j ++){ let r = parseInt(Math.random() * this.rows); let c = parseInt(Math.random() * this.cols); if(g[r][c] || r == this.rows - 2 && c == 1 || c == this.cols - 2 && r == 1){ continue; } g[r][c] = g[this.rows - 1 - r][this.cols - 1 -c] = true; break; } } const copy_g = JSON.parse(JSON.stringify(g));//深拷贝 if(!this.check_connectivity(copy_g, this.rows - 2, 1, 1, this.cols - 2)){ return false; } for(let r = 0; r < this.rows; r ++ ){ for(let c = 0; c < this.cols; c ++ ){ if(g[r][c]){ this.walls.push(new Wall(r, c, this)); } } } return true; }翻译成Java
以下是将 JavaScript 代码转换为 Java 代码后的结果:
public boolean createWalls() {
boolean[][] g = new boolean[this.rows][this.cols];
for (int r = 0; r < this.rows; r++) {
for (int c = 0; c < this.cols; c++) {
g[r][c] = false;
}
}
// 四周加墙
for (int r = 0; r < this.rows; r++) {
g[r][0] = g[r][this.cols - 1] = true;
}
for (int c = 0; c < this.cols; c++) {
g[0][c] = g[this.rows - 1][c] = true;
}
// 随机化
for (int i = 0; i < this.inner_walls_count; i++) {
for (int j = 0; j < 1000; j++) {
int r = (int) (Math.random() * this.rows);
int c = (int) (Math.random() * this.cols);
if (g[r][c] || (r == this.rows - 2 && c == 1) || (c == this.cols - 2 && r == 1)) {
continue;
}
g[r][c] = g[this.rows - 1 - r][this.cols - 1 - c] = true;
break;
}
}
boolean[][] copy_g = new boolean[this.rows][this.cols];
for (int r = 0; r < this.rows; r++) {
for (int c = 0; c < this.cols; c++) {
copy_g[r][c] = g[r][c];
}
}
if (!this.checkConnectivity(copy_g, this.rows - 2, 1, 1, this.cols - 2)) {
return false;
}
for (int r = 0; r < this.rows; r++) {
for (int c = 0; c < this.cols; c++) {
if (g[r][c]) {
this.walls.add(new Wall(r, c, this));
}
}
}
return true;
}
阅读全文