Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
VerticalStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit e178b7d4
由
LN
编写于
2020-06-17 17:10:55 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改垂直货柜配置
1 个父辈
4be59287
隐藏空白字符变更
内嵌
并排
正在显示
34 个修改的文件
包含
1283 行增加
和
3766 行删除
doc/SO479垂直循环货柜IO配置.xlsx
source/DeviceLibrary/DeviceLibrary.csproj
source/DeviceLibrary/StoreConfig/StoreConfig.csv
source/DeviceLibrary/acVerticalStore/AxisBean.cs
source/DeviceLibrary/acVerticalStore/DoorBean.cs
source/DeviceLibrary/acVerticalStore/StoreManager.cs
source/DeviceLibrary/acVerticalStore/VerticalStoreBean.cs
source/DeviceLibrary/acVerticalStore/VerticalStoreBean_InOut.cs
source/DeviceLibrary/device/IO/AIManager.cs
source/DeviceLibrary/device/IO/AIOBOX/AIOAIManager.cs
source/DeviceLibrary/device/IO/KangNaiDe/AITcpClient.cs
source/DeviceLibrary/device/IO/KangNaiDe/KNDAIManager.cs
source/DeviceLibrary/device/IO/KangNaiDe/KNDManager.cs
source/DeviceLibrary/device/IO/KangNaiDe/MasterTcpClient.cs
source/DeviceLibrary/device/led/BaseLedManager.cs
source/DeviceLibrary/store/InOutParam.cs
source/DeviceLibrary/store/KTK_DeviceBase.cs
source/DeviceLibrary/store/KTK_Store.cs
source/DeviceLibrary/store/StoreMoveP.cs
source/DeviceLibrary/store/StoreStep.cs
source/DeviceLibrary/store/model/StoreMoveInfo.cs
source/LoadCVSLibrary/position/VerticalPosition.cs
source/LoadCVSLibrary/storeConfig/CSVConfigReader.cs
source/LoadCVSLibrary/storeConfig/ConfigItemBase.cs
source/LoadCVSLibrary/storeConfig/config/IO_Type.cs
source/LoadCVSLibrary/storeConfig/config/StoreType.cs
source/LoadCVSLibrary/storeConfig/config/VerticalStoreConfig.cs
source/VerticalStoreClinet/App.config
source/VerticalStoreClinet/FrmIOStatus.Designer.cs
source/VerticalStoreClinet/FrmIOStatus.cs
source/VerticalStoreClinet/FrmStoreBox.Designer.cs
source/VerticalStoreClinet/FrmStoreBox.cs
source/VerticalStoreClinet/useControl/AxisMoveControl.cs
source/VerticalStoreClinet/记录.txt
doc/SO479垂直循环货柜IO配置.xlsx
查看文件 @
e178b7d
此文件类型无法预览
source/DeviceLibrary/DeviceLibrary.csproj
查看文件 @
e178b7d
...
...
@@ -65,21 +65,20 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="acVerticalStore\AxisBean.cs" />
<Compile Include="acVerticalStore\DoorBean.cs" />
<Compile Include="acVerticalStore\VerticalStoreBean.cs" />
<Compile Include="acVerticalStore\VerticalStoreBean_InOut.cs" />
<Compile Include="acVerticalStore\StoreManager.cs" />
<Compile Include="device\halcon\CodeManager.cs" />
<Compile Include="device\IO\AIOBOX\AIOBOXManager.cs" />
<Compile Include="device\IO\IOManager.cs" />
<Compile Include="device\led\BaseLedManager.cs" />
<Compile Include="device\led\LEDColorArtNet.cs" />
<Compile Include="store\StoreMoveP.cs" />
<Compile Include="store\StoreAlarm.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="store\model\AxisAlarmInfo.cs" />
<Compile Include="store\KTK_DeviceBase.cs" />
<Compile Include="store\InOutParam.cs">
<SubType>Code</SubType>
</Compile>
...
...
source/DeviceLibrary/StoreConfig/StoreConfig.csv
查看文件 @
e178b7d
...
...
@@ -3,12 +3,13 @@
AXIS,(轴一)料斗旋转轴,Middle_Axis,1,COM1,,,,250,80,80,80,60,50,10,1000,0,0
PRO,IO模块对应的DI数量,IO_DILength,192.168.200.21#16,,,,,,,,,,,,,,
PRO,模块对应的DO数量,IO_DOLength,192.168.200.21#16,,,,,,,,,,,,,,
PRO,Led控制器IP,LED_IP,192.168.200.192,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,
DI,急停,SuddenStop_BTN,0,192.168.200.21,急停,X01,X01,,,,,,,,,,
DI,复位,Reset_BTN,1,192.168.200.21,复位,X02,X02,,,,,,,,,,
DI,安全光栅,SafetyLightCurtains,2,192.168.200.21,安全光栅,X03,X03,,,,,,,,,,
DI,升降门上升
端,Door_Up,3,192.168.200.21,升降门上升
端,X04,X04,,,,,,,,,,
DI,升降门下降
端,Door_Down,4,192.168.200.21,升降门下降
端,X05,X05,,,,,,,,,,
DI,升降门上升
/打开端,Door_Up,3,192.168.200.21,升降门上升/打开
端,X04,X04,,,,,,,,,,
DI,升降门下降
/关闭端,Door_Down,4,192.168.200.21,升降门下降/关闭
端,X05,X05,,,,,,,,,,
,链轮计数信号,,5,192.168.200.21,链轮计数信号,X06,X06,,,,,,,,,,
,,,6,192.168.200.21,,X07,X07,,,,,,,,,,
,,,7,192.168.200.21,,X08,X08,,,,,,,,,,
...
...
@@ -27,9 +28,9 @@ DO,待机指示灯,RunSign_HddLed,2,192.168.200.21,待机指示灯,Y03,Y03,,,,,,,,,,
DO,报警蜂鸣器,Alarm_Buzzer,3,192.168.200.21,报警蜂鸣器,Y04,Y04,,,,,,,,,,
DO,设备运转ON,Run_Signal,4,192.168.200.21,设备运转ON,Y05,Y05,,,,,,,,,,
DO,料斗伺服刹车ON,Axis_Brake,5,192.168.200.21,料斗伺服刹车ON,Y06,Y06,,,,,,,,,,
DO,升降门刹车ON,
Camera_Led
,6,192.168.200.21,升降门刹车ON,Y07,Y07,,,,,,,,,,
DO,升降门
电机上升,Door_Up,7,192.168.200.21,升降门电机上升
,Y08,Y08,,,,,,,,,,
DO,升降门
电机下降,Door_Down,8,192.168.200.21,升降门电机下降
,Y09,Y09,,,,,,,,,,
DO,升降门刹车ON,
Door_Break
,6,192.168.200.21,升降门刹车ON,Y07,Y07,,,,,,,,,,
DO,升降门
上升/打开端,Door_Up,7,192.168.200.21,升降门上升/打开端
,Y08,Y08,,,,,,,,,,
DO,升降门
下降/关闭端,Door_Down,8,192.168.200.21,升降门下降/关闭端
,Y09,Y09,,,,,,,,,,
DO,设备照明ON,Device_Led,9,192.168.200.21,设备照明ON,Y10,Y10,,,,,,,,,,
,,,10,192.168.200.21,,Y11,Y11,,,,,,,,,,
,,,11,192.168.200.21,,Y12,Y12,,,,,,,,,,
...
...
@@ -49,4 +50,3 @@ PRO,旋转轴(轴1)P2速度,MiddleAxis_P2_Speed,120,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,
PRO,设备是否处于调试状态(1=调试,0=正常),IsInDebug,0,,,,,,,,,,,,,,
PRO,IO信号超时时间(毫秒),IOSingle_TimerOut,10000,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,
\ No newline at end of file
source/DeviceLibrary/acVerticalStore/AxisBean.cs
0 → 100644
查看文件 @
e178b7d
using
DeviceLib
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
OnlineStore.DeviceLibrary
{
public
class
AxisBean
{
public
ConfigMoveAxis
Config
=
null
;
public
static
int
TimeoutInterval
=
500
;
/// <summary>
/// 正常工作过程中判断位置是否到达时使用
/// </summary>
public
int
LastPosition
=
0
;
public
string
AxisName
;
public
AxisBean
(
ConfigMoveAxis
axisConfig
,
string
deviceName
)
{
this
.
Config
=
axisConfig
;
AxisName
=
deviceName
+
" "
+
Config
.
Explain
+
"["
+
Config
.
DeviceName
+
"-"
+
Config
.
GetAxisValue
()
+
"]"
;
}
private
bool
IsIntSlvBlock
=
false
;
public
bool
Open
(
bool
isCheck
,
out
string
Msg
)
{
IOManager
.
IOMove
(
Config
.
Axis_Run_DO
,
IO_VALUE
.
HIGH
);
Msg
=
""
;
string
portName
=
Config
.
DeviceName
;
int
slvAddr
=
Config
.
GetAxisValue
();
//打开 轴
int
bro
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
ACBaudRate
);
ACServerManager
.
OpenPort
(
Config
.
DeviceName
,
bro
);
Thread
.
Sleep
(
50
);
//初始化
if
(!
IsIntSlvBlock
)
{
ACServerManager
.
InitSlvAddr
(
portName
,
slvAddr
,
Config
.
TargetSpeed
,
Config
.
AddSpeed
,
Config
.
DelSpeed
);
Thread
.
Sleep
(
100
);
}
ACServerManager
.
AlarmClear
(
portName
,
slvAddr
);
Thread
.
Sleep
(
50
);
ACServerManager
.
ServoOn
(
portName
,
slvAddr
);
Thread
.
Sleep
(
1000
);
//打开所有轴
if
(
isCheck
)
{
if
(!
OpenAxis
(
out
Msg
))
{
return
false
;
}
}
IOManager
.
IOMove
(
Config
.
Axis_Brake_DO
,
IO_VALUE
.
HIGH
);
IsIntSlvBlock
=
true
;
return
true
;
}
/// <summary>
/// 打开所有轴
/// </summary>
/// <returns></returns>
private
bool
OpenAxis
(
out
string
msg
)
{
msg
=
""
;
//判断轴是否正常
string
portName
=
Config
.
DeviceName
;
int
slvAddr
=
Config
.
GetAxisValue
();
if
(
ACServerManager
.
ServerOnStatus
(
portName
,
slvAddr
))
{
LogUtil
.
info
(
AxisName
+
"成功打开"
);
}
else
{
//清理报警,再重新打开一次
LogUtil
.
info
(
AxisName
+
"第一次打开失败,先清理一下报警,再重新打开一次"
);
ACServerManager
.
AlarmClear
(
portName
,
slvAddr
);
System
.
Threading
.
Thread
.
Sleep
(
1200
);
ACServerManager
.
ServoOn
(
portName
,
slvAddr
);
System
.
Threading
.
Thread
.
Sleep
(
100
);
if
(
ACServerManager
.
ServerOnStatus
(
portName
,
slvAddr
))
{
LogUtil
.
info
(
AxisName
+
"清理报警后重新打卡轴成功:"
+
Config
.
Explain
);
}
else
{
ACServerManager
.
ServoOff
(
portName
,
slvAddr
);
msg
=
"打开轴"
+
Config
.
Explain
+
"失败 "
;
LogUtil
.
info
(
AxisName
+
msg
);
return
false
;
}
}
return
true
;
}
public
void
ServoOff
()
{
LogUtil
.
info
(
"ServoOff【"
+
AxisName
+
"】"
);
IOManager
.
IOMove
(
Config
.
Axis_Brake_DO
,
IO_VALUE
.
LOW
);
ACServerManager
.
ServoOff
(
Config
.
DeviceName
,
Config
.
GetAxisValue
());
IOManager
.
IOMove
(
Config
.
Axis_Run_DO
,
IO_VALUE
.
LOW
);
}
public
void
HomeMove
(
StoreMoveInfo
MoveInfo
)
{
Config
.
TargetPosition
=
0
;
LogUtil
.
info
(
AxisName
+
"speed["
+
Config
.
TargetSpeed
+
"]开始原点返回"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitAxis
(
Config
,
true
));
ACServerManager
.
HomeMove
(
Config
.
DeviceName
,
(
short
)
Config
.
GetAxisValue
(),
Config
.
HomeHighSpeed
);
}
public
void
AbsMove
(
StoreMoveInfo
MoveInfo
,
int
targetPosition
,
int
targetSpeed
)
{
if
(
MoveInfo
==
null
)
{
AbsMove
(
targetPosition
,
targetSpeed
);
}
else
{
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitAxis
(
Config
,
targetPosition
,
targetSpeed
));
Config
.
TargetPosition
=
targetPosition
;
ACServerManager
.
AbsMove
(
Config
.
DeviceName
,
Config
.
GetAxisValue
(),
targetPosition
,
targetSpeed
);
}
}
public
static
bool
ACAxisMoveIsEnd
(
StoreMoveInfo
MoveInfo
,
ConfigMoveAxis
axis
,
int
targetPosition
,
int
targetSpeed
,
out
string
msg
)
{
msg
=
""
;
string
deviceName
=
axis
.
DeviceName
;
short
axisNo
=
axis
.
GetAxisValue
();
bool
isOk
=
ACServerManager
.
GetBusyStatus
(
deviceName
,
axisNo
).
Equals
(
0
);
int
outCount
=
ACServerManager
.
GetActualtPosition
(
deviceName
,
axisNo
);
int
errorCount
=
Math
.
Abs
(
outCount
-
targetPosition
);
if
(
isOk
)
{
if
(
errorCount
<=
axis
.
CanErrorCountMax
)
{
return
true
;
}
//判断是否需要重新运动
if
(
MoveInfo
.
CanWhileCount
>
0
)
{
LogUtil
.
error
(
MoveInfo
.
Name
+
axis
.
DisplayStr
+
"目标位置["
+
targetPosition
+
"]当前位置["
+
outCount
+
"],误差过大,重新开始运动,剩余["
+
MoveInfo
.
CanWhileCount
+
"]次"
);
ACServerManager
.
SuddenStop
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
ACServerManager
.
AbsMove
(
axis
.
DeviceName
,
axis
.
GetAxisValue
(),
targetPosition
,
targetSpeed
);
MoveInfo
.
CanWhileCount
--;
}
else
{
msg
=
" "
+
MoveInfo
.
MoveStep
+
MoveInfo
.
Name
+
axis
.
DisplayStr
+
",目标位置["
+
targetPosition
+
"]当前位置["
+
outCount
+
"],误差过大,需要报警"
;
LogUtil
.
error
(
msg
,
600
);
}
}
return
false
;
}
public
static
bool
HomeMoveIsEnd
(
StoreMoveInfo
MoveInfo
,
ConfigMoveAxis
axis
,
out
string
msg
)
{
msg
=
""
;
if
(
ACServerManager
.
IsHomeMoveEnd
(
axis
.
DeviceName
,
axis
.
GetAxisValue
()))
{
//原点完成并且位置=0
int
outCount
=
ACServerManager
.
GetActualtPosition
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
int
errorCount
=
Math
.
Abs
(
outCount
);
if
(
errorCount
<=
axis
.
CanErrorCountMax
)
{
return
true
;
}
//判断是否需要重新运动
if
(
MoveInfo
.
CanWhileCount
>
0
)
{
LogUtil
.
error
(
MoveInfo
.
Name
+
axis
.
DisplayStr
+
"收到原点完成信号,当前位置["
+
outCount
+
"],重新回原点,剩余["
+
MoveInfo
.
CanWhileCount
+
"]次"
);
//LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager
.
HomeMove
(
axis
.
DeviceName
,
axis
.
GetAxisValue
(),
axis
.
HomeHighSpeed
,
true
);
MoveInfo
.
CanWhileCount
--;
}
else
{
msg
=
MoveInfo
.
Name
+
" "
+
MoveInfo
.
MoveType
+
axis
.
DisplayStr
+
",收到原点完成信号,当前位置["
+
outCount
+
"],误差过大,需要报警"
;
LogUtil
.
error
(
msg
);
}
}
return
false
;
}
public
int
GetAclPosition
()
{
int
p
=
ACServerManager
.
GetActualtPosition
(
Config
.
DeviceName
,
Config
.
GetAxisValue
());
return
p
;
}
public
bool
IsInPosition
(
int
targetP
)
{
int
currp
=
GetAclPosition
();
int
chaz
=
targetP
-
currp
;
if
(
Math
.
Abs
(
chaz
)
<
Config
.
CanErrorCountMax
)
{
return
true
;
}
return
false
;
}
/// <summary>
/// 绝对运动至点,不等待结果
/// </summary>
private
void
AbsMove
(
int
targetPos
,
double
targetSpeed
)
{
if
(
targetPos
.
Equals
(-
1
))
{
return
;
}
LastPosition
=
-
1
;
if
(
targetSpeed
>
Config
.
TargetSpeed
||
targetSpeed
<=
0
)
{
targetSpeed
=
Config
.
TargetSpeed
;
}
//小于1,表示是目标速度的百分比
else
if
(
targetSpeed
<=
1
)
{
targetSpeed
=
Config
.
TargetSpeed
*
targetSpeed
;
}
ACServerManager
.
AbsMove
(
Config
.
DeviceName
,
Config
.
GetAxisValue
(),
targetPos
,
(
int
)
targetSpeed
);
}
public
void
SuddenStop
()
{
ACServerManager
.
SuddenStop
(
Config
.
DeviceName
,
Config
.
GetAxisValue
());
}
}
}
source/DeviceLibrary/acVerticalStore/DoorBean.cs
0 → 100644
查看文件 @
e178b7d
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
OnlineStore.DeviceLibrary
{
public
class
DoorBean
{
public
static
bool
IsRun
=
false
;
private
static
string
LastMoveDO
=
""
;
private
static
string
LastCheckDI
=
""
;
internal
static
DateTime
LastEndTime
=
DateTime
.
Now
;
public
static
void
Stop
()
{
if
(
IsRun
)
{
IsRun
=
false
;
}
}
private
static
bool
Start
(
string
moveDO
,
string
checkDI
,
int
timeOutMS
=
30000
)
{
if
(
IsRun
)
{
LogUtil
.
error
(
"启动["
+
moveDO
+
"] ["
+
checkDI
+
"] 失败"
);
return
false
;
}
IsRun
=
true
;
Task
.
Factory
.
StartNew
(
delegate
{
WriteAndWait
(
moveDO
,
checkDI
,
timeOutMS
);
});
return
true
;
}
private
static
string
WriteAndWait
(
string
moveDO
,
string
checkDI
,
int
timeOutMS
=
30000
)
{
LastMoveDO
=
moveDO
;
LastCheckDI
=
checkDI
;
LogUtil
.
debug
(
"写入信号:"
+
moveDO
+
",等待信号:"
+
checkDI
+
""
);
if
(
moveDO
.
Equals
(
IO_Type
.
Door_Up
))
{
IOManager
.
IOMove
(
IO_Type
.
Door_Down
,
IO_VALUE
.
LOW
);
}
else
{
IOManager
.
IOMove
(
IO_Type
.
Door_Up
,
IO_VALUE
.
LOW
);
}
IOManager
.
IOMove
(
moveDO
,
IO_VALUE
.
HIGH
);
Thread
.
Sleep
(
50
);
IsRun
=
true
;
DateTime
startTime
=
DateTime
.
Now
;
string
result
=
""
;
bool
isStop
=
false
;
while
(
true
)
{
Thread
.
Sleep
(
50
);
TimeSpan
span
=
DateTime
.
Now
-
startTime
;
if
(!
IsRun
)
{
isStop
=
true
;
result
=
"手动停止"
;
}
else
if
(
span
.
TotalMilliseconds
>
timeOutMS
)
{
isStop
=
true
;
result
=
"转动超时"
;
}
//判断Buzy及位置是否结束
else
if
(
IOManager
.
IOValue
(
checkDI
).
Equals
(
IO_VALUE
.
HIGH
))
{
isStop
=
true
;
}
if
(
isStop
)
{
if
(
result
.
Equals
(
""
))
{
LogUtil
.
info
(
"停止运动:"
+
result
+
" ["
+
moveDO
+
"] ["
+
checkDI
+
"] "
);
}
else
{
LogUtil
.
info
(
"["
+
moveDO
+
"] ["
+
checkDI
+
"] 停止运动:"
+
result
+
" "
+
moveDO
);
}
LastEndTime
=
DateTime
.
Now
;
IOManager
.
IOMove
(
moveDO
,
IO_VALUE
.
LOW
);
IsRun
=
false
;
return
result
;
}
}
}
private
static
bool
UseDoor
=
true
;
public
static
bool
StartOpen
(
StoreMoveInfo
moveInfo
)
{
if
(!
UseDoor
)
{
return
false
;
}
//如果门已打开直接返回
if
(
IOManager
.
IOValue
(
IO_Type
.
Door_Down
).
Equals
(
IO_VALUE
.
HIGH
)
&&
IOManager
.
IOValue
(
IO_Type
.
Door_Up
).
Equals
(
IO_VALUE
.
LOW
))
{
return
true
;
}
if
(
moveInfo
!=
null
)
{
moveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IO_Type
.
Door_Down
,
IO_VALUE
.
HIGH
));
moveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IO_Type
.
Door_Up
,
IO_VALUE
.
LOW
));
}
return
Start
(
IO_Type
.
Door_Down
,
IO_Type
.
Door_Down
);
}
public
static
bool
StartClose
(
StoreMoveInfo
moveInfo
)
{
if
(!
UseDoor
)
{
return
false
;
}
//如果门已关闭直接返回
if
(
IOManager
.
IOValue
(
IO_Type
.
Door_Up
).
Equals
(
IO_VALUE
.
HIGH
)
&&
IOManager
.
IOValue
(
IO_Type
.
Door_Down
).
Equals
(
IO_VALUE
.
LOW
))
{
return
true
;
}
if
(
moveInfo
!=
null
)
{
moveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IO_Type
.
Door_Up
,
IO_VALUE
.
HIGH
));
moveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IO_Type
.
Door_Down
,
IO_VALUE
.
LOW
));
}
return
Start
(
IO_Type
.
Door_Up
,
IO_Type
.
Door_Up
);
}
}
}
source/DeviceLibrary/acVerticalStore/StoreManager.cs
查看文件 @
e178b7d
...
...
@@ -59,14 +59,14 @@ namespace OnlineStore.DeviceLibrary
isInit
=
true
;
string
storeType
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_Type
);
LogUtil
.
info
(
"
配置的料仓 类型="
+
storeType
+
",开始加载料仓
配置"
);
if
(
storeType
==
StoreType
.
RC_AC_SA_
TIN
)
LogUtil
.
info
(
"
类型="
+
storeType
+
",开始加载
配置"
);
if
(
storeType
==
StoreType
.
RC_AC_SA_
Vertical
)
{
string
appPath
=
Application
.
StartupPath
;
string
CID
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_CID
);
string
linefilePath
=
appPath
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_ConfigPath
);
StoreConfig
storeConfig
=
CSVConfigReader
.
LoadConfig
(
1
,
CID
,
StoreType
.
RC_AC_SA_
TIN
,
linefilePath
);
StoreConfig
storeConfig
=
CSVConfigReader
.
LoadConfig
(
1
,
CID
,
StoreType
.
RC_AC_SA_
Vertical
,
linefilePath
);
string
positionConfigFile
=
appPath
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_Position_Config
);
if
(
File
.
Exists
(
positionConfigFile
))
...
...
@@ -77,7 +77,7 @@ namespace OnlineStore.DeviceLibrary
Config
=
(
VerticalStoreConfig
)
storeConfig
;
Store
=
new
VerticalStoreBean
(
Config
);
Store
.
CID
=
CID
;
LogUtil
.
info
(
"加载
料仓
完成!"
);
LogUtil
.
info
(
"加载
配置
完成!"
);
return
Store
;
}
}
...
...
source/DeviceLibrary/acVerticalStore/VerticalStoreBean.cs
查看文件 @
e178b7d
...
...
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
namespace
OnlineStore.DeviceLibrary
{
public
partial
class
VerticalStoreBean
:
KTK_Stor
e
public
partial
class
VerticalStoreBean
:
DeviceBas
e
{
private
static
bool
IsIntSlvBlock
=
false
;
public
string
CID
=
""
;
...
...
@@ -21,7 +21,7 @@ namespace OnlineStore.DeviceLibrary
public
bool
UseBuzzer
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
UseBuzzer
).
Equals
(
1
);
private
System
.
Timers
.
Timer
serverConnectTimer
=
new
System
.
Timers
.
Timer
();
private
System
.
Timers
.
Timer
IoCheckTimer
=
new
System
.
Timers
.
Timer
();
public
AxisBean
MiddleAxis
=
null
;
public
VerticalStoreBean
(
VerticalStoreConfig
config
)
{
...
...
@@ -41,12 +41,11 @@ namespace OnlineStore.DeviceLibrary
{
IsDebug
=
true
;
}
Name
=
(
"
锡膏料仓
"
+
config
.
Id
+
" "
).
ToUpper
();
Name
=
(
"
垂直货柜
"
+
config
.
Id
+
" "
).
ToUpper
();
this
.
StoreID
=
config
.
Id
;
this
.
Config
=
config
;
moveAxisList
=
new
List
<
ConfigMoveAxis
>();
MoveAxisConfig
();
List
<
VerticalPosition
>
positionList
=
CSVPositionReader
<
VerticalPosition
>.
getPositionList
();
PositionNumList
=
new
List
<
string
>();
...
...
@@ -62,13 +61,13 @@ namespace OnlineStore.DeviceLibrary
}
}
//初始化摄像机配置
CodeManager
.
LoadConfig
();
//初始化摄像机配置
IOManager
.
Init
();
IOManager
.
instance
.
ConnectionIOList
(
Config
.
DIODeviceNameList
);
IOManager
.
instance
.
ConnectionIOList
(
Config
.
DIODeviceNameList
);
ACServerManager
.
LogEvent
+=
ACServerManager_LogEvent
;
LEDManager
.
deviceMap
.
Add
(
Config
.
LED_IP
,
LEDBaseModule
.
GetModule
(
Config
.
LED_IP
));
MiddleAxis
=
new
AxisBean
(
Config
.
Middle_Axis
,
"料斗旋转轴"
);
mainTimer
.
Enabled
=
false
;
if
(
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
App_AutoRun
).
Equals
(
1
))
{
...
...
@@ -81,58 +80,35 @@ namespace OnlineStore.DeviceLibrary
public
override
bool
StartRun
()
{
LogUtil
.
info
(
Name
+
"开始启动:"
+
StartTime
.
ToString
()
);
LogUtil
.
info
(
Name
+
"开始启动 "
);
autoNext
=
false
;
mainTimer
.
Enabled
=
false
;
alarmType
=
StoreAlarmType
.
None
;
//急停按钮和气压检测需要一起判断
IO_VALUE
suddenBtn
=
IOManager
.
IOValue
(
IO_Type
.
SuddenStop_BTN
);
if
(
suddenBtn
==
IO_VALUE
.
HIGH
)
if
(
IOManager
.
IOValue
(
IO_Type
.
SuddenStop_BTN
).
Equals
(
IO_VALUE
.
HIGH
))
{
lastAirCloseTime
=
DateTime
.
Now
;
if
(!
RunAxis
(
true
))
if
(!
MiddleAxis
.
Open
(
true
,
out
WarnMsg
))
{
return
false
;
}
}
runStatus
=
StoreRunStatus
.
HomeMoving
;
StartReset
();
StartTime
=
DateTime
.
Now
;
mainTimer
.
Enabled
=
true
;
IoCheckTimer
.
Enabled
=
true
;
serverConnectTimer
.
Enabled
=
true
;
serverConnectTimer
.
Enabled
=
true
;
return
true
;
}
else
{
if
(
suddenBtn
.
Equals
(
IO_VALUE
.
LOW
))
{
LogUtil
.
error
(
" ("
+
Name
+
")启动出现错误:急停没开 !启动失败!"
);
}
else
{
LogUtil
.
error
(
" ("
+
Name
+
")启动出现错误:没有气压信号 !启动失败!"
);
}
LogUtil
.
error
(
" ("
+
Name
+
")启动出现错误:急停没开 !启动失败!"
);
return
false
;
}
}
#
region
复位处理
public
void
MoveToP1
()
{
//压紧轴回原点,叉子回到P1,关闭门旋转轴和升降轴回到P1
MoveInfo
.
NewMove
(
MoveType
.
StoreReset
);
MoveInfo
.
NextMoveStep
(
StoreMoveStep
.
P01_InOutToP1
);
LogUtil
.
info
(
Name
+
"到待机状态,进出轴到P1"
);
// ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1, Config.InOutAxis_P1_Speed);
}
public
override
void
Reset
(
bool
isNeedClearAuto
=
true
)
{
//复位之前先停止运行
...
...
@@ -141,9 +117,9 @@ namespace OnlineStore.DeviceLibrary
autoNext
=
false
;
}
MoveInfo
.
EndMove
();
StopAllAxis
();
MiddleAxis
.
SuddenStop
();
runStatus
=
StoreRunStatus
.
Reset
;
if
(!
RunAxis
(
true
))
if
(!
MiddleAxis
.
Open
(
true
,
out
WarnMsg
))
{
LogUtil
.
info
(
Name
+
"复位时打开轴失败,需要再次复位,直接报警停止复位"
);
return
;
...
...
@@ -164,8 +140,7 @@ namespace OnlineStore.DeviceLibrary
private
void
StartReset
()
{
WarnMsg
=
""
;
isInSuddenDown
=
false
;
isNoAirCheck
=
false
;
isInSuddenDown
=
false
;
CurrInOutCount
=
0
;
CurrInOutACount
=
0
;
CloseAllLed
();
...
...
@@ -173,10 +148,11 @@ namespace OnlineStore.DeviceLibrary
alarmType
=
StoreAlarmType
.
None
;
storeStatus
=
StoreStatus
.
ResetMove
;
MoveInfo
.
NewMove
(
MoveType
.
StoreReset
);
MoveInfo
.
NextMoveStep
(
StoreMoveStep
.
R01_InOutBack
);
// ACAxisHomeMove(Config.InOut_Axis);
LogUtil
.
info
(
Name
+
"开始原点返回,先把进出轴回原点"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
2000
));
MoveInfo
.
NextMoveStep
(
StoreMoveStep
.
R01_DoorClose
);
LogUtil
.
info
(
Name
+
"开始复位:关闭升降门,关闭所有灯"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
1000
));
DoorBean
.
StartClose
(
MoveInfo
);
LEDManager
.
GetLedModule
(
Config
.
LED_IP
).
AllLightOff
();
}
protected
override
void
ResetProcess
()
...
...
@@ -274,6 +250,8 @@ namespace OnlineStore.DeviceLibrary
VerticalStoreConfig
.
ConfigAxis
(
Config
);
moveAxisList
=
new
List
<
ConfigMoveAxis
>();
Config
.
Middle_Axis
.
Axis_Brake_DO
=
IO_Type
.
Axis_Brake
;
Config
.
Middle_Axis
.
Axis_Run_DO
=
IO_Type
.
Run_Signal
;
moveAxisList
.
Add
(
Config
.
Middle_Axis
);
this
.
AxisAlarmCodeMap
=
new
Dictionary
<
string
,
AxisAlarmInfo
>();
...
...
@@ -286,87 +264,87 @@ namespace OnlineStore.DeviceLibrary
#
endregion
public
bool
RunAxis
(
bool
isCheck
)
{
IOManager
.
IOMove
(
IO_Type
.
Run_Signal
,
IO_VALUE
.
HIGH
);
Thread
.
Sleep
(
1000
);
//打开所有轴
foreach
(
ConfigMoveAxis
moveAxis
in
moveAxisList
)
{
string
portName
=
moveAxis
.
DeviceName
;
short
slvAddr
=
moveAxis
.
GetAxisValue
();
int
bro
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
ACBaudRate
);
ACServerManager
.
OpenPort
(
portName
,
bro
);
Thread
.
Sleep
(
50
);
if
(!
IsIntSlvBlock
)
{
ACServerManager
.
InitSlvAddr
(
portName
,
slvAddr
,
moveAxis
.
TargetSpeed
,
moveAxis
.
AddSpeed
,
moveAxis
.
DelSpeed
);
Thread
.
Sleep
(
100
);
}
ACServerManager
.
AlarmClear
(
portName
,
slvAddr
);
Thread
.
Sleep
(
50
);
ACServerManager
.
ServoOn
(
portName
,
slvAddr
);
}
Thread
.
Sleep
(
1000
);
//打开所有轴
if
(
isCheck
)
{
if
(!
OpenAllAxis
())
{
return
false
;
}
}
IsIntSlvBlock
=
true
;
IOManager
.
IOMove
(
IO_Type
.
Axis_Brake
,
IO_VALUE
.
HIGH
);
return
true
;
}
//
public bool RunAxis(bool isCheck)
//
{
//
IOManager.IOMove(IO_Type.Run_Signal, IO_VALUE.HIGH);
//
Thread.Sleep(1000);
//
//打开所有轴
//
foreach (ConfigMoveAxis moveAxis in moveAxisList)
//
{
//
string portName = moveAxis.DeviceName;
//
short slvAddr = moveAxis.GetAxisValue();
//
int bro = ConfigAppSettings.GetIntValue(Setting_Init.ACBaudRate);
//
ACServerManager.OpenPort(portName,bro);
//
Thread.Sleep(50);
//
if (!IsIntSlvBlock)
//
{
//
ACServerManager.InitSlvAddr(portName, slvAddr, moveAxis.TargetSpeed, moveAxis.AddSpeed, moveAxis.DelSpeed);
//
Thread.Sleep(100);
//
}
//
ACServerManager.AlarmClear(portName, slvAddr);
//
Thread.Sleep(50);
//
ACServerManager.ServoOn(portName, slvAddr);
//
}
//
Thread.Sleep(1000);
//
//打开所有轴
//
if (isCheck)
//
{
//
if (!OpenAllAxis())
//
{
//
return false;
//
}
//
}
//
IsIntSlvBlock = true;
//
IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.HIGH);
//
return true;
//
}
private
bool
OpenAllAxis
()
{
//判断轴是否正常
foreach
(
ConfigMoveAxis
axis
in
moveAxisList
)
{
if
(
ACServerManager
.
ServerOnStatus
(
axis
.
DeviceName
,
axis
.
GetAxisValue
()))
{
LogUtil
.
info
(
Name
+
"成功打开轴:"
+
axis
.
Explain
);
}
else
{
//清理报警,再重新打开一次
LogUtil
.
info
(
Name
+
"第一次打开轴"
+
axis
.
Explain
+
"失败,先清理一下报警,再重新打开一次"
);
ACServerManager
.
AlarmClear
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
System
.
Threading
.
Thread
.
Sleep
(
1200
);
ACServerManager
.
ServoOn
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
System
.
Threading
.
Thread
.
Sleep
(
100
);
if
(
ACServerManager
.
ServerOnStatus
(
axis
.
DeviceName
,
axis
.
GetAxisValue
()))
{
LogUtil
.
info
(
Name
+
"清理报警后重新打卡轴成功:"
+
axis
.
Explain
);
}
else
{
ACServerManager
.
ServoOff
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
WarnMsg
=
Name
+
"打开轴"
+
axis
.
Explain
+
"失败 "
;
LogUtil
.
info
(
Name
+
WarnMsg
);
Alarm
(
StoreAlarmType
.
AxisAlarm
,
axis
.
ProName
,
WarnMsg
,
MoveInfo
.
MoveType
);
return
false
;
}
}
}
return
true
;
}
public
void
CloseAllAxis
()
{
LogUtil
.
info
(
Name
+
"关闭刹车,关闭伺服"
);
IOManager
.
IOMove
(
IO_Type
.
Axis_Brake
,
IO_VALUE
.
LOW
);
foreach
(
ConfigMoveAxis
axis
in
moveAxisList
)
{
ACServerManager
.
ServoOff
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
}
Thread
.
Sleep
(
100
);
IOManager
.
IOMove
(
IO_Type
.
Run_Signal
,
IO_VALUE
.
LOW
);
}
//
private bool OpenAllAxis()
//
{
//
//判断轴是否正常
//
foreach (ConfigMoveAxis axis in moveAxisList)
//
{
//
if (ACServerManager.ServerOnStatus(axis.DeviceName, axis.GetAxisValue()))
//
{
//
LogUtil.info( Name + "成功打开轴:" + axis.Explain);
//
}
//
else
//
{
//
//清理报警,再重新打开一次
//
LogUtil.info( Name + "第一次打开轴" + axis.Explain + "失败,先清理一下报警,再重新打开一次");
//
ACServerManager.AlarmClear(axis.DeviceName, axis.GetAxisValue());
//
System.Threading.Thread.Sleep(1200);
//
ACServerManager.ServoOn(axis.DeviceName, axis.GetAxisValue());
//
System.Threading.Thread.Sleep(100);
//
if (ACServerManager.ServerOnStatus(axis.DeviceName, axis.GetAxisValue()))
//
{
//
LogUtil.info( Name + "清理报警后重新打卡轴成功:" + axis.Explain);
//
}
//
else
//
{
//
ACServerManager.ServoOff(axis.DeviceName, axis.GetAxisValue());
//
WarnMsg = Name + "打开轴" + axis.Explain + "失败 ";
//
LogUtil.info( Name + WarnMsg);
//
Alarm(StoreAlarmType.AxisAlarm, axis.ProName, WarnMsg, MoveInfo.MoveType);
//
return false;
//
}
//
}
//
}
//
return true;
//
}
//
public void CloseAllAxis()
//
{
//
LogUtil.info(Name + "关闭刹车,关闭伺服");
//
IOManager.IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
//
foreach (ConfigMoveAxis axis in moveAxisList)
//
{
//
ACServerManager.ServoOff(axis.DeviceName, axis.GetAxisValue());
//
}
//
Thread.Sleep(100);
//
IOManager.IOMove(IO_Type.Run_Signal, IO_VALUE.LOW);
//
}
public
override
void
StopRun
()
{
...
...
@@ -376,9 +354,8 @@ namespace OnlineStore.DeviceLibrary
serverConnectTimer
.
Enabled
=
false
;
mainTimer
.
Enabled
=
false
;
StopMove
(
true
);
TimeSpan
span
=
DateTime
.
Now
-
StartTime
;
IOManager
.
instance
.
CloseAllDO
();
LogUtil
.
info
(
Name
+
",停止运行
,总运行时间:"
+
span
.
ToString
()
);
LogUtil
.
info
(
Name
+
",停止运行
"
);
}
public
override
void
Alarm
(
StoreAlarmType
alarmType
,
string
alarmDetial
,
string
alarmMsg
,
MoveType
storeMoveType
)
...
...
@@ -409,8 +386,7 @@ namespace OnlineStore.DeviceLibrary
storeStatus
=
StoreStatus
.
SuddenStop
;
}
else
if
(
alarmType
.
Equals
(
StoreAlarmType
.
NoAirCheck
))
{
isNoAirCheck
=
true
;
{
LogUtil
.
error
(
Name
+
" 未检测到气压信号 ,打开刹车,停止运动,关闭轴,打开报警灯 "
);
IOManager
.
IOMove
(
IO_Type
.
Axis_Brake
,
IO_VALUE
.
LOW
);
MoveInfo
.
EndMove
();
...
...
@@ -438,7 +414,7 @@ namespace OnlineStore.DeviceLibrary
IoCheckProcess
();
TimerProcess
();
//检查运动轴报警
if
(
runStatus
>
StoreRunStatus
.
Wait
&&
(!
isInSuddenDown
)
&&
(!
isNoAirCheck
)
)
if
(
runStatus
>
StoreRunStatus
.
Wait
&&
(!
isInSuddenDown
)
)
{
CheckAxisAlarm
();
}
...
...
@@ -485,17 +461,15 @@ namespace OnlineStore.DeviceLibrary
if
(
resetBtn
.
Equals
(
IO_VALUE
.
HIGH
))
{
//收到复位信号,若报警直接复位,若不报警且无操作,回到待机点
if
(
alarmType
.
Equals
(
StoreAlarmType
.
None
)
&&
isInSuddenDown
.
Equals
(
false
)
&&
isNoAirCheck
.
Equals
(
false
)
)
if
(
alarmType
.
Equals
(
StoreAlarmType
.
None
)
&&
isInSuddenDown
.
Equals
(
false
)
)
{
if
(
MoveInfo
.
MoveType
.
Equals
(
MoveType
.
None
))
{
LogUtil
.
info
(
"收到复位信号但是没有报警,且当前无操作,只回到待机点"
);
MoveToP1
();
LogUtil
.
info
(
"收到复位信号但是没有报警,且当前无操作,暂不复位"
);
}
else
{
LogUtil
.
info
(
"收到复位信号但是已经在"
+
MoveInfo
.
MoveType
+
"处理中,且无报警,不处理"
);
//WarnMsg = "收到复位信号但是已经在" + StoreMove.MoveType + "处理中,且无报警,不处理";
LogUtil
.
info
(
"收到复位信号但是已经在"
+
MoveInfo
.
MoveType
+
"处理中,且无报警,不处理"
);
}
}
else
...
...
@@ -584,7 +558,7 @@ namespace OnlineStore.DeviceLibrary
{
return
;
}
if
(
isInSuddenDown
||
isNoAirCheck
)
if
(
isInSuddenDown
)
{
return
;
}
...
...
@@ -725,11 +699,11 @@ namespace OnlineStore.DeviceLibrary
public
override
void
StopMove
(
bool
IsCloseAxis
=
false
)
{
IOManager
.
IOMove
(
IO_Type
.
Axis_Brake
,
IO_VALUE
.
LOW
);
StopAllAxis
();
MiddleAxis
.
SuddenStop
();
if
(
IsCloseAxis
)
{
CloseAllAxis
();
MiddleAxis
.
ServoOff
();
}
LogUtil
.
info
(
Name
+
"StopMove"
);
IOManager
.
IOMove
(
IO_Type
.
Door_Down
,
IO_VALUE
.
LOW
);
...
...
@@ -737,18 +711,10 @@ namespace OnlineStore.DeviceLibrary
isInPro
=
false
;
}
private
void
StopAllAxis
()
{
foreach
(
ConfigMoveAxis
axis
in
moveAxisList
)
{
ACServerManager
.
SuddenStop
(
axis
.
DeviceName
,
axis
.
GetAxisValue
());
}
}
public
bool
CanStarInOut
()
{
if
(
isInSuddenDown
||
isNoAirCheck
||
if
(
isInSuddenDown
||
(!
runStatus
.
Equals
(
StoreRunStatus
.
Runing
))
||
storeStatus
.
Equals
(
StoreStatus
.
InStoreExecute
)
||
storeStatus
.
Equals
(
StoreStatus
.
OutStoreExecute
)
||
storeStatus
.
Equals
(
StoreStatus
.
InStoreEnd
)
||
storeStatus
.
Equals
(
StoreStatus
.
OutStoreBoxEnd
))
...
...
source/DeviceLibrary/acVerticalStore/VerticalStoreBean_InOut.cs
查看文件 @
e178b7d
...
...
@@ -58,11 +58,11 @@ namespace OnlineStore.DeviceLibrary
string
msg
=
""
;
if
(
wait
.
IsHomeMove
)
{
wait
.
IsEnd
=
ACHomeMoveIsEnd
(
wait
.
AxisInfo
,
out
msg
);
wait
.
IsEnd
=
AxisBean
.
HomeMoveIsEnd
(
MoveInfo
,
wait
.
AxisInfo
,
out
msg
);
}
else
{
wait
.
IsEnd
=
A
CAxisMoveIsEnd
(
wait
.
AxisInfo
,
wait
.
TargetPosition
,
wait
.
TargetSpeed
,
out
msg
);
wait
.
IsEnd
=
A
xisBean
.
ACAxisMoveIsEnd
(
MoveInfo
,
wait
.
AxisInfo
,
wait
.
TargetPosition
,
wait
.
TargetSpeed
,
out
msg
);
}
if
(!
msg
.
Equals
(
""
))
{
...
...
@@ -135,7 +135,7 @@ namespace OnlineStore.DeviceLibrary
string
posId
=
param
!=
null
?
param
.
PosId
:
""
;
if
(
runStatus
.
Equals
(
StoreRunStatus
.
Runing
)&&
MoveInfo
.
MoveType
.
Equals
(
MoveType
.
None
))
{
if
(
!
param
.
LoadParam
(
Config
)
)
if
(
param
.
Position
==
null
)
{
LogUtil
.
error
(
Name
+
" 启动 "
+
param
.
LogName
+
"失败,找不到库位信息"
);
return
false
;
...
...
@@ -153,7 +153,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
SI_02_InOutToP1
(
MoveInfo
.
MoveParam
.
MoveP
);
//
SI_02_InOutToP1(MoveInfo.MoveParam.MoveP);
}
return
true
;
}
...
...
@@ -323,7 +323,7 @@ namespace OnlineStore.DeviceLibrary
}
private
void
SI_02_InOutToP1
(
StoreMoveP
moveP
)
private
void
SI_02_InOutToP1
(
)
{
//MoveInfo.NextMoveStep(StoreMoveStep.SI_02_InOutToP1);
//InStoreLog(" 进出轴到P1,打开舱门");
...
...
@@ -406,7 +406,7 @@ namespace OnlineStore.DeviceLibrary
protected
override
void
OutStoreProcess
()
{
StoreMoveP
moveP
=
MoveInfo
.
MoveParam
.
MoveP
;
//
StoreMoveP moveP = MoveInfo.MoveParam.MoveP;
if
(
MoveInfo
.
IsInWait
)
{
CheckWait
();
...
...
source/DeviceLibrary/device/IO/AIManager.cs
deleted
100644 → 0
查看文件 @
4be5928
using
Asa.IOModule
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
namespace
OnlineStore.DeviceLibrary
{
public
abstract
class
AIManager
{
public
bool
NeedShow
=
false
;
public
static
AIManager
Instance
=
null
;
public
static
void
Init
()
{
bool
isAIOBox
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
UseAIOBOX
).
Equals
(
1
);
if
(
isAIOBox
)
{
Instance
=
new
AIOAIManager
();
}
else
{
Instance
=
new
KNDAIManager
();
}
}
public
static
double
ConvertAI
(
double
aiValue
,
double
defaultValue
)
{
// double xishu = (double)StoreManager.Config.AI_ConvertPosition;
// double result = Math.Round((aiValue - defaultValue) / xishu, 2);
// return result;
return
0
;
}
public
abstract
void
StartConnect
(
params
string
[]
ioIp
);
public
abstract
void
CloseConnect
();
public
abstract
double
GetAIValue
(
string
ioiP
,
int
index
);
}
}
source/DeviceLibrary/device/IO/AIOBOX/AIOAIManager.cs
deleted
100644 → 0
查看文件 @
4be5928
using
Asa.IOModule
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
OnlineStore.DeviceLibrary
{
public
class
AIOAIManager
:
AIManager
{
private
object
AILock
=
""
;
private
List
<
int
>
AIValList
=
null
;
private
int
AILength
=
4
;
private
Asa
.
IOModule
.
AIOBOX
AIBox
=
null
;
private
System
.
Timers
.
Timer
conTimer
=
null
;
private
List
<
string
>
needConIp
=
new
List
<
string
>();
public
override
void
StartConnect
(
params
string
[]
ipList
)
{
if
(
conTimer
==
null
)
{
conTimer
=
new
System
.
Timers
.
Timer
();
conTimer
.
AutoReset
=
true
;
conTimer
.
Interval
=
60000
;
conTimer
.
Elapsed
+=
ConTimer_Elapsed
;
}
conTimer
.
Enabled
=
false
;
needConIp
=
new
List
<
string
>(
ipList
);
foreach
(
string
ip
in
ipList
)
{
bool
result
=
ConnectionIP
(
ip
);
}
if
(
needConIp
.
Count
>
0
)
{
//启动定时器,1一分钟重连一次
conTimer
.
Start
();
}
}
private
bool
ConnectionIP
(
string
ioIp
)
{
int
autoMS
=
150
;
try
{
AIValList
=
new
List
<
int
>();
AIBox
=
new
Asa
.
IOModule
.
AIOBOX
();
AIBox
.
IP
=
ioIp
;
// bool rtn = AIBox.AutoIP(ioIp);
AIBox
.
SetInput
(
Asa
.
IOModule
.
Box_Type
.
AI
,
AILength
);
AIBox
.
SetOutput
(
Asa
.
IOModule
.
Box_Type
.
DO
,
0
);
AIBox
.
AutoReadInput
(
true
,
autoMS
);
AIBox
.
AI_Changed_Event
+=
Box_AI_Changed_Event
;
LogUtil
.
debug
(
"开始连接AI模块["
+
ioIp
+
"]["
+
autoMS
+
"],尝试重连三次"
);
for
(
int
i
=
1
;
i
<=
3
;
i
++)
{
bool
result
=
AIBox
.
Connect
();
if
(
result
)
{
if
(
needConIp
.
Contains
(
ioIp
))
{
needConIp
.
Remove
(
ioIp
);
}
LogUtil
.
info
(
"第【"
+
i
+
"】次连接IO模块["
+
ioIp
+
"]["
+
autoMS
+
"]成功:"
+
AIBox
.
ErrInfo
);
return
true
;
}
else
{
LogUtil
.
error
(
"第【"
+
i
+
"】次连接IO模块["
+
ioIp
+
"]["
+
autoMS
+
"]失败:"
+
AIBox
.
ErrInfo
+
""
);
}
Thread
.
Sleep
(
10
);
}
}
catch
(
Exception
error
)
{
LogUtil
.
error
(
"连接IO模块["
+
ioIp
+
"]["
+
autoMS
+
"]出错:"
+
error
.
ToString
());
}
return
false
;
}
private
void
ConTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
try
{
List
<
string
>
list
=
new
List
<
string
>(
needConIp
);
if
(
list
.
Count
>
0
)
{
foreach
(
string
ip
in
list
)
{
LogUtil
.
info
(
"重连AOI AI 模块 :"
+
ip
);
ConnectionIP
(
ip
);
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"AOI AI ConTimer_Elapsed 出错: "
+
ex
.
ToString
());
}
}
public
override
void
CloseConnect
()
{
try
{
if
(
AIBox
!=
null
)
{
AIBox
.
Close
();
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"断开AI连接出错:"
+
ex
.
ToString
());
}
}
private
void
Box_AI_Changed_Event
(
AIOBOX
box
,
int
[]
val
)
{
try
{
if
(
val
!=
null
&&
val
.
Length
>=
AILength
)
{
lock
(
AILock
)
{
AIValList
=
new
List
<
int
>();
AIValList
.
AddRange
(
val
);
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"Box_AI_Changed_Event出错:"
+
ex
.
ToString
());
}
}
public
override
double
GetAIValue
(
string
ioiP
,
int
index
)
{
if
(
AIValList
!=
null
&&
AIValList
.
Count
>
index
)
{
return
AIValList
[
index
];
}
return
-
1
;
}
//public override double ConvertAI(double aiValue, double defaultValue)
//{
// double xishu = (double)ConfigAppSettings.GetNumValue(Setting_Init.AI_ConvertPosition);
// double result = Math.Round((aiValue - defaultValue) / xishu, 2);
// return result;
//}
}
}
source/DeviceLibrary/device/IO/KangNaiDe/AITcpClient.cs
deleted
100644 → 0
查看文件 @
4be5928
using
System
;
using
System.Collections
;
using
System.Text
;
using
System.IO
;
using
System.Net
;
using
System.Net.Sockets
;
using
System.Threading
;
using
System.Diagnostics
;
using
log4net
;
using
System.Reflection
;
using
OnlineStore.Common
;
namespace
OnlineStore.DeviceLibrary
{
public
class
AITcpClient
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
// ------------------------------------------------------------------------
// Constants for access
private
const
byte
fctReadCoil
=
1
;
private
const
byte
fctReadDiscreteInputs
=
2
;
private
const
byte
fctReadHoldingRegister
=
3
;
private
const
byte
fctReadInputRegister
=
4
;
private
const
byte
fctWriteSingleCoil
=
5
;
private
const
byte
fctWriteSingleRegister
=
6
;
private
const
byte
fctWriteMultipleCoils
=
15
;
private
const
byte
fctWriteMultipleRegister
=
16
;
private
const
byte
fctReadWriteMultipleRegister
=
23
;
/// <summary>Constant for exception illegal function.</summary>
public
const
byte
excIllegalFunction
=
1
;
/// <summary>Constant for exception illegal data address.</summary>
public
const
byte
excIllegalDataAdr
=
2
;
/// <summary>Constant for exception illegal data value.</summary>
public
const
byte
excIllegalDataVal
=
3
;
/// <summary>Constant for exception slave device failure.</summary>
public
const
byte
excSlaveDeviceFailure
=
4
;
/// <summary>Constant for exception acknowledge.</summary>
public
const
byte
excAck
=
5
;
/// <summary>Constant for exception slave is busy/booting up.</summary>
public
const
byte
excSlaveIsBusy
=
6
;
/// <summary>Constant for exception gate path unavailable.</summary>
public
const
byte
excGatePathUnavailable
=
10
;
/// <summary>Constant for exception not connected.</summary>
public
const
byte
excExceptionNotConnected
=
253
;
/// <summary>Constant for exception connection lost.</summary>
public
const
byte
excExceptionConnectionLost
=
254
;
/// <summary>Constant for exception response timeout.</summary>
public
const
byte
excExceptionTimeout
=
255
;
/// <summary>Constant for exception wrong offset.</summary>
private
const
byte
excExceptionOffset
=
128
;
/// <summary>Constant for exception send failt.</summary>
private
const
byte
excSendFailt
=
100
;
// ------------------------------------------------------------------------
// Private declarations
private
static
ushort
_timeout
=
500
;
private
static
ushort
_refresh
=
10
;
private
static
bool
_connected
=
false
;
private
static
bool
_autoConnectOfBreak
=
false
;
private
Socket
socketClient
;
private
int
M281_A_Len
=
0
;
private
byte
[]
tcpSocketReviceBuffer
=
new
byte
[
2048
];
//private Socket tcpSynCl;
//private byte[] tcpSynClBuffer = new byte[2048];
// ------------------------------------------------------------------------
/// <summary>Response data event. This event is called when new data arrives</summary>
public
delegate
void
ResponseData
(
string
ip
,
ushort
id
,
byte
function
,
byte
[]
data
,
byte
[]
reviceData
);
/// <summary>Response data event. This event is called when new data arrives</summary>
public
event
ResponseData
OnResponseData
;
/// <summary>Exception data event. This event is called when the data is incorrect</summary>
public
delegate
void
ExceptionData
(
string
ip
,
ushort
id
,
byte
function
,
byte
exception
,
byte
[]
reviceData
);
/// <summary>Exception data event. This event is called when the data is incorrect</summary>
public
event
ExceptionData
OnException
;
/// <summary>
/// autoConnectOfBreak
/// </summary>
public
bool
autoConnectOfBreak
{
get
{
return
_autoConnectOfBreak
;
}
set
{
_autoConnectOfBreak
=
value
;
}
}
public
static
ushort
timeout
{
get
{
return
_timeout
;
}
set
{
_timeout
=
value
;
}
}
public
ushort
refresh
{
get
{
return
_refresh
;
}
set
{
_refresh
=
value
;
}
}
public
bool
connected
{
get
{
return
_connected
;
}
}
public
AITcpClient
()
{
}
public
string
IP
=
""
;
public
int
Port
=
0
;
public
int
TimeOutTime
=
0
;
public
AITcpClient
(
string
ip
,
ushort
port
)
{
TimeOutTime
=
2000
;
connect
(
ip
,
port
);
}
private
System
.
Timers
.
Timer
reviceTimer
=
new
System
.
Timers
.
Timer
();
public
void
connect
(
string
ip
,
ushort
port
)
{
try
{
this
.
IP
=
ip
;
this
.
Port
=
port
;
OnResponseData
=
null
;
// Connect asynchronous client
socketClient
=
new
Socket
(
IPAddress
.
Parse
(
ip
).
AddressFamily
,
SocketType
.
Stream
,
ProtocolType
.
Tcp
);
if
(
TimeOutTime
<=
0
)
{
socketClient
.
Connect
(
new
IPEndPoint
(
IPAddress
.
Parse
(
ip
),
port
));
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
SendTimeout
,
_timeout
);
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
ReceiveTimeout
,
_timeout
);
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
NoDelay
,
1
);
}
else
{
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
SendTimeout
,
_timeout
);
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
ReceiveTimeout
,
_timeout
);
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
NoDelay
,
1
);
IAsyncResult
connResult
=
socketClient
.
BeginConnect
(
ip
,
port
,
null
,
null
);
connResult
.
AsyncWaitHandle
.
WaitOne
(
this
.
TimeOutTime
,
true
);
//等待2秒
if
(!
connResult
.
IsCompleted
)
{
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
ip
+
":"
+
port
+
" fail!"
);
return
;
}
else
{
_connected
=
true
;
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
ip
+
":"
+
port
+
" success!"
);
}
}
//Thread threadReceive = new Thread(new ThreadStart(ReceiveHandle));
//threadReceive.Start();
reviceTimer
.
AutoReset
=
true
;
reviceTimer
.
Elapsed
+=
reviceTimer_Elapsed
;
reviceTimer
.
Interval
=
130
;
reviceTimer
.
Enabled
=
true
;
_connected
=
true
;
}
catch
(
Exception
error
)
{
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
ip
+
":"
+
port
+
" fail!"
);
_connected
=
false
;
}
}
public
void
WriteAIScope
(
ushort
id
,
byte
slaveId
,
string
address
,
int
value
)
{
//0x000100000006FF0603EA0001
byte
function
=
0x06
;
byte
[]
data
=
new
byte
[
12
];
byte
[]
_id
=
BitConverter
.
GetBytes
((
short
)
id
);
data
[
0
]
=
_id
[
0
];
// Slave id high byte
data
[
1
]
=
_id
[
1
];
// Slave id low byte
data
[
2
]
=
0x00
;
data
[
3
]
=
0x00
;
data
[
4
]
=
0x00
;
data
[
5
]
=
6
;
// Message size
data
[
6
]
=
slaveId
;
// Slave address //必须设置为"1": 2012.04-24 覃发光;
data
[
7
]
=
function
;
;
// Function code
byte
[]
_adr
=
AcSerialBean
.
StringToByte
(
address
);
data
[
8
]
=
_adr
[
0
];
// Start address
data
[
9
]
=
_adr
[
1
];
// Start address
byte
[]
_length
=
BitConverter
.
GetBytes
((
short
)
1
);
data
[
10
]
=
_length
[
0
];
// Number of data to read
data
[
11
]
=
_length
[
1
];
// Number of data to read
WriteAsyncData
(
data
,
id
);
}
public
void
ReadAllAI
(
ushort
id
,
string
startAddress
,
int
length
,
byte
slaveId
)
{
//0x 000100000006FF0302580010
byte
function
=
0x03
;
byte
[]
data
=
CreateData
(
id
,
startAddress
,
(
ushort
)
length
,
function
,
slaveId
);
WriteAsyncData
(
data
,
id
);
}
private
byte
[]
CreateData
(
ushort
id
,
string
startAddress
,
ushort
length
,
byte
function
,
byte
SlaveID
)
{
byte
[]
data
=
new
byte
[
12
];
byte
[]
_id
=
BitConverter
.
GetBytes
((
short
)
id
);
data
[
0
]
=
_id
[
0
];
// Slave id high byte
data
[
1
]
=
_id
[
1
];
// Slave id low byte
data
[
5
]
=
6
;
// Message size
data
[
6
]
=
SlaveID
;
// Slave address //必须设置为"1": 2012.04-24 覃发光;
data
[
7
]
=
function
;
// Function code
byte
[]
_adr
=
AcSerialBean
.
StringToByte
(
startAddress
);
if
(
_adr
.
Length
.
Equals
(
2
))
{
data
[
8
]
=
_adr
[
0
];
// Start address
data
[
9
]
=
_adr
[
1
];
// Start address
}
else
if
(
_adr
.
Length
.
Equals
(
1
))
{
data
[
8
]
=
0x00
;
data
[
9
]
=
_adr
[
0
];
// Start address
}
else
{
data
[
8
]
=
0x00
;
data
[
9
]
=
0x00
;
}
byte
[]
_length
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
length
));
data
[
10
]
=
_length
[
0
];
// Number of data to read
data
[
11
]
=
_length
[
1
];
// Number of data to read
return
data
;
}
void
reviceTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
try
{
ReviceDataProcess
();
Thread
.
Sleep
(
10
);
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
"出错:"
+
ex
.
ToString
());
}
}
private
void
ReviceDataProcess
()
{
byte
[]
rdata
=
Receive
();
if
(
rdata
==
null
)
{
return
;
}
string
str
=
""
;
foreach
(
byte
by
in
rdata
)
{
str
=
str
+
" "
+
by
;
}
int
lengthIndex
=
5
;
//这里rdata就是接收到的数据,
IPEndPoint
clientipe
=
(
IPEndPoint
)
socketClient
.
RemoteEndPoint
;
byte
dataLength
=
rdata
[
lengthIndex
];
int
allLength
=
lengthIndex
+
1
+
dataLength
;
if
(
rdata
.
Length
<=
allLength
)
{
LogUtil
.
debug
(
LOGGER
,
clientipe
.
ToString
()
+
"收到数据(无需分包):"
+
str
);
ushort
id
=
BitConverter
.
ToUInt16
(
rdata
,
0
);
byte
function
=
rdata
[
7
];
DataProcess
(
clientipe
.
ToString
(),
id
,
function
,
rdata
);
return
;
}
int
currStartIndex
=
0
;
try
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
if
(
rdata
.
Length
<
currStartIndex
+
lengthIndex
)
{
LogUtil
.
error
(
clientipe
.
ToString
()
+
"收到数据:"
+
str
+
"分包出错 ["
+
currStartIndex
+
"]"
);
break
;
}
else
{
dataLength
=
rdata
[
currStartIndex
+
lengthIndex
];
allLength
=
lengthIndex
+
1
+
dataLength
;
byte
[]
thisData
=
new
byte
[
allLength
];
Array
.
Copy
(
rdata
,
currStartIndex
,
thisData
,
0
,
allLength
);
ushort
id
=
BitConverter
.
ToUInt16
(
thisData
,
0
);
byte
function
=
thisData
[
7
];
DataProcess
(
clientipe
.
ToString
(),
id
,
function
,
thisData
);
//剩余的数据处理
if
(
rdata
.
Length
<=
currStartIndex
+
allLength
)
{
break
;
}
currStartIndex
=
currStartIndex
+
allLength
;
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
clientipe
.
ToString
()
+
"收到数据:"
+
str
+
"分包出错 ["
+
currStartIndex
+
"]:"
+
ex
.
ToString
());
}
}
private
void
DataProcess
(
string
clientIp
,
ushort
id
,
byte
function
,
byte
[]
rdata
)
{
byte
[]
data
;
if
(
rdata
.
Length
<=
9
)
{
return
;
}
if
((
function
>=
fctWriteSingleCoil
)
&&
(
function
!=
fctReadWriteMultipleRegister
))
{
data
=
new
byte
[
2
];
Array
.
Copy
(
rdata
,
10
,
data
,
0
,
2
);
}
// ------------------------------------------------------------
// Read response data
else
{
data
=
new
byte
[
rdata
[
8
]];
Array
.
Copy
(
rdata
,
9
,
data
,
0
,
rdata
[
8
]);
}
// ------------------------------------------------------------
// Response data is slave exception
if
(
function
>
excExceptionOffset
)
{
function
-=
excExceptionOffset
;
CallException
(
id
,
function
,
rdata
[
8
],
rdata
);
}
// ------------------------------------------------------------
// Response data is regular data
else
if
(
OnResponseData
!=
null
)
{
//收到的数据打印出来
OnResponseData
(
clientIp
,
id
,
function
,
data
,
rdata
);
}
}
private
byte
[]
Receive
()
{
try
{
if
(
socketClient
==
null
||
!
socketClient
.
Connected
||
socketClient
.
Available
<
1
)
{
return
null
;
}
int
size
=
socketClient
.
Available
;
byte
[]
rData
=
new
byte
[
size
];
socketClient
.
Receive
(
rData
,
size
,
SocketFlags
.
None
);
return
rData
;
}
catch
(
SocketException
e
)
{
if
(
socketClient
!=
null
)
{
socketClient
.
Close
();
socketClient
=
null
;
}
return
null
;
}
}
public
void
disconnect
()
{
Dispose
();
}
~
AITcpClient
()
{
Dispose
();
}
public
void
Dispose
()
{
reviceTimer
.
Enabled
=
false
;
if
(
socketClient
!=
null
)
{
if
(
socketClient
.
Connected
)
{
try
{
socketClient
.
Shutdown
(
SocketShutdown
.
Both
);
}
catch
{
}
socketClient
.
Close
();
}
socketClient
=
null
;
}
}
internal
void
CallException
(
ushort
id
,
byte
function
,
byte
exception
,
byte
[]
rdata
)
{
reviceTimer
.
Enabled
=
false
;
if
((
socketClient
==
null
))
{
return
;
}
if
(
exception
==
excExceptionConnectionLost
)
{
//tcpSynCl = null;
socketClient
=
null
;
return
;
}
if
(
OnException
!=
null
)
{
OnException
(
socketClient
.
RemoteEndPoint
.
AddressFamily
.
ToString
(),
id
,
function
,
exception
,
rdata
);
}
}
public
void
WriteAsyncData
(
byte
[]
write_data
,
ushort
id
)
{
try
{
if
(
socketClient
==
null
)
{
LOGGER
.
Error
(
"AITcpClient发送数据时发现socketClient=null"
);
return
;
}
IPEndPoint
clientipe
=
(
IPEndPoint
)
socketClient
.
RemoteEndPoint
;
if
((
socketClient
!=
null
)
&&
(
socketClient
.
Connected
))
{
try
{
//LogUtil.info( clientipe.ToString()+"发送数据:" + AcSerialBean.byteToHexStr(write_data));
socketClient
.
BeginSend
(
write_data
,
0
,
write_data
.
Length
,
SocketFlags
.
None
,
new
AsyncCallback
(
OnSend
),
null
);
//socketClient.BeginReceive(tcpSocketReviceBuffer, 0, tcpSocketReviceBuffer.Length, SocketFlags.None, new AsyncCallback(OnReceive), socketClient);
ReviceDataProcess
();
}
catch
(
SystemException
error
)
{
CallException
(
id
,
write_data
[
7
],
excExceptionConnectionLost
,
tcpSocketReviceBuffer
);
}
}
else
CallException
(
id
,
write_data
[
7
],
excExceptionConnectionLost
,
tcpSocketReviceBuffer
);
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
"出错:"
+
ex
.
ToString
());
}
}
// ------------------------------------------------------------------------
// Write asynchronous data acknowledge
private
void
OnSend
(
System
.
IAsyncResult
result
)
{
if
(
result
.
IsCompleted
==
false
)
CallException
(
0xFFFF
,
0xFF
,
excSendFailt
,
tcpSocketReviceBuffer
);
}
internal
bool
ISConnection
()
{
if
(
socketClient
==
null
)
{
return
false
;
}
if
(
socketClient
.
Connected
==
false
)
{
return
false
;
}
return
true
;
}
}
}
source/DeviceLibrary/device/IO/KangNaiDe/KNDAIManager.cs
deleted
100644 → 0
查看文件 @
4be5928
using
log4net
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
System.Threading
;
//using FuBaRobot.LoadCSVLibrary;
namespace
OnlineStore.DeviceLibrary
{
/// <summary>
/// 康奈德IO控制模块
/// </summary>
public
class
KNDAIManager
:
AIManager
{
public
ushort
DefaultAILength
=
8
;
public
byte
DefualtSlaveID
=
255
;
private
string
AIStartAddress
=
"0258"
;
public
Dictionary
<
string
,
AITcpClient
>
mastMap
=
new
Dictionary
<
string
,
AITcpClient
>();
public
Dictionary
<
string
,
List
<
KNDAI
>>
AIValueMap
=
new
Dictionary
<
string
,
List
<
KNDAI
>>();
private
object
AIMapLock
=
""
;
public
System
.
Timers
.
Timer
timer
=
null
;
private
ushort
port
=
502
;
//public static bool IsNeedReadAI = true;
public
override
void
StartConnect
(
params
string
[]
ioIps
)
{
if
(
timer
==
null
)
{
timer
=
new
System
.
Timers
.
Timer
();
timer
.
Interval
=
300
;
timer
.
AutoReset
=
true
;
timer
.
Elapsed
+=
timer_Elapsed
;
timer
.
Enabled
=
true
;
}
AITcpClient
MBmaster
=
null
;
foreach
(
string
ioIp
in
ioIps
)
{
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
if
(
null
!=
MBmaster
)
{
MBmaster
.
disconnect
();
MBmaster
.
Dispose
();
MBmaster
=
null
;
lock
(
AIMapLock
)
{
if
(
AIValueMap
.
ContainsKey
(
ioIp
))
{
AIValueMap
.
Remove
(
ioIp
);
}
}
}
mastMap
.
Remove
(
ioIp
);
}
try
{
// Create new modbus master and add event functions
MBmaster
=
new
AITcpClient
(
ioIp
,
port
);
MBmaster
.
OnResponseData
+=
new
AITcpClient
.
ResponseData
(
MBmaster_OnResponseData
);
MBmaster
.
OnException
+=
new
AITcpClient
.
ExceptionData
(
MBmaster_OnException
);
MBmaster
.
autoConnectOfBreak
=
false
;
mastMap
.
Add
(
ioIp
,
MBmaster
);
LogUtil
.
info
(
"连接AI模块["
+
ioIp
+
"]成功"
);
Thread
.
Sleep
(
10
);
WriteAIScope
(
ioIp
,
1
);
Thread
.
Sleep
(
10
);
ReadAll
(
ioIp
);
}
catch
(
Exception
error
)
{
LogUtil
.
error
(
"连接AI模块["
+
ioIp
+
"]出错:"
+
error
.
ToString
());
}
}
}
private
void
ReadAll
(
string
ioIp
)
{
//读取所有的DO
ReadMultipleAI
(
ioIp
,
DefualtSlaveID
,
AIStartAddress
,
DefaultAILength
);
}
/// <summary>
/// 判断Io模块是否连接
/// </summary>
public
bool
IsConnection
(
string
ip
)
{
try
{
List
<
string
>
list
=
new
List
<
string
>(
mastMap
.
Keys
);
foreach
(
string
io
in
list
)
{
if
(
io
.
Equals
(
ip
))
{
//判断是否连接,如果没有连接自动重连
AITcpClient
clinet
=
mastMap
[
io
];
if
(
clinet
.
ISConnection
())
{
return
true
;
}
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"出错啦:"
+
ex
.
ToString
());
}
return
false
;
}
private
DateTime
PreCheckTime
=
DateTime
.
Now
;
private
bool
isProcess
=
false
;
private
void
timer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
if
(
isProcess
)
{
return
;
}
try
{
isProcess
=
true
;
bool
IsNeedReadAI
=
false
;
// bool IsNeedReadAI = IOManager.IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.HIGH) || NeedShow;
TimeSpan
span
=
DateTime
.
Now
-
PreCheckTime
;
List
<
string
>
list
=
new
List
<
string
>(
mastMap
.
Keys
);
foreach
(
string
IP
in
list
)
{
//判断是否连接,如果没有连接自动重连
AITcpClient
clinet
=
mastMap
[
IP
];
if
(!
IsNeedReadAI
)
{
ClearAIData
(
IP
);
continue
;
}
if
(
clinet
.
ISConnection
())
{
ReadAll
(
clinet
.
IP
);
}
else
if
(
span
.
TotalSeconds
>
3
)
{
LogUtil
.
error
(
"AI模块"
+
IP
+
"当前没有连上,重连"
+
IP
);
StartConnect
(
IP
);
PreCheckTime
=
DateTime
.
Now
;
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"出错啦:"
+
ex
.
ToString
());
}
Thread
.
Sleep
(
2
);
isProcess
=
false
;
}
private
void
WriteAIScope
(
string
ioIp
,
int
value
)
{
// 0 表示 0 - 10V, 1 表示 0 - 5V
WriteAIScope
(
ioIp
,
DefualtSlaveID
,
"03EA"
,
value
);
}
private
void
WriteAIScope
(
string
ioIp
,
byte
slaveId
,
string
Adress
,
int
value
)
{
// 写 AI 模块采样范围,可以往寄存器里面写入 0 或 1。 0 表示 0 - 10V, 1 表示 0 - 5V。默
//认 0,写 AI 模块采样范围为 0 - 5V
ushort
ID
=
1
;
AITcpClient
MBmaster
=
null
;
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
MBmaster
.
WriteAIScope
(
ID
,
slaveId
,
Adress
,
value
);
}
else
{
LogUtil
.
error
(
"WriteAIScope出错没有连接AI模块:"
+
ioIp
);
}
}
private
void
ReadMultipleAI
(
string
ioIp
,
byte
slaveId
,
string
StartAddress
,
int
length
)
{
ushort
ID
=
1
;
AITcpClient
MBmaster
=
null
;
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
MBmaster
.
ReadAllAI
(
ID
,
StartAddress
,
length
*
2
,
slaveId
);
}
else
{
LogUtil
.
error
(
"ReadMultipleAI出错没有连接AI模块:"
+
ioIp
);
}
}
public
override
void
CloseConnect
()
{
List
<
AITcpClient
>
list
=
new
List
<
AITcpClient
>();
foreach
(
AITcpClient
tcp
in
list
)
{
tcp
.
disconnect
();
}
mastMap
.
Clear
();
}
public
override
double
GetAIValue
(
string
ioiP
,
int
index
)
{
double
aiValue
=
GetAIValue
(
ioiP
,
DefualtSlaveID
,
index
-
1
);
return
Math
.
Round
(
aiValue
,
2
);
}
public
double
GetAIValue
(
string
ioIP
,
byte
slaveId
,
int
index
)
{
double
value
=
0
;
try
{
lock
(
AIMapLock
)
{
if
(
AIValueMap
.
ContainsKey
(
ioIP
))
{
List
<
KNDAI
>
allIo
=
new
List
<
KNDAI
>(
AIValueMap
[
ioIP
]);
List
<
KNDAI
>
list
=
(
from
m
in
allIo
where
m
.
SlaveId
.
Equals
(
slaveId
)
&&
m
.
AIIndex
.
Equals
(
index
)
select
m
).
ToList
<
KNDAI
>();
if
(
list
.
Count
>
0
)
{
value
=
list
[
0
].
AIValue
;
}
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"GetAIValue 出错了 :ioIP["
+
ioIP
+
"]index["
+
index
+
"]:"
+
ex
);
}
return
value
;
}
private
void
ClearAIData
(
string
ioIp
)
{
byte
[]
datas
=
new
byte
[
32
];
for
(
int
i
=
0
;
i
<
datas
.
Length
;
i
++)
{
datas
[
i
]
=
0
;
}
SaveAIData
(
ioIp
,
3
,
datas
);
}
private
void
SaveAIData
(
string
ioIp
,
ushort
ID
,
byte
[]
values
)
{
try
{
if
(
values
.
Length
.
Equals
(
DefaultAILength
*
4
))
{
List
<
KNDAI
>
kndList
=
new
List
<
KNDAI
>();
string
strFromat
=
"{0:X2}"
;
string
msg
=
""
;
for
(
int
index
=
0
;
index
<
DefaultAILength
;
index
++)
{
string
str1
=
String
.
Format
(
strFromat
,
values
[
index
*
4
+
2
])
+
String
.
Format
(
strFromat
,
values
[
index
*
4
+
3
])
+
String
.
Format
(
strFromat
,
values
[
index
*
4
+
1
])
+
String
.
Format
(
strFromat
,
values
[
index
*
4
]);
double
value
=
BitToFloat
(
str1
);
KNDAI
io
=
new
KNDAI
(
ioIp
,
(
byte
)
DefualtSlaveID
,
index
,
value
);
if
(
value
>
0
)
{
Console
.
WriteLine
(
str1
+
" float convert = {0}"
,
value
);
}
msg
+=
"【"
+
index
+
"="
+
value
+
"】"
;
kndList
.
Add
(
io
);
}
//LogUtil.info(msg);
lock
(
AIMapLock
)
{
if
(
AIValueMap
.
ContainsKey
(
ioIp
))
{
AIValueMap
.
Remove
(
ioIp
);
}
AIValueMap
.
Add
(
ioIp
,
kndList
);
}
try
{
//if (StoreManager.Store != null && IOManager.IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.HIGH))
//{
// if (StoreManager.Config.AIDI1_Addr > 0 && StoreManager.Config.AIDI2_Addr > 0)
// { //每次上传后验证下
// int v1 = (int)GetAIValue(ioIp, StoreManager.Config.AIDI1_Addr);
// int v2 = (int)GetAIValue(ioIp, StoreManager.Config.AIDI2_Addr);
// if (v1.Equals(0) && v2.Equals(0))
// {
// LogUtil.info(msg);
// string value = AcSerialBean.ByteToString(values);
// LogUtil.error("收到【" + ioIp + "】的数据【" + value + "】,2个高度都为0");
// // ConnectionIP(ioIp);
// }
// }
// else if (StoreManager.Config.AIDI3_Addr > 0 && StoreManager.Config.AIDI4_Addr > 0)
// { //每次上传后验证下
// int v1 = (int)GetAIValue(ioIp, StoreManager.Config.AIDI3_Addr);
// int v2 = (int)GetAIValue(ioIp, StoreManager.Config.AIDI4_Addr);
// if (v1.Equals(0) && v2.Equals(0))
// {
// LogUtil.info(msg);
// string value = AcSerialBean.ByteToString(values);
// LogUtil.error("收到【" + ioIp + "】的数据【" + value + "】,2个高度都为0");
// // ConnectionIP(ioIp);
// }
// }
//}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"验证数据出错:"
+
ex
.
StackTrace
);
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"SaveAIData出错:"
+
ex
.
ToString
());
}
}
private
float
BitToFloat
(
string
hexString
)
{
uint
num
=
uint
.
Parse
(
hexString
,
System
.
Globalization
.
NumberStyles
.
AllowHexSpecifier
);
byte
[]
floatVals
=
BitConverter
.
GetBytes
(
num
);
float
f
=
BitConverter
.
ToSingle
(
floatVals
,
0
);
return
f
;
}
private
void
MBmaster_OnResponseData
(
string
ioIp
,
ushort
ID
,
byte
function
,
byte
[]
values
,
byte
[]
reviceData
)
{
try
{
if
(
ioIp
.
IndexOf
(
":"
)
>
0
)
{
ioIp
=
ioIp
.
Substring
(
0
,
ioIp
.
IndexOf
(
":"
));
}
string
strFromat
=
"{0:X2}"
;
string
reviceMsg
=
""
;
foreach
(
byte
data
in
reviceData
)
{
reviceMsg
=
reviceMsg
+
" "
+
String
.
Format
(
strFromat
,
data
);
if
(
reviceMsg
.
Length
>
200
)
{
break
;
}
}
// LOGGER.Info ("Read data:【" + reviceMsg + "】 ");
if
(
ID
==
0xFF
)
{
return
;
}
// ------------------------------------------------------------------------
// Identify requested data
ushort
Func
=
ID
;
if
(
Func
==
0
&&
reviceData
.
Length
>
8
)
{
Func
=
reviceData
[
7
];
}
byte
SlaveId
=
0xFF
;
if
(
reviceData
.
Length
>=
7
)
{
SlaveId
=
reviceData
[
6
];
}
switch
(
function
)
{
case
1
:
//LOGGER.Info("Read coils end:【" + reviceMsg + "】 ");
break
;
case
2
:
//LOGGER.Info("Read discrete inputs end:【" + reviceMsg + "】 ");
//SaveAIData(ioIp, SlaveId, values);
break
;
case
3
:
SaveAIData
(
ioIp
,
ID
,
values
);
break
;
case
4
:
//LOGGER.Info("读入(多个)寄存器完成 end:【" + reviceMsg + "】 ");
break
;
case
5
:
//LOGGER.Info("Write single coil:【" + reviceMsg + "】 ");
break
;
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"处理接受数据出错:"
+
ex
.
ToString
());
}
}
private
void
MBmaster_OnException
(
string
ioIp
,
ushort
id
,
byte
function
,
byte
exception
,
byte
[]
reviceData
)
{
string
exc
=
"Modbus says error: "
;
switch
(
exception
)
{
case
AITcpClient
.
excIllegalFunction
:
exc
+=
"Illegal function!"
;
break
;
case
AITcpClient
.
excIllegalDataAdr
:
exc
+=
"Illegal data adress!"
;
break
;
case
AITcpClient
.
excIllegalDataVal
:
exc
+=
"Illegal data value!"
;
break
;
case
AITcpClient
.
excSlaveDeviceFailure
:
exc
+=
"Slave device failure!"
;
break
;
case
AITcpClient
.
excAck
:
exc
+=
"Acknoledge!"
;
break
;
case
AITcpClient
.
excSlaveIsBusy
:
exc
+=
"Slave is busy!"
;
break
;
case
AITcpClient
.
excGatePathUnavailable
:
exc
+=
"Gateway path unavailbale!"
;
break
;
case
AITcpClient
.
excExceptionTimeout
:
exc
+=
"Slave timed out!"
;
break
;
case
AITcpClient
.
excExceptionConnectionLost
:
exc
+=
"Connection is lost!"
;
break
;
case
AITcpClient
.
excExceptionNotConnected
:
exc
+=
"Not connected!"
;
break
;
default
:
break
;
}
LogUtil
.
error
(
"接收数据出错:"
+
exc
);
}
}
public
class
KNDAI
{
public
KNDAI
(
string
ioIp
,
byte
ID
,
int
index
,
double
value
)
{
this
.
IoIP
=
ioIp
;
this
.
SlaveId
=
ID
;
this
.
AIIndex
=
index
;
this
.
AIValue
=
value
;
UpdateTime
=
DateTime
.
Now
;
}
/// <summary>
/// AI模块IP
/// </summary>
public
string
IoIP
{
get
;
set
;
}
/// <summary>
/// 地址
/// </summary>
public
byte
SlaveId
{
get
;
set
;
}
/// <summary>
/// 第几个AI
/// </summary>
public
int
AIIndex
{
get
;
set
;
}
/// <summary>
/// 值
/// </summary>
public
double
AIValue
{
get
;
set
;
}
/// <summary>
/// 更新时间
/// </summary>
public
DateTime
UpdateTime
{
get
;
set
;
}
}
}
source/DeviceLibrary/device/IO/KangNaiDe/KNDManager.cs
deleted
100644 → 0
查看文件 @
4be5928
using
log4net
;
using
OnlineStore.Common
;
//using OnlineStore.DeviceLibrary.doubleStore;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
System.Threading
;
namespace
OnlineStore.DeviceLibrary
{
/// <summary>
/// 康奈德IO控制模块
/// </summary>
public
class
KNDManager
:
IOManager
{
public
static
ushort
DIStartAddress
=
200
;
public
static
ushort
DoStartAddress
=
100
;
//public static ushort DefaultDILength = 16;
//public static ushort DefaultDOLength = 16;
private
static
byte
DefualtSlaveID
=
255
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
public
static
Dictionary
<
string
,
MasterTcpClient
>
mastMap
=
new
Dictionary
<
string
,
MasterTcpClient
>();
public
static
Dictionary
<
string
,
List
<
KNDIO
>>
DIValueMap
=
new
Dictionary
<
string
,
List
<
KNDIO
>>();
public
static
Dictionary
<
string
,
List
<
KNDIO
>>
DOValueMap
=
new
Dictionary
<
string
,
List
<
KNDIO
>>();
private
static
object
DIMapLock
=
""
;
private
static
object
DOMapLock
=
""
;
public
static
System
.
Timers
.
Timer
timer
=
null
;
private
static
ushort
port
=
502
;
public
static
void
ConnectionIP
(
string
ioIp
)
{
if
(
timer
==
null
)
{
timer
=
new
System
.
Timers
.
Timer
();
timer
.
Interval
=
1000
;
timer
.
AutoReset
=
true
;
timer
.
Elapsed
+=
timer_Elapsed
;
timer
.
Enabled
=
true
;
}
MasterTcpClient
MBmaster
=
null
;
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
if
(
null
!=
MBmaster
)
{
MBmaster
.
disconnect
();
MBmaster
.
Dispose
();
MBmaster
=
null
;
lock
(
DIMapLock
)
{
if
(
DIValueMap
.
ContainsKey
(
ioIp
))
{
DIValueMap
.
Remove
(
ioIp
);
}
}
lock
(
DOMapLock
)
{
if
(
DOValueMap
.
ContainsKey
(
ioIp
))
{
DOValueMap
.
Remove
(
ioIp
);
}
}
}
mastMap
.
Remove
(
ioIp
);
}
try
{
// Create new modbus master and add event functions
MBmaster
=
new
MasterTcpClient
(
ioIp
,
port
);
MBmaster
.
OnResponseData
+=
new
MasterTcpClient
.
ResponseData
(
MBmaster_OnResponseData
);
MBmaster
.
OnException
+=
new
MasterTcpClient
.
ExceptionData
(
MBmaster_OnException
);
MBmaster
.
autoConnectOfBreak
=
false
;
mastMap
.
Add
(
ioIp
,
MBmaster
);
Thread
.
Sleep
(
10
);
//读取所有的DO
ReadMultipleDO
(
ioIp
,
DefualtSlaveID
,
DoStartAddress
,
StoreManager
.
Config
.
GetDOLength
(
ioIp
));
}
catch
(
Exception
error
)
{
LogUtil
.
error
(
LOGGER
,
"连接IO模块["
+
ioIp
+
"]出错:"
+
error
.
ToString
());
}
}
public
override
void
ReadAllDI
(
string
ioIp
,
byte
slaveId
)
{
ReadMultipleDI
(
ioIp
,
(
byte
)
slaveId
,
(
ushort
)
DIStartAddress
,
16
);
}
public
override
void
ReadAllDO
(
string
ioIp
,
byte
slaveId
)
{
ReadMultipleDO
(
ioIp
,
(
byte
)
slaveId
,
(
ushort
)
DoStartAddress
,
16
);
}
/// <summary>
/// 判断Io模块是否连接
/// </summary>
public
static
bool
IsConnection
(
string
ip
)
{
try
{
List
<
string
>
list
=
new
List
<
string
>(
mastMap
.
Keys
);
foreach
(
string
io
in
list
)
{
if
(
io
.
Equals
(
ip
))
{
//判断是否连接,如果没有连接自动重连
MasterTcpClient
clinet
=
mastMap
[
io
];
if
(
clinet
.
ISConnection
())
{
return
true
;
}
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"出错啦:"
+
ex
.
ToString
());
}
return
false
;
}
private
static
void
timer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
try
{
List
<
string
>
list
=
new
List
<
string
>(
mastMap
.
Keys
);
foreach
(
string
io
in
list
)
{
//判断是否连接,如果没有连接自动重连
MasterTcpClient
clinet
=
mastMap
[
io
];
if
(
clinet
.
ISConnection
())
{
//ReadMultipleDI(io, DefualtSlaveID, DIStartAddress, DefualtLength);
}
else
{
ConnectionIP
(
io
);
LogUtil
.
error
(
LOGGER
,
io
+
"当前没有连上,重连"
+
io
);
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"出错啦:"
+
ex
.
ToString
());
}
Thread
.
Sleep
(
1
);
}
public
override
void
ConnectionIOList
(
List
<
string
>
DIONameList
)
{
foreach
(
string
ip
in
DIONameList
)
{
ConnectionIP
(
ip
);
}
}
public
static
void
ReadMultipleDI
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
ushort
length
)
{
ushort
ID
=
2
;
MasterTcpClient
MBmaster
=
null
;
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
MBmaster
.
ReadDiscreteInputs
(
ID
,
StartAddress
,
length
,
slaveId
);
}
else
{
LogUtil
.
error
(
LOGGER
,
"ReadMultipleDI出错 没有连接IO模块:"
+
ioIp
);
}
}
public
static
void
ReadMultipleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
ushort
length
)
{
ushort
ID
=
1
;
MasterTcpClient
MBmaster
=
null
;
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
MBmaster
.
ReadCoils
(
ID
,
StartAddress
,
length
,
slaveId
);
}
else
{
LogUtil
.
error
(
LOGGER
,
"ReadMultipleDO出错 没有连接IO模块:"
+
ioIp
);
}
}
//关闭所有的DO
public
override
void
CloseAllDO
()
{
foreach
(
string
key
in
mastMap
.
Keys
)
{
byte
[]
data
=
new
byte
[]
{
0
,
0
};
WriteMultipleDO
(
key
,
DefualtSlaveID
,
DoStartAddress
,
StoreManager
.
Config
.
GetDOLength
(
key
),
data
);
}
}
public
override
void
CloseAllConnection
()
{
foreach
(
MasterTcpClient
tcp
in
mastMap
.
Values
)
{
tcp
.
disconnect
();
}
mastMap
.
Clear
();
timer
.
Stop
();
timer
=
null
;
}
public
static
void
CloseAllDO
(
string
ioIp
,
byte
slaveId
)
{
ushort
length
=
StoreManager
.
Config
.
GetDOLength
(
ioIp
);
byte
[]
bytes
=
new
byte
[
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
bytes
[
i
]
=
0
;
}
WriteMultipleDO
(
ioIp
,
slaveId
,
DoStartAddress
,
length
,
bytes
);
}
public
static
void
WriteMultipleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
ushort
length
,
byte
[]
bytes
)
{
ushort
ID
=
6
;
MasterTcpClient
MBmaster
=
null
;
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
MBmaster
.
WriteMultipleCoils
(
ID
,
StartAddress
,
length
,
bytes
,
slaveId
);
}
else
{
LogUtil
.
error
(
LOGGER
,
"WriteMultipleDO 出错 没有连接IO模块:"
+
ioIp
);
}
}
public
override
void
WriteSingleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
IO_VALUE
onOff
)
{
ushort
ID
=
5
;
MasterTcpClient
MBmaster
=
null
;
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
MBmaster
.
WriteSingleCoils
(
ID
,
StartAddress
,
onOff
,
slaveId
);
KNDIO
io
=
new
KNDIO
(
ioIp
,
slaveId
,
StartAddress
,
onOff
);
SaveDOValue
(
io
,
ioIp
);
}
else
{
LogUtil
.
error
(
LOGGER
,
"WriteSingleDO 出错没有连接IO模块:"
+
ioIp
);
}
}
public
override
void
WriteSingleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
IO_VALUE
onOff
,
int
mSeconds
)
{
ushort
ID
=
5
;
MasterTcpClient
MBmaster
=
null
;
if
(
mastMap
.
ContainsKey
(
ioIp
))
{
MBmaster
=
mastMap
[
ioIp
];
MBmaster
.
WriteSingleCoils
(
ID
,
StartAddress
,
onOff
,
slaveId
);
KNDIO
io
=
new
KNDIO
(
ioIp
,
slaveId
,
StartAddress
,
onOff
);
SaveDOValue
(
io
,
ioIp
);
//写入之后,等待指定间隔后回写
System
.
Timers
.
Timer
mytimer
=
new
System
.
Timers
.
Timer
(
mSeconds
);
mytimer
.
Elapsed
+=
(
o1
,
e1
)
=>
{
try
{
IO_VALUE
newValue
=
IO_VALUE
.
LOW
;
if
(
onOff
.
Equals
(
IO_VALUE
.
LOW
))
{
newValue
=
IO_VALUE
.
HIGH
;
}
MBmaster
.
WriteSingleCoils
(
ID
,
StartAddress
,
newValue
,
slaveId
);
KNDIO
newIo
=
new
KNDIO
(
ioIp
,
slaveId
,
StartAddress
,
newValue
);
SaveDOValue
(
newIo
,
ioIp
);
LogUtil
.
info
(
LOGGER
,
"**********定时回写入 IO【"
+
ioIp
+
","
+
StartAddress
+
",值"
+
onOff
+
"】:"
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"**********定时回写入 出错:"
+
ex
.
StackTrace
);
}
};
mytimer
.
AutoReset
=
false
;
//设置是否自动重启,即自动执行多次;
mytimer
.
Enabled
=
true
;
//是否执行System.Timers.Timer.Elapsed事件mytask;
}
else
{
LogUtil
.
error
(
LOGGER
,
"WriteSingleDO出错 没有连接IO模块:"
+
ioIp
);
}
}
private
static
void
SaveDOValue
(
KNDIO
io
,
string
ioIp
)
{
try
{
lock
(
DOMapLock
)
{
if
(!
DOValueMap
.
ContainsKey
(
ioIp
))
{
DOValueMap
.
Add
(
ioIp
,
new
List
<
KNDIO
>());
DOValueMap
[
ioIp
].
Add
(
io
);
}
else
{
List
<
KNDIO
>
ios
=
DOValueMap
[
ioIp
];
List
<
KNDIO
>
list
=
(
from
m
in
ios
where
m
.
SlaveId
.
Equals
(
io
.
SlaveId
)
&&
m
.
IOAddress
.
Equals
(
io
.
IOAddress
)
select
m
).
ToList
<
KNDIO
>();
if
(
list
.
Count
>
0
)
{
DOValueMap
[
ioIp
].
Remove
(
list
[
0
]);
DOValueMap
[
ioIp
].
Add
(
io
);
}
else
{
DOValueMap
[
ioIp
].
Add
(
io
);
}
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"SaveDOValue出错:"
+
ex
.
ToString
());
}
}
public
override
IO_VALUE
GetDOValue
(
string
ioIP
,
byte
slaveId
,
ushort
StartAddress
)
{
IO_VALUE
value
=
IO_VALUE
.
LOW
;
if
(
DOValueMap
.
ContainsKey
(
ioIP
))
{
List
<
KNDIO
>
allIo
=
new
List
<
KNDIO
>(
DOValueMap
[
ioIP
]);
List
<
KNDIO
>
list
=
(
from
m
in
allIo
where
m
.
SlaveId
.
Equals
(
slaveId
)
&&
m
.
IOAddress
.
Equals
(
StartAddress
)
select
m
).
ToList
<
KNDIO
>();
if
(
list
.
Count
>
0
)
{
value
=
list
[
0
].
IoValue
;
}
}
return
value
;
}
public
override
IO_VALUE
GetDIValue
(
string
ioIP
,
byte
slaveId
,
ushort
StartAddress
)
{
IO_VALUE
value
=
IO_VALUE
.
LOW
;
if
(
DIValueMap
.
ContainsKey
(
ioIP
))
{
List
<
KNDIO
>
allIo
=
new
List
<
KNDIO
>(
DIValueMap
[
ioIP
]);
List
<
KNDIO
>
list
=
(
from
m
in
allIo
where
m
.
SlaveId
.
Equals
(
slaveId
)
&&
m
.
IOAddress
.
Equals
(
StartAddress
)
select
m
).
ToList
<
KNDIO
>();
if
(
list
.
Count
>
0
)
{
value
=
list
[
0
].
IoValue
;
}
}
return
value
;
}
public
override
IO_VALUE
GetIOValue
(
ConfigIO
configIO
)
{
IO_VALUE
value
=
IO_VALUE
.
LOW
;
try
{
if
(
configIO
.
ProType
.
Equals
(
ConfigItemType
.
DI
))
{
if
(
DIValueMap
.
ContainsKey
(
configIO
.
IO_IP
))
{
List
<
KNDIO
>
allIo
=
new
List
<
KNDIO
>(
DIValueMap
[
configIO
.
IO_IP
]);
List
<
KNDIO
>
list
=
(
from
m
in
allIo
where
m
.
IOAddress
.
Equals
(
configIO
.
GetIOAddr
())
select
m
).
ToList
<
KNDIO
>();
if
(
list
.
Count
>
0
)
{
value
=
list
[
0
].
IoValue
;
}
}
}
else
if
(
configIO
.
ProType
.
Equals
(
ConfigItemType
.
DO
))
{
if
(
DOValueMap
.
ContainsKey
(
configIO
.
IO_IP
))
{
List
<
KNDIO
>
allIo
=
new
List
<
KNDIO
>(
DOValueMap
[
configIO
.
IO_IP
]);
List
<
KNDIO
>
list
=
(
from
m
in
allIo
where
m
.
SlaveId
.
Equals
(
configIO
.
SlaveID
)
&&
m
.
IOAddress
.
Equals
(
configIO
.
GetIOAddr
())
select
m
).
ToList
<
KNDIO
>();
if
(
list
.
Count
>
0
)
{
value
=
list
[
0
].
IoValue
;
}
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"获取数据出错:"
+
ex
.
ToString
());
}
return
value
;
}
private
static
void
SaveDIData
(
string
ioIp
,
ushort
ID
,
byte
[]
values
)
{
try
{
ushort
DILength
=
StoreManager
.
Config
.
GetDILength
(
ioIp
);
string
finalData
=
""
;
if
(
values
.
Length
==
2
&&
DILength
.
Equals
(
16
))
{
string
finalData0
=
Convert
.
ToString
(
values
[
0
],
2
).
PadLeft
(
8
,
'0'
);
string
finalData1
=
Convert
.
ToString
(
values
[
1
],
2
).
PadLeft
(
8
,
'0'
);
finalData
=
finalData1
+
finalData0
;
}
else
if
(
values
.
Length
==
1
&&
DILength
<=
8
)
{
finalData
=
Convert
.
ToString
(
values
[
0
],
2
).
PadLeft
(
DILength
,
'0'
);
}
LOGGER
.
Debug
(
"IO模块【"
+
ioIp
+
"】收到DI上传:【"
+
finalData
+
"】"
);
if
(
finalData
.
Length
>=
DILength
)
{
List
<
KNDIO
>
kndList
=
new
List
<
KNDIO
>();
ushort
index
=
(
ushort
)(
DIStartAddress
+
DILength
-
1
);
foreach
(
char
str
in
finalData
)
{
KNDIO
io
=
null
;
if
(
str
.
Equals
(
'1'
))
{
io
=
new
KNDIO
(
ioIp
,
(
byte
)
ID
,
index
,
IO_VALUE
.
HIGH
);
}
else
{
io
=
new
KNDIO
(
ioIp
,
(
byte
)
ID
,
index
,
IO_VALUE
.
LOW
);
}
kndList
.
Add
(
io
);
index
--;
}
lock
(
DIMapLock
)
{
if
(
DIValueMap
.
ContainsKey
(
ioIp
))
{
DIValueMap
.
Remove
(
ioIp
);
}
DIValueMap
.
Add
(
ioIp
,
kndList
);
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"SaveDIData出错:"
+
ex
.
ToString
());
//LOGGER.Error("处理接受数据出错:", ex);
}
}
private
static
void
SaveDOData
(
string
ioIp
,
ushort
ID
,
byte
[]
values
)
{
ushort
DoLength
=
StoreManager
.
Config
.
GetDOLength
(
ioIp
);
string
finalData
=
""
;
if
(
values
.
Length
==
2
&&
DoLength
.
Equals
(
16
))
{
string
finalData0
=
Convert
.
ToString
(
values
[
0
],
2
).
PadLeft
(
8
,
'0'
);
string
finalData1
=
Convert
.
ToString
(
values
[
1
],
2
).
PadLeft
(
8
,
'0'
);
finalData
=
finalData1
+
finalData0
;
}
else
if
(
values
.
Length
==
1
&&
DoLength
<=
8
)
{
finalData
=
Convert
.
ToString
(
values
[
0
],
2
).
PadLeft
(
DoLength
,
'0'
);
}
if
(
finalData
.
Length
>=
DoLength
)
{
List
<
KNDIO
>
kndList
=
new
List
<
KNDIO
>();
ushort
index
=
(
ushort
)(
DoStartAddress
+
DoLength
-
1
);
foreach
(
char
str
in
finalData
)
{
KNDIO
io
=
null
;
if
(
str
.
Equals
(
'1'
))
{
io
=
new
KNDIO
(
ioIp
,
(
byte
)
ID
,
index
,
IO_VALUE
.
HIGH
);
}
else
{
io
=
new
KNDIO
(
ioIp
,
(
byte
)
ID
,
index
,
IO_VALUE
.
LOW
);
}
kndList
.
Add
(
io
);
index
--;
}
lock
(
DOMapLock
)
{
if
(
DOValueMap
.
ContainsKey
(
ioIp
))
{
DOValueMap
.
Remove
(
ioIp
);
}
DOValueMap
.
Add
(
ioIp
,
kndList
);
}
}
}
// ------------------------------------------------------------------------
// Event for response data
// ------------------------------------------------------------------------
private
static
void
MBmaster_OnResponseData
(
string
ioIp
,
ushort
ID
,
byte
function
,
byte
[]
values
,
byte
[]
reviceData
)
{
try
{
if
(
ioIp
.
IndexOf
(
":"
)
>
0
)
{
ioIp
=
ioIp
.
Substring
(
0
,
ioIp
.
IndexOf
(
":"
));
}
string
reviceMsg
=
""
;
foreach
(
byte
data
in
reviceData
)
{
reviceMsg
=
reviceMsg
+
" "
+
data
;
if
(
reviceMsg
.
Length
>
200
)
{
break
;
}
}
if
(
ID
==
0xFF
)
{
return
;
}
// ------------------------------------------------------------------------
// Identify requested data
ushort
Func
=
ID
;
if
(
Func
==
0
&&
reviceData
.
Length
>
8
)
{
Func
=
reviceData
[
7
];
}
byte
SlaveId
=
0xFF
;
if
(
reviceData
.
Length
>=
7
)
{
SlaveId
=
reviceData
[
6
];
}
switch
(
Func
)
{
case
1
:
LOGGER
.
Info
(
"Read coils end:【"
+
reviceMsg
+
"】 "
);
SaveDOData
(
ioIp
,
SlaveId
,
values
);
break
;
case
2
:
//LOGGER.Info("Read discrete inputs end:【" + reviceMsg + "】 ");
SaveDIData
(
ioIp
,
SlaveId
,
values
);
break
;
case
3
:
//LOGGER.Info("读入(多个)寄存器完成 end:【" + reviceMsg + "】 ");
break
;
case
4
:
//LOGGER.Info("读入(多个)寄存器完成 end:【" + reviceMsg + "】 ");
break
;
case
5
:
//LOGGER.Info("Write single coil:【" + reviceMsg + "】 ");
break
;
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"处理接受数据出错:"
+
ex
.
ToString
());
//LOGGER.Error("处理接受数据出错:", ex);
}
}
// ------------------------------------------------------------------------
// Modbus TCP slave exception
// ------------------------------------------------------------------------
private
static
void
MBmaster_OnException
(
string
ioIp
,
ushort
id
,
byte
function
,
byte
exception
,
byte
[]
reviceData
)
{
string
exc
=
"Modbus says error: "
;
switch
(
exception
)
{
case
MasterTcpClient
.
excIllegalFunction
:
exc
+=
"Illegal function!"
;
break
;
case
MasterTcpClient
.
excIllegalDataAdr
:
exc
+=
"Illegal data adress!"
;
break
;
case
MasterTcpClient
.
excIllegalDataVal
:
exc
+=
"Illegal data value!"
;
break
;
case
MasterTcpClient
.
excSlaveDeviceFailure
:
exc
+=
"Slave device failure!"
;
break
;
case
MasterTcpClient
.
excAck
:
exc
+=
"Acknoledge!"
;
break
;
case
MasterTcpClient
.
excSlaveIsBusy
:
exc
+=
"Slave is busy!"
;
break
;
case
MasterTcpClient
.
excGatePathUnavailable
:
exc
+=
"Gateway path unavailbale!"
;
break
;
case
MasterTcpClient
.
excExceptionTimeout
:
exc
+=
"Slave timed out!"
;
break
;
case
MasterTcpClient
.
excExceptionConnectionLost
:
exc
+=
"Connection is lost!"
;
break
;
case
MasterTcpClient
.
excExceptionNotConnected
:
exc
+=
"Not connected!"
;
break
;
default
:
break
;
}
LOGGER
.
Error
(
"接收数据出错:"
+
exc
);
//MessageBox.Show(exc, "Modbus slave exception");
}
}
public
class
KNDIO
{
public
KNDIO
(
string
ioIp
,
byte
ID
,
ushort
index
,
IO_VALUE
o_VALUE
)
{
this
.
IoIP
=
ioIp
;
this
.
SlaveId
=
ID
;
this
.
IOAddress
=
index
;
this
.
IoValue
=
o_VALUE
;
UpdateTime
=
DateTime
.
Now
;
}
/// <summary>
/// IO模块IP
/// </summary>
public
string
IoIP
{
get
;
set
;
}
/// <summary>
/// 地址
/// </summary>
public
byte
SlaveId
{
get
;
set
;
}
/// <summary>
/// 寄存器地址
/// </summary>
public
ushort
IOAddress
{
get
;
set
;
}
/// <summary>
/// 值
/// </summary>
public
IO_VALUE
IoValue
{
get
;
set
;
}
/// <summary>
/// 更新时间
/// </summary>
public
DateTime
UpdateTime
{
get
;
set
;
}
}
}
source/DeviceLibrary/device/IO/KangNaiDe/MasterTcpClient.cs
deleted
100644 → 0
查看文件 @
4be5928
using
System
;
using
System.Collections
;
using
System.Text
;
using
System.IO
;
using
System.Net
;
using
System.Net.Sockets
;
using
System.Threading
;
using
System.Diagnostics
;
using
log4net
;
using
System.Reflection
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
namespace
OnlineStore.DeviceLibrary
{
public
class
MasterTcpClient
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
// ------------------------------------------------------------------------
// Constants for access
private
const
byte
fctReadCoil
=
1
;
private
const
byte
fctReadDiscreteInputs
=
2
;
private
const
byte
fctReadHoldingRegister
=
3
;
private
const
byte
fctReadInputRegister
=
4
;
private
const
byte
fctWriteSingleCoil
=
5
;
private
const
byte
fctWriteSingleRegister
=
6
;
private
const
byte
fctWriteMultipleCoils
=
15
;
private
const
byte
fctWriteMultipleRegister
=
16
;
private
const
byte
fctReadWriteMultipleRegister
=
23
;
/// <summary>Constant for exception illegal function.</summary>
public
const
byte
excIllegalFunction
=
1
;
/// <summary>Constant for exception illegal data address.</summary>
public
const
byte
excIllegalDataAdr
=
2
;
/// <summary>Constant for exception illegal data value.</summary>
public
const
byte
excIllegalDataVal
=
3
;
/// <summary>Constant for exception slave device failure.</summary>
public
const
byte
excSlaveDeviceFailure
=
4
;
/// <summary>Constant for exception acknowledge.</summary>
public
const
byte
excAck
=
5
;
/// <summary>Constant for exception slave is busy/booting up.</summary>
public
const
byte
excSlaveIsBusy
=
6
;
/// <summary>Constant for exception gate path unavailable.</summary>
public
const
byte
excGatePathUnavailable
=
10
;
/// <summary>Constant for exception not connected.</summary>
public
const
byte
excExceptionNotConnected
=
253
;
/// <summary>Constant for exception connection lost.</summary>
public
const
byte
excExceptionConnectionLost
=
254
;
/// <summary>Constant for exception response timeout.</summary>
public
const
byte
excExceptionTimeout
=
255
;
/// <summary>Constant for exception wrong offset.</summary>
private
const
byte
excExceptionOffset
=
128
;
/// <summary>Constant for exception send failt.</summary>
private
const
byte
excSendFailt
=
100
;
// ------------------------------------------------------------------------
// Private declarations
private
static
ushort
_timeout
=
500
;
private
static
ushort
_refresh
=
10
;
private
static
bool
_connected
=
false
;
private
static
bool
_autoConnectOfBreak
=
false
;
private
Socket
socketClient
;
private
int
M281_A_Len
=
0
;
private
byte
[]
tcpSocketReviceBuffer
=
new
byte
[
2048
];
//private Socket tcpSynCl;
//private byte[] tcpSynClBuffer = new byte[2048];
// ------------------------------------------------------------------------
/// <summary>Response data event. This event is called when new data arrives</summary>
public
delegate
void
ResponseData
(
string
ip
,
ushort
id
,
byte
function
,
byte
[]
data
,
byte
[]
reviceData
);
/// <summary>Response data event. This event is called when new data arrives</summary>
public
event
ResponseData
OnResponseData
;
/// <summary>Exception data event. This event is called when the data is incorrect</summary>
public
delegate
void
ExceptionData
(
string
ip
,
ushort
id
,
byte
function
,
byte
exception
,
byte
[]
reviceData
);
/// <summary>Exception data event. This event is called when the data is incorrect</summary>
public
event
ExceptionData
OnException
;
/// <summary>
/// autoConnectOfBreak
/// </summary>
public
bool
autoConnectOfBreak
{
get
{
return
_autoConnectOfBreak
;
}
set
{
_autoConnectOfBreak
=
value
;
}
}
public
static
ushort
timeout
{
get
{
return
_timeout
;
}
set
{
_timeout
=
value
;
}
}
public
ushort
refresh
{
get
{
return
_refresh
;
}
set
{
_refresh
=
value
;
}
}
public
bool
connected
{
get
{
return
_connected
;
}
}
public
MasterTcpClient
()
{
}
private
string
IP
=
""
;
public
int
TimeOutTime
=
0
;
public
MasterTcpClient
(
string
ip
,
ushort
port
)
{
this
.
IP
=
ip
;
TimeOutTime
=
2000
;
connect
(
ip
,
port
);
}
private
System
.
Timers
.
Timer
reviceTimer
=
new
System
.
Timers
.
Timer
();
public
void
connect
(
string
ip
,
ushort
port
)
{
try
{
// Connect asynchronous client
socketClient
=
new
Socket
(
IPAddress
.
Parse
(
ip
).
AddressFamily
,
SocketType
.
Stream
,
ProtocolType
.
Tcp
);
if
(
TimeOutTime
<=
0
)
{
socketClient
.
Connect
(
new
IPEndPoint
(
IPAddress
.
Parse
(
ip
),
port
));
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
SendTimeout
,
_timeout
);
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
ReceiveTimeout
,
_timeout
);
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
NoDelay
,
1
);
}
else
{
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
SendTimeout
,
_timeout
);
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
ReceiveTimeout
,
_timeout
);
socketClient
.
SetSocketOption
(
SocketOptionLevel
.
Socket
,
SocketOptionName
.
NoDelay
,
1
);
IAsyncResult
connResult
=
socketClient
.
BeginConnect
(
ip
,
port
,
null
,
null
);
connResult
.
AsyncWaitHandle
.
WaitOne
(
this
.
TimeOutTime
,
true
);
//等待2秒
if
(!
connResult
.
IsCompleted
)
{
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
ip
+
":"
+
port
+
" fail!"
);
return
;
}
else
{
_connected
=
true
;
}
}
//Thread threadReceive = new Thread(new ThreadStart(ReceiveHandle));
//threadReceive.Start();
reviceTimer
.
AutoReset
=
true
;
reviceTimer
.
Elapsed
+=
reviceTimer_Elapsed
;
reviceTimer
.
Interval
=
130
;
reviceTimer
.
Enabled
=
true
;
_connected
=
true
;
}
catch
(
System
.
IO
.
IOException
error
)
{
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
ip
+
":"
+
port
+
" fail!"
);
_connected
=
false
;
throw
(
error
);
}
}
void
reviceTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
try
{
//socketClient.BeginReceive(tcpSocketReviceBuffer, 0, tcpSocketReviceBuffer.Length, SocketFlags.None, new AsyncCallback(OnReceive), socketClient);
ReviceDataProcess
();
Thread
.
Sleep
(
10
);
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
"IO模块["
+
IP
+
"]出错:"
+
ex
.
ToString
());
}
}
private
void
ReviceDataProcess
()
{
int
lengthIndex
=
5
;
byte
[]
rdata
=
Receive
();
if
(
rdata
!=
null
)
{
string
str
=
""
;
foreach
(
byte
by
in
rdata
)
{
str
=
str
+
" "
+
by
;
if
(
str
.
Length
>
200
)
{
break
;
}
}
//这里rdata就是接收到的数据,
IPEndPoint
clientipe
=
(
IPEndPoint
)
socketClient
.
RemoteEndPoint
;
//ushort id = BitConverter.ToUInt16(rdata, 0);
//byte function = rdata[7];
byte
dataLength
=
rdata
[
lengthIndex
];
int
allLength
=
lengthIndex
+
1
+
dataLength
;
if
(
rdata
.
Length
>
allLength
)
{
//LogUtil.info(clientipe.ToString() + "收到数据(需要分包):" + str);
int
currStartIndex
=
0
;
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
try
{
if
(
rdata
.
Length
<
currStartIndex
+
lengthIndex
)
{
LogUtil
.
error
(
clientipe
.
ToString
()
+
"收到数据:"
+
str
+
"分包出错 ["
+
currStartIndex
+
"]"
);
}
dataLength
=
rdata
[
currStartIndex
+
lengthIndex
];
allLength
=
lengthIndex
+
1
+
dataLength
;
byte
[]
thisData
=
new
byte
[
allLength
];
Array
.
Copy
(
rdata
,
currStartIndex
,
thisData
,
0
,
allLength
);
ushort
id
=
BitConverter
.
ToUInt16
(
thisData
,
0
);
byte
function
=
thisData
[
7
];
DataProcess
(
clientipe
.
ToString
(),
id
,
function
,
thisData
);
//剩余的数据处理
if
(
rdata
.
Length
<=
currStartIndex
+
allLength
)
{
break
;
}
currStartIndex
=
currStartIndex
+
allLength
;
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
clientipe
.
ToString
()
+
"收到数据:"
+
str
+
"分包出错 ["
+
currStartIndex
+
"]:"
+
ex
.
ToString
());
}
}
}
else
{
LogUtil
.
debug
(
LOGGER
,
clientipe
.
ToString
()
+
"收到数据(无需分包):"
+
str
);
ushort
id
=
BitConverter
.
ToUInt16
(
rdata
,
0
);
byte
function
=
rdata
[
7
];
DataProcess
(
clientipe
.
ToString
(),
id
,
function
,
rdata
);
}
}
}
private
void
DataProcess
(
string
clientIp
,
ushort
id
,
byte
function
,
byte
[]
rdata
)
{
byte
[]
data
;
if
((
function
>=
fctWriteSingleCoil
)
&&
(
function
!=
fctReadWriteMultipleRegister
))
{
data
=
new
byte
[
2
];
Array
.
Copy
(
rdata
,
10
,
data
,
0
,
2
);
}
// ------------------------------------------------------------
// Read response data
else
{
data
=
new
byte
[
rdata
[
8
]];
Array
.
Copy
(
rdata
,
9
,
data
,
0
,
rdata
[
8
]);
}
// ------------------------------------------------------------
// Response data is slave exception
if
(
function
>
excExceptionOffset
)
{
function
-=
excExceptionOffset
;
CallException
(
id
,
function
,
rdata
[
8
],
rdata
);
}
// ------------------------------------------------------------
// Response data is regular data
else
if
(
OnResponseData
!=
null
)
{
//收到的数据打印出来
OnResponseData
(
clientIp
,
id
,
function
,
data
,
rdata
);
}
}
private
byte
[]
Receive
()
{
try
{
if
(
socketClient
==
null
||
!
socketClient
.
Connected
||
socketClient
.
Available
<
1
)
{
return
null
;
}
int
size
=
socketClient
.
Available
;
byte
[]
rData
=
new
byte
[
size
];
socketClient
.
Receive
(
rData
,
size
,
SocketFlags
.
None
);
return
rData
;
}
catch
(
SocketException
e
)
{
LogUtil
.
error
(
LOGGER
,
"IO模块["
+
IP
+
"]接收数据出现错误:"
+
e
.
ToString
());
if
(
socketClient
!=
null
)
{
socketClient
.
Close
();
socketClient
=
null
;
}
return
null
;
}
}
// ------------------------------------------------------------------------
/// <summary>Stop connection to slave.</summary>
public
void
disconnect
()
{
Dispose
();
}
// ------------------------------------------------------------------------
/// <summary>Destroy master instance.</summary>
~
MasterTcpClient
()
{
Dispose
();
}
// ------------------------------------------------------------------------
/// <summary>Destroy master instance</summary>
public
void
Dispose
()
{
reviceTimer
.
Enabled
=
false
;
if
(
socketClient
!=
null
)
{
if
(
socketClient
.
Connected
)
{
try
{
socketClient
.
Shutdown
(
SocketShutdown
.
Both
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"IO模块["
+
IP
+
"]dispose出错:"
+
ex
.
ToString
());
}
socketClient
.
Close
();
}
socketClient
=
null
;
}
}
internal
void
CallException
(
ushort
id
,
byte
function
,
byte
exception
,
byte
[]
rdata
)
{
reviceTimer
.
Enabled
=
false
;
if
((
socketClient
==
null
))
{
return
;
}
if
(
exception
==
excExceptionConnectionLost
)
{
//tcpSynCl = null;
socketClient
=
null
;
return
;
}
if
(
OnException
!=
null
)
{
OnException
(
socketClient
.
RemoteEndPoint
.
AddressFamily
.
ToString
(),
id
,
function
,
exception
,
rdata
);
}
}
public
void
ReadCoils
(
ushort
id
,
ushort
startAddress
,
ushort
numInputs
,
byte
SlaveID
)
{
WriteAsyncData
(
CreateReadHeader
(
id
,
startAddress
,
numInputs
,
fctReadCoil
,
SlaveID
),
id
);
}
public
void
ReadDiscreteInputs
(
ushort
id
,
ushort
startAddress
,
ushort
numInputs
,
byte
SlaveID
)
{
WriteAsyncData
(
CreateReadHeader
(
id
,
startAddress
,
numInputs
,
fctReadDiscreteInputs
,
SlaveID
),
id
);
}
public
void
ReadHoldingRegister
(
ushort
id
,
ushort
startAddress
,
ushort
numInputs
,
byte
SlaveID
)
{
WriteAsyncData
(
CreateReadHeader
(
id
,
startAddress
,
numInputs
,
fctReadHoldingRegister
,
SlaveID
),
id
);
}
public
void
ReadInputRegister
(
ushort
id
,
ushort
startAddress
,
ushort
numInputs
,
byte
SlaveID
)
{
WriteAsyncData
(
CreateReadHeader
(
id
,
startAddress
,
numInputs
,
fctReadInputRegister
,
SlaveID
),
id
);
}
public
void
WriteSingleCoils
(
ushort
id
,
ushort
startAddress
,
IO_VALUE
ioValue
,
byte
SlaveID
)
{
byte
[]
data
;
bool
OnOff
=
ioValue
.
Equals
(
IO_VALUE
.
HIGH
);
data
=
CreateWriteHeader
(
id
,
startAddress
,
1
,
1
,
fctWriteSingleCoil
,
SlaveID
);
if
(
OnOff
==
true
)
data
[
10
]
=
255
;
else
data
[
10
]
=
0
;
WriteAsyncData
(
data
,
id
);
}
public
void
WriteMultipleCoils
(
ushort
id
,
ushort
startAddress
,
ushort
numBits
,
byte
[]
values
,
byte
SlaveID
)
{
byte
numBytes
=
Convert
.
ToByte
(
values
.
Length
);
byte
[]
data
;
data
=
CreateWriteHeader
(
id
,
startAddress
,
numBits
,
(
byte
)(
numBytes
+
2
),
fctWriteMultipleCoils
,
SlaveID
);
Array
.
Copy
(
values
,
0
,
data
,
13
,
numBytes
);
WriteAsyncData
(
data
,
id
);
}
public
void
WriteSingleRegister
(
ushort
id
,
ushort
startAddress
,
byte
[]
values
,
byte
SlaveID
)
{
byte
[]
data
;
data
=
CreateWriteHeader
(
id
,
startAddress
,
1
,
1
,
fctWriteSingleRegister
,
SlaveID
);
data
[
10
]
=
values
[
0
];
data
[
11
]
=
values
[
1
];
WriteAsyncData
(
data
,
id
);
}
public
void
WriteMultipleRegister
(
ushort
id
,
ushort
startAddress
,
byte
[]
values
,
byte
SlaveID
)
{
ushort
numBytes
=
Convert
.
ToUInt16
(
values
.
Length
);
if
(
numBytes
%
2
>
0
)
numBytes
++;
byte
[]
data
;
data
=
CreateWriteHeader
(
id
,
startAddress
,
Convert
.
ToUInt16
(
numBytes
/
2
),
Convert
.
ToUInt16
(
numBytes
+
2
),
fctWriteMultipleRegister
,
SlaveID
);
Array
.
Copy
(
values
,
0
,
data
,
13
,
values
.
Length
);
WriteAsyncData
(
data
,
id
);
}
public
void
ReadWriteMultipleRegister
(
ushort
id
,
ushort
startReadAddress
,
ushort
numInputs
,
ushort
startWriteAddress
,
byte
SlaveID
,
byte
[]
values
)
{
ushort
numBytes
=
Convert
.
ToUInt16
(
values
.
Length
);
if
(
numBytes
%
2
>
0
)
numBytes
++;
byte
[]
data
;
data
=
CreateReadWriteHeader
(
id
,
startReadAddress
,
numInputs
,
startWriteAddress
,
Convert
.
ToUInt16
(
numBytes
/
2
),
SlaveID
);
Array
.
Copy
(
values
,
0
,
data
,
17
,
values
.
Length
);
WriteAsyncData
(
data
,
id
);
}
// ------------------------------------------------------------------------
// Create modbus header for read action
private
byte
[]
CreateReadHeader
(
ushort
id
,
ushort
startAddress
,
ushort
length
,
byte
function
,
byte
SlaveID
)
{
byte
[]
data
=
new
byte
[
12
];
byte
[]
_id
=
BitConverter
.
GetBytes
((
short
)
id
);
data
[
0
]
=
_id
[
0
];
// Slave id high byte
data
[
1
]
=
_id
[
1
];
// Slave id low byte
data
[
5
]
=
6
;
// Message size
data
[
6
]
=
SlaveID
;
// Slave address //必须设置为"1": 2012.04-24 覃发光;
data
[
7
]
=
function
;
// Function code
byte
[]
_adr
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
startAddress
));
data
[
8
]
=
_adr
[
0
];
// Start address
data
[
9
]
=
_adr
[
1
];
// Start address
byte
[]
_length
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
length
));
data
[
10
]
=
_length
[
0
];
// Number of data to read
data
[
11
]
=
_length
[
1
];
// Number of data to read
return
data
;
}
// ------------------------------------------------------------------------
// Create modbus header for write action
private
byte
[]
CreateWriteHeader
(
ushort
id
,
ushort
startAddress
,
ushort
numData
,
ushort
numBytes
,
byte
function
,
byte
SlaveID
)
{
byte
[]
data
=
new
byte
[
numBytes
+
11
];
byte
[]
_id
=
BitConverter
.
GetBytes
((
short
)
id
);
data
[
0
]
=
_id
[
0
];
// Slave id high byte
data
[
1
]
=
_id
[
1
];
// Slave id low byte+
byte
[]
_size
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)(
5
+
numBytes
)));
data
[
4
]
=
_size
[
0
];
// Complete message size in bytes
data
[
5
]
=
_size
[
1
];
// Complete message size in bytes
data
[
6
]
=
SlaveID
;
// Slave address //必须设置为"1": 2012.04-24 覃发光;
data
[
7
]
=
function
;
// Function code
byte
[]
_adr
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
startAddress
));
data
[
8
]
=
_adr
[
0
];
// Start address
data
[
9
]
=
_adr
[
1
];
// Start address
if
(
function
>=
fctWriteMultipleCoils
)
{
byte
[]
_cnt
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
numData
));
data
[
10
]
=
_cnt
[
0
];
// Number of bytes
data
[
11
]
=
_cnt
[
1
];
// Number of bytes
data
[
12
]
=
(
byte
)(
numBytes
-
2
);
}
return
data
;
}
// ------------------------------------------------------------------------
// Create modbus header for write action
private
byte
[]
CreateReadWriteHeader
(
ushort
id
,
ushort
startReadAddress
,
ushort
numRead
,
ushort
startWriteAddress
,
ushort
numWrite
,
byte
SlaveID
)
{
byte
[]
data
=
new
byte
[
numWrite
*
2
+
17
];
byte
[]
_id
=
BitConverter
.
GetBytes
((
short
)
id
);
data
[
0
]
=
_id
[
0
];
// Slave id high byte
data
[
1
]
=
_id
[
1
];
// Slave id low byte+
byte
[]
_size
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)(
11
+
numWrite
*
2
)));
data
[
4
]
=
_size
[
0
];
// Complete message size in bytes
data
[
5
]
=
_size
[
1
];
// Complete message size in bytes
data
[
6
]
=
SlaveID
;
// Slave address //必须设置为"1": 2012.04-24 覃发光;
data
[
7
]
=
fctReadWriteMultipleRegister
;
// Function code
byte
[]
_adr_read
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
startReadAddress
));
data
[
8
]
=
_adr_read
[
0
];
// Start read address
data
[
9
]
=
_adr_read
[
1
];
// Start read address
byte
[]
_cnt_read
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
numRead
));
data
[
10
]
=
_cnt_read
[
0
];
// Number of bytes to read
data
[
11
]
=
_cnt_read
[
1
];
// Number of bytes to read
byte
[]
_adr_write
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
startWriteAddress
));
data
[
12
]
=
_adr_write
[
0
];
// Start write address
data
[
13
]
=
_adr_write
[
1
];
// Start write address
byte
[]
_cnt_write
=
BitConverter
.
GetBytes
((
short
)
IPAddress
.
HostToNetworkOrder
((
short
)
numWrite
));
data
[
14
]
=
_cnt_write
[
0
];
// Number of bytes to write
data
[
15
]
=
_cnt_write
[
1
];
// Number of bytes to write
data
[
16
]
=
(
byte
)(
numWrite
*
2
);
return
data
;
}
// ------------------------------------------------------------------------
// Write asynchronous data
private
void
WriteAsyncData
(
byte
[]
write_data
,
ushort
id
)
{
if
(
socketClient
==
null
)
{
LOGGER
.
Error
(
"发送数据时发现socketClient=null"
);
return
;
}
IPEndPoint
clientipe
=
(
IPEndPoint
)
socketClient
.
RemoteEndPoint
;
if
((
socketClient
!=
null
)
&&
(
socketClient
.
Connected
))
{
try
{
//发送的数据打印出来
string
str
=
""
;
foreach
(
byte
by
in
write_data
)
{
str
=
str
+
" "
+
by
;
}
//LogUtil.info( clientipe.ToString()+"发送数据:" + str);
socketClient
.
BeginSend
(
write_data
,
0
,
write_data
.
Length
,
SocketFlags
.
None
,
new
AsyncCallback
(
OnSend
),
null
);
//socketClient.BeginReceive(tcpSocketReviceBuffer, 0, tcpSocketReviceBuffer.Length, SocketFlags.None, new AsyncCallback(OnReceive), socketClient);
ReviceDataProcess
();
}
catch
(
SystemException
error
)
{
LogUtil
.
error
(
LOGGER
,
"IO模块 WriteAsyncData出错:"
+
error
.
ToString
());
CallException
(
id
,
write_data
[
7
],
excExceptionConnectionLost
,
tcpSocketReviceBuffer
);
}
}
else
CallException
(
id
,
write_data
[
7
],
excExceptionConnectionLost
,
tcpSocketReviceBuffer
);
}
// ------------------------------------------------------------------------
// Write asynchronous data acknowledge
private
void
OnSend
(
System
.
IAsyncResult
result
)
{
if
(
result
.
IsCompleted
==
false
)
CallException
(
0xFFFF
,
0xFF
,
excSendFailt
,
tcpSocketReviceBuffer
);
}
// ------------------------------------------------------------------------
// Write asynchronous data response
private
void
OnReceive
(
System
.
IAsyncResult
result
)
{
if
(
socketClient
==
null
)
{
return
;
}
IPEndPoint
clientipe
=
(
IPEndPoint
)
socketClient
.
RemoteEndPoint
;
if
(
result
.
IsCompleted
==
false
)
{
CallException
(
0xFF
,
0xFF
,
excExceptionConnectionLost
,
tcpSocketReviceBuffer
);
}
ushort
id
=
BitConverter
.
ToUInt16
(
tcpSocketReviceBuffer
,
0
);
;
byte
function
=
tcpSocketReviceBuffer
[
7
];
byte
[]
data
;
// ------------------------------------------------------------
// Write response data
if
((
function
>=
fctWriteSingleCoil
)
&&
(
function
!=
fctReadWriteMultipleRegister
))
{
data
=
new
byte
[
2
];
Array
.
Copy
(
tcpSocketReviceBuffer
,
10
,
data
,
0
,
2
);
}
// ------------------------------------------------------------
// Read response data
else
{
data
=
new
byte
[
tcpSocketReviceBuffer
[
8
]];
Array
.
Copy
(
tcpSocketReviceBuffer
,
9
,
data
,
0
,
tcpSocketReviceBuffer
[
8
]);
}
// ------------------------------------------------------------
// Response data is slave exception
if
(
function
>
excExceptionOffset
)
{
function
-=
excExceptionOffset
;
CallException
(
id
,
function
,
tcpSocketReviceBuffer
[
8
],
tcpSocketReviceBuffer
);
}
// ------------------------------------------------------------
// Response data is regular data
else
if
(
OnResponseData
!=
null
)
{
//收到的数据打印出来
string
str
=
""
;
foreach
(
byte
by
in
tcpSocketReviceBuffer
)
{
str
=
str
+
" "
+
by
;
if
(
str
.
Length
>
50
)
{
break
;
}
}
// LogUtil.info( clientipe.ToString()+"收到数据:" + str);
OnResponseData
(
clientipe
.
ToString
(),
id
,
function
,
data
,
tcpSocketReviceBuffer
);
}
}
internal
bool
ISConnection
()
{
if
(
socketClient
==
null
)
{
return
false
;
}
if
(
socketClient
.
Connected
==
false
)
{
return
false
;
}
return
true
;
}
}
}
source/DeviceLibrary/device/led/BaseLedManager.cs
查看文件 @
e178b7d
...
...
@@ -135,21 +135,8 @@ namespace OnlineStore.DeviceLibrary
public
string
ModuleIP
=
""
;
public
static
LEDBaseModule
GetModule
(
string
ip
)
{
//if (LEDManager.DeviceLedType.Equals(1))
//{
// LEDColorModule module = new LEDColorModule(ip);
// return module;
//}
//else if (LEDManager.DeviceLedType.Equals(2))
//{
LEDColorArtNet
module
=
new
LEDColorArtNet
(
ip
);
return
module
;
//}
//else
//{
// LEDSingleModule module = new LEDSingleModule(ip);
// return module;
//}
}
internal
LEDBaseModule
(
string
ip
)
...
...
source/DeviceLibrary/store/InOutParam.cs
查看文件 @
e178b7d
...
...
@@ -13,22 +13,12 @@ namespace OnlineStore.DeviceLibrary
{
position
=
null
;
PosCode
=
code
;
PosId
=
posId
;
MoveP
=
null
;
PosId
=
posId
;
this
.
PlateW
=
plateW
;
this
.
PlateH
=
plateH
;
this
.
paramType
=
type
;
}
public
InOutParam
(
MoveType
paramType
,
string
posId
,
StoreMoveP
linePosition
,
string
wareNo
=
""
)
{
position
=
null
;
PosCode
=
wareNo
;
PosId
=
posId
;
MoveP
=
linePosition
;
this
.
paramType
=
paramType
;
}
public
string
ToStr
()
{
if
(
paramType
.
Equals
(
MoveType
.
InStore
))
...
...
@@ -63,10 +53,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 位置坐标名(对应配置表的位置)
/// </summary>
public
string
PosId
=
""
;
public
StoreMoveP
MoveP
{
get
;
set
;
}
public
string
PosId
=
""
;
/// <summary>
/// 料盘高度
/// </summary>
...
...
@@ -76,29 +63,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public
int
PlateW
=
0
;
internal
bool
LoadParam
(
VerticalStoreConfig
Config
)
{
//加载位置
if
(
MoveP
==
null
)
{
StoreMoveP
p
=
new
StoreMoveP
();
VerticalPosition
position
=
Position
;
if
(
position
==
null
)
{
LogUtil
.
error
(
"出入库时发现param中取到的Position=null,没有库位不能执行出入库"
);
return
false
;
}
p
.
Middle_P2
=
position
.
MiddleAxis_P2
;
this
.
MoveP
=
p
;
return
true
;
}
return
true
;
}
public
string
LogName
{
get
...
...
@@ -120,73 +85,6 @@ namespace OnlineStore.DeviceLibrary
}
}
public
class
StirInfo
{
public
StirInfo
()
{
InStirWork
=
false
;
StartTime
=
DateTime
.
Now
;
StopTime
=
DateTime
.
Now
;
StirParam
=
new
InOutParam
(
MoveType
.
None
,
""
,
""
);
}
/// <summary>
/// 是否在搅拌中
/// </summary>
public
bool
InStirWork
=
false
;
/// <summary>
/// 搅拌区状态:1=物料1已放入,2=物料2已放入,3=搅拌中,4=搅拌完成,等待取出物料,5=物料1已取出,6=物料2已取出,7=全部完成
/// </summary>
public
int
MoveStatus
=
0
;
/// <summary>
/// 开始搅拌信息
/// </summary>
public
DateTime
StartTime
=
DateTime
.
Now
;
/// <summary>
/// 需要停止搅拌的时间
/// </summary>
public
DateTime
StopTime
=
DateTime
.
Now
;
/// <summary>
/// 搅拌参数
/// </summary>
public
InOutParam
StirParam
=
null
;
public
string
toStr
()
{
if
(
MoveStatus
.
Equals
(
0
))
{
return
"暂无搅拌信息"
;
}
string
str
=
"等待物料放入搅拌区"
;
if
(
MoveStatus
.
Equals
(
1
))
{
str
=
"物料1已放入"
;
}
else
if
(
MoveStatus
.
Equals
(
2
))
{
str
=
"物料2已放入"
;
}
else
if
(
MoveStatus
.
Equals
(
3
))
{
str
=
"搅拌中,结束时间:"
+
StopTime
.
ToLongTimeString
();
}
else
if
(
MoveStatus
.
Equals
(
4
))
{
str
=
"搅拌完成,等待物料回库 "
;
}
else
if
(
MoveStatus
.
Equals
(
5
))
{
str
=
"物料1已回库"
;
}
else
if
(
MoveStatus
.
Equals
(
6
))
{
str
=
"物料2已回库"
;
}
return
"["
+
str
+
"]"
+
StirParam
.
ToStr
();
}
}
}
source/DeviceLibrary/store/KTK_DeviceBase.cs
deleted
100644 → 0
查看文件 @
4be5928
using
log4net
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
namespace
OnlineStore.DeviceLibrary
{
public
abstract
class
KTK_DeviceBase
{
/// <summary>
/// 料仓单个调试状态(默认不是调试状态)
/// </summary>
public
bool
IsDebug
=
false
;
/// <summary>
///1=设备联机(正常就绪)(入库后,BOX恢复原始状态)(出库后,移载装置恢复原始状态),
///2=急停,3=故障,4=警告,5=调试
/// 6=入库执行中,7=入仓完成,8=入仓失败
/// 9=出库执行,10=出仓完成,11=出库失败
/// </summary>
public
StoreStatus
storeStatus
=
StoreStatus
.
ResetMove
;
/// <summary>
/// 提示消息,一般发给服务器后清空(LineBean表示报警提示消息,BoxBean表示出入库失败的原因记录)
/// </summary>
public
string
WarnMsg
=
""
;
/// <summary>
/// 日志颜色
/// </summary>
protected
static
Color
storeMoveColor
=
Color
.
Blue
;
public
string
Name
=
""
;
public
int
StoreID
=
0
;
/// <summary>
/// 料仓状态
/// </summary>
private
StoreRunStatus
storerunstatus
=
StoreRunStatus
.
Wait
;
/// <summary>
/// 定时器
/// </summary>
protected
System
.
Timers
.
Timer
mainTimer
;
private
bool
isInit
=
false
;
/// <summary>
/// 初始化
/// </summary>
protected
virtual
void
Init
()
{
if
(!
isInit
)
{
MoveInfo
=
new
StoreMoveInfo
(
StoreID
);
mainTimer
=
new
System
.
Timers
.
Timer
();
mainTimer
.
Enabled
=
false
;
mainTimer
.
Interval
=
300
;
mainTimer
.
Elapsed
+=
timersTimer_Elapsed
;
mainTimer
.
AutoReset
=
true
;
isInit
=
true
;
}
}
public
StoreRunStatus
runStatus
{
get
{
return
storerunstatus
;
}
set
{
StoreRunStatus
oldStatus
=
storerunstatus
;
storerunstatus
=
value
;
}
}
/// <summary>
/// 移动信息
/// </summary>
public
StoreMoveInfo
MoveInfo
=
null
;
/// <summary>
/// 定时处理,监听信号,监听IO
/// </summary>
protected
abstract
void
timersTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
);
#
region
出库
/// <summary>
/// 开始出库运动
/// </summary>
public
abstract
bool
StartOutStore
(
InOutParam
param
);
protected
abstract
void
OutStoreProcess
();
#
endregion
#
region
入库
/// <summary>
/// 开始入库移动移动
/// </summary>
public
abstract
bool
StartInStore
(
InOutParam
param
,
bool
isNeedCheckIO
=
false
);
protected
abstract
void
InStoreProcess
();
#
endregion
public
string
GetRunStr
()
{
string
sta
=
"运行中"
;
string
aa
=
""
;
switch
(
runStatus
)
{
case
StoreRunStatus
.
Busy
:
sta
=
"忙碌"
;
break
;
case
StoreRunStatus
.
HomeMoving
:
sta
=
"原点返回"
;
break
;
case
StoreRunStatus
.
Reset
:
sta
=
"重置"
;
break
;
case
StoreRunStatus
.
Runing
:
sta
=
"运行中"
;
break
;
case
StoreRunStatus
.
Wait
:
sta
=
"等待启动"
;
break
;
}
if
(
runStatus
>
StoreRunStatus
.
Wait
)
{
//"0":"急停中", "1":"设备联机", "2":"故障中", "3":"入库执行中", "4":"出库执行中", 5":"料盘入仓位完成", "6":"料盘出仓位完成", 7":"设备调试中",
switch
(
storeStatus
)
{
case
StoreStatus
.
Debugging
:
aa
=
"设备调试中"
;
break
;
case
StoreStatus
.
InStoreEnd
:
aa
=
"料盘入仓位完成"
;
break
;
case
StoreStatus
.
InStoreExecute
:
aa
=
"入库执行中"
;
break
;
case
StoreStatus
.
InTrouble
:
aa
=
"故障中"
;
break
;
case
StoreStatus
.
OutStoreBoxEnd
:
aa
=
"料盘出仓位完成"
;
break
;
case
StoreStatus
.
OutStoreExecute
:
aa
=
"出库执行中"
;
break
;
case
StoreStatus
.
StoreOnline
:
aa
=
"设备联机"
;
break
;
case
StoreStatus
.
SuddenStop
:
aa
=
"急停中"
;
break
;
case
StoreStatus
.
OutMoveExecute
:
aa
=
"出库完成"
;
break
;
case
StoreStatus
.
InStoreFaild
:
aa
=
"入库失败("
+
WarnMsg
+
")"
;
break
;
case
StoreStatus
.
OutStoreFaild
:
aa
=
"出库失败("
+
WarnMsg
+
")"
;
break
;
}
if
(!
aa
.
Equals
(
""
))
{
return
sta
+
"_"
+
aa
;
}
else
{
return
sta
;
}
}
else
{
return
sta
;
}
}
}
}
source/DeviceLibrary/store/KTK_Store.cs
查看文件 @
e178b7d
...
...
@@ -15,51 +15,42 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 康泰克单台自动料仓
/// </summary>
public
abstract
class
KTK_Store
:
KTK_DeviceBase
public
abstract
class
DeviceBase
{
public
KTK_Stor
e
()
public
DeviceBas
e
()
{
}
/// <summary>
/// 开始运行的时间
/// </summary>
public
DateTime
StartTime
{
get
;
set
;
}
public
DateTime
statusTime
=
DateTime
.
Now
;
public
StoreMoveInfo
MoveInfo
=
null
;
public
string
lastPosId
=
""
;
public
StoreStatus
lastPosIdStatus
=
StoreStatus
.
StoreOnline
;
public
List
<
ConfigMoveAxis
>
moveAxisList
=
new
List
<
ConfigMoveAxis
>();
protected
Dictionary
<
string
,
AxisAlarmInfo
>
AxisAlarmCodeMap
=
new
Dictionary
<
string
,
AxisAlarmInfo
>();
/// <summary>
/// 最后一次气压检测变为0的时间
/// </summary>
protected
DateTime
lastAirCloseTime
=
DateTime
.
Now
;
/// <summary>
/// 是否在急停中
/// </summary>
public
bool
isInSuddenDown
=
false
;
/// <summary>
/// 是否没有检测到气压
/// </summary>
public
bool
isNoAirCheck
=
false
;
public
List
<
ConfigMoveAxis
>
moveAxisList
=
new
List
<
ConfigMoveAxis
>();
protected
Dictionary
<
string
,
AxisAlarmInfo
>
AxisAlarmCodeMap
=
new
Dictionary
<
string
,
AxisAlarmInfo
>();
public
bool
isInSuddenDown
=
false
;
protected
int
NeedCheckSafetyLight
=
0
;
public
StoreAlarmType
alarmType
=
StoreAlarmType
.
None
;
protected
AlarmInfo
alarmInfo
=
new
AlarmInfo
();
public
Dictionary
<
string
,
IO_VALUE
>
DILastValueMap
=
new
Dictionary
<
string
,
IO_VALUE
>();
public
bool
IsDebug
=
false
;
protected
int
NeedCheckSafetyLight
=
0
;
/// <summary>
/// 是否再报警中
///1=设备联机(正常就绪)(入库后,BOX恢复原始状态)(出库后,移载装置恢复原始状态),
///2=急停,3=故障,4=警告,5=调试
/// 6=入库执行中,7=入仓完成,8=入仓失败
/// 9=出库执行,10=出仓完成,11=出库失败
/// </summary>
public
StoreAlarmType
alarmType
=
StoreAlarmType
.
None
;
public
StoreStatus
storeStatus
=
StoreStatus
.
ResetMove
;
public
string
WarnMsg
=
""
;
protected
AlarmInfo
alarmInfo
=
new
AlarmInfo
();
/// <summary>
/// 记录上一次的部分IO状态,主要是急停,气压检测信号,复位信号,用来判断是否io发生改变
/// </summary>
public
Dictionary
<
string
,
IO_VALUE
>
DILastValueMap
=
new
Dictionary
<
string
,
IO_VALUE
>();
public
string
Name
=
""
;
public
int
StoreID
=
0
;
public
StoreRunStatus
runStatus
=
StoreRunStatus
.
Wait
;
protected
System
.
Timers
.
Timer
mainTimer
;
private
bool
isInit
=
false
;
public
object
lastDiListLock
=
""
;
public
void
addLastDI
(
string
type
,
IO_VALUE
value
)
{
...
...
@@ -80,35 +71,13 @@ namespace OnlineStore.DeviceLibrary
LogUtil
.
error
(
ex
.
ToString
());
}
}
/// <summary>
/// 获取料仓运行的时间
/// </summary>
/// <returns></returns>
public
TimeSpan
GetStoreRunTime
()
{
if
(
StartTime
!=
null
)
{
return
DateTime
.
Now
-
StartTime
;
}
else
{
return
new
TimeSpan
(
0
);
}
}
/// <summary>
/// 运动处理
/// </summary>
protected
bool
isInPro
=
false
;
protected
virtual
void
BusyMoveProcess
()
{
//if (isInPro)
//{
// return;
//}
{
isInPro
=
true
;
try
{
...
...
@@ -206,103 +175,122 @@ namespace OnlineStore.DeviceLibrary
/// 重置处理
/// </summary>
protected
abstract
void
ResetProcess
();
/// <summary>
///
松下伺服轴原点返回运动,等待收到反馈后才会返回
/// </summary>
protected
v
oid
ACAxisHomeMove
(
ConfigMoveAxis
moveAxis
)
///
初始化
/// </summary>
protected
v
irtual
void
Init
(
)
{
moveAxis
.
TargetPosition
=
0
;
LogUtil
.
info
(
moveAxis
.
DisplayStr
+
"speed["
+
moveAxis
.
TargetSpeed
+
"]开始原点返回"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitAxis
(
moveAxis
,
true
));
ACServerManager
.
HomeMove
(
moveAxis
.
DeviceName
,
(
short
)
moveAxis
.
GetAxisValue
(),
moveAxis
.
HomeHighSpeed
);
if
(!
isInit
)
{
MoveInfo
=
new
StoreMoveInfo
(
StoreID
);
mainTimer
=
new
System
.
Timers
.
Timer
();
mainTimer
.
Enabled
=
false
;
mainTimer
.
Interval
=
300
;
mainTimer
.
Elapsed
+=
timersTimer_Elapsed
;
mainTimer
.
AutoReset
=
true
;
isInit
=
true
;
}
}
protected
abstract
void
timersTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
);
#
region
出库
/// <summary>
///
松下伺服电机
运动
///
开始出库
运动
/// </summary>
protected
void
ACAxisMove
(
ConfigMoveAxis
moveAxis
,
int
targetPosition
,
int
targetSpeed
)
{
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitAxis
(
moveAxis
,
targetPosition
,
targetSpeed
));
moveAxis
.
TargetPosition
=
targetPosition
;
ACServerManager
.
AbsMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
targetPosition
,
targetSpeed
);
}
public
abstract
bool
StartOutStore
(
InOutParam
param
);
protected
abstract
void
OutStoreProcess
();
#
endregion
#
region
入库
/// <summary>
///
判断AC伺服电机轴是否运动完成
///
开始入库移动移动
/// </summary>
p
rotected
bool
ACAxisMoveIsEnd
(
ConfigMoveAxis
moveAxis
,
int
targetPosition
,
int
targetSpeed
,
out
string
msg
)
{
msg
=
""
;
string
deviceName
=
moveAxis
.
DeviceName
;
short
axisNo
=
moveAxis
.
GetAxisValue
();
p
ublic
abstract
bool
StartInStore
(
InOutParam
param
,
bool
isNeedCheckIO
=
false
);
protected
abstract
void
InStoreProcess
();
#
endregion
//如果是进出轴,并且光栅被遮挡,直接返回false
if
(
NeedCheckSafetyLight
.
Equals
(
2
))
public
string
GetRunStr
()
{
string
sta
=
"运行中"
;
string
aa
=
""
;
switch
(
runStatus
)
{
if
(
MoveInfo
.
IsStep
(
StoreMoveStep
.
SO_13_InoutToP2
)
||
MoveInfo
.
IsStep
(
StoreMoveStep
.
SI_05_InoutToP2
))
{
return
false
;
}
case
StoreRunStatus
.
Busy
:
sta
=
"忙碌"
;
break
;
case
StoreRunStatus
.
HomeMoving
:
sta
=
"原点返回"
;
break
;
case
StoreRunStatus
.
Reset
:
sta
=
"重置"
;
break
;
case
StoreRunStatus
.
Runing
:
sta
=
"运行中"
;
break
;
case
StoreRunStatus
.
Wait
:
sta
=
"等待启动"
;
break
;
}
bool
isOk
=
ACServerManager
.
GetBusyStatus
(
deviceName
,
axisNo
).
Equals
(
0
);
int
outCount
=
ACServerManager
.
GetActualtPosition
(
deviceName
,
axisNo
);
int
errorCount
=
Math
.
Abs
(
outCount
-
targetPosition
);
if
(
isOk
)
{
if
(
errorCount
<=
moveAxis
.
CanErrorCountMax
)
if
(
runStatus
>
StoreRunStatus
.
Wait
)
{
//"0":"急停中", "1":"设备联机", "2":"故障中", "3":"入库执行中", "4":"出库执行中", 5":"料盘入仓位完成", "6":"料盘出仓位完成", 7":"设备调试中",
switch
(
storeStatus
)
{
return
true
;
case
StoreStatus
.
Debugging
:
aa
=
"设备调试中"
;
break
;
case
StoreStatus
.
InStoreEnd
:
aa
=
"料盘入仓位完成"
;
break
;
case
StoreStatus
.
InStoreExecute
:
aa
=
"入库执行中"
;
break
;
case
StoreStatus
.
InTrouble
:
aa
=
"故障中"
;
break
;
case
StoreStatus
.
OutStoreBoxEnd
:
aa
=
"料盘出仓位完成"
;
break
;
case
StoreStatus
.
OutStoreExecute
:
aa
=
"出库执行中"
;
break
;
case
StoreStatus
.
StoreOnline
:
aa
=
"设备联机"
;
break
;
case
StoreStatus
.
SuddenStop
:
aa
=
"急停中"
;
break
;
case
StoreStatus
.
OutMoveExecute
:
aa
=
"出库完成"
;
break
;
case
StoreStatus
.
InStoreFaild
:
aa
=
"入库失败("
+
WarnMsg
+
")"
;
break
;
case
StoreStatus
.
OutStoreFaild
:
aa
=
"出库失败("
+
WarnMsg
+
")"
;
break
;
}
//判断是否需要重新运动
if
(
MoveInfo
.
CanWhileCount
>
0
)
if
(!
aa
.
Equals
(
""
))
{
LogUtil
.
error
(
moveAxis
.
DisplayStr
+
"目标位置["
+
targetPosition
+
"]当前位置["
+
outCount
+
"],误差过大,重新开始运动,剩余["
+
MoveInfo
.
CanWhileCount
+
"]次"
);
ACServerManager
.
AbsMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
targetPosition
,
targetSpeed
);
MoveInfo
.
CanWhileCount
--;
return
sta
+
"_"
+
aa
;
}
else
{
msg
=
Name
+
" storeMoveStep="
+
MoveInfo
.
MoveStep
+
moveAxis
.
DisplayStr
+
"目标位置["
+
targetPosition
+
"]当前位置["
+
outCount
+
"],误差过大,需要报警"
;
LogUtil
.
error
(
msg
);
return
sta
;
}
}
return
false
;
}
protected
bool
ACHomeMoveIsEnd
(
ConfigMoveAxis
moveAxis
,
out
string
msg
)
{
msg
=
""
;
if
(
ACServerManager
.
IsHomeMoveEnd
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
()))
else
{
//原点完成并且位置=0
int
outCount
=
ACServerManager
.
GetActualtPosition
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
());
int
errorCount
=
Math
.
Abs
(
outCount
);
if
(
errorCount
<=
moveAxis
.
CanErrorCountMax
)
{
return
true
;
}
//判断是否需要重新运动
if
(
MoveInfo
.
CanWhileCount
>
0
)
{
LogUtil
.
error
(
moveAxis
.
DisplayStr
+
"收到原点完成信号,当前位置["
+
outCount
+
"],重新回原点,剩余["
+
MoveInfo
.
CanWhileCount
+
"]次"
);
//LogUtil.error(LOGGER, StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager
.
HomeMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
moveAxis
.
HomeHighSpeed
);
MoveInfo
.
CanWhileCount
--;
}
else
{
msg
=
Name
+
" storeMoveStep="
+
MoveInfo
.
MoveStep
+
moveAxis
.
DisplayStr
+
"收到原点完成信号,当前位置["
+
outCount
+
"],误差过大,需要报警"
;
LogUtil
.
error
(
msg
);
}
return
sta
;
}
return
false
;
}
}
}
}
source/DeviceLibrary/store/StoreMoveP.cs
deleted
100644 → 0
查看文件 @
4be5928
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
OnlineStore.DeviceLibrary
{
public
class
StoreMoveP
{
/// <summary>
/// 轴1旋转轴 库位点 P2
/// </summary>
public
int
Middle_P2
=
0
;
}
}
source/DeviceLibrary/store/StoreStep.cs
查看文件 @
e178b7d
...
...
@@ -134,48 +134,25 @@ namespace OnlineStore.DeviceLibrary
/// 无操作,等待状态
/// </summary>
Wait
=
0
,
#
region
料仓
重置
101
开始
#
region
料仓
重置
101
开始
/// <summary>
/// 复位:
进出轴回原点
/// 复位:
升降门关闭,关闭所有灯
/// </summary>
R01_InOutBack
=
101
,
R01_DoorClose
=
101
,
/// <summary>
/// 复位:
进出轴回P1,关闭仓门,冷藏门
/// 复位:
料斗旋转轴返回原点
/// </summary>
R02_
InOutToP1
,
R02_
MiddleHome
,
/// <summary>
/// 复位:
升降轴,旋转轴,搅拌轴,回温轴,冷藏轴原点返回
/// 复位:
旋转轴到待机点
/// </summary>
R03_OtherAxisBack
,
R03_MiddleToP1
,
/// <summary>
/// 复位:旋转轴,升降轴,搅拌轴到待机点
/// </summary>
R04_AxisToP1
,
/// <summary>
/// 复位:启动吹气冷气,冷藏旋转,回温旋转。
/// </summary>
R05_StartWork
,
/// <summary>
/// 复位到待机点:进出轴回P1,关闭仓门,冷藏门
/// </summary>
P01_InOutToP1
,
/// <summary>
/// 复位到待机点:升降轴,旋转轴,搅拌轴,回温轴,冷藏轴原点返回
/// </summary>
P02_AxisToP1
,
/// <summary>
/// 复位:启动吹气冷气,冷藏旋转,回温旋转。
/// </summary>
P03_StartWork
,
#
endregion
#
region
出库步骤
1001
开始
,冷藏区
->
仓门口,回温区
->
仓门口
#
region
出库步骤
1001
开始
/// <summary>
///出库:进出轴到P1,旋转轴停止匀速旋转
/// </summary>
...
...
@@ -260,7 +237,7 @@ namespace OnlineStore.DeviceLibrary
#
endregion
#
region
料仓
入库步骤
2001
开始,仓门口
->
冷藏区
,或者
仓门口
->
回温区
#
region
入库步骤
2001
开始
/// <summary>
/// 入库信号检测
/// </summary>
...
...
@@ -338,325 +315,7 @@ namespace OnlineStore.DeviceLibrary
SI_17_GoBack
,
#
endregion
#
region
回温移库步骤
3001
开始
,冷藏区
->
回温区
/// <summary>
///移库:进出轴到P1,冷藏区旋转轴停止匀速旋转
/// </summary>
MG_01_InoutToP1
=
3001
,
/// <summary>
///移库:冷藏区旋转轴回原点
/// </summary>
MG_02_AxisHome
,
/// <summary>
/// 移库: 旋转轴至P2( 库位点),升降轴至P5(库位出库前点) ,旋转轴到P2
/// </summary>
MG_03_ToBag
,
/// <summary>
/// 移库:开冷藏门
/// </summary>
MG_04_OpenCold
,
/// <summary>
/// 移库:进出轴 至P3(库位取放料点)
/// </summary>
MG_05_InoutToP3
,
/// <summary>
///移库: 夹爪夹紧
/// </summary>
MG_06_Clamping_Work
,
/// <summary>
///移库:升降轴到缓冲点P6
/// </summary>
MG_07_UpdownToP6
,
/// <summary>
///移库:进出轴返回P1
/// </summary>
MG_08_InoutToP1
,
/// <summary>
/// 移库:关闭冷藏区门 ,停止回温区旋转轴匀速运动
/// </summary>
MG_09_CloseCold
,
/// <summary>
/// 移库:移动到库位点,旋转轴 至P2( 库位点)升降轴至P3(库位入库前点),回温区旋转轴回原点
/// </summary>
MP_11_MoveToTBag
,
/// <summary>
/// 移库:回温轴到P2点
/// </summary>
MP_12_TargetAxisToP2
,
///// <summary>
///// 移库:打开回温区门
///// </summary>
//MP_13_OpenTDoor,
/// <summary>
/// 移库:叉子进入库位中,进出轴至P3(库位取放料点)
/// </summary>
MP_14_InoutToP3
,
/// <summary>
/// 移库:放下物品,升降轴至P4( 库位入料缓冲点)
/// </summary>
MP_15_UpdownToP4
,
/// <summary>
/// 移库:夹爪放松
/// </summary>
MP_16_Clamping_Relax
,
/// <summary>
/// 入库。。叉子从库位中返回,进出轴动作至P1
/// </summary>
MP_17_InOutToP1
,
///// <summary>
///// 移库:关闭冷藏门
///// </summary>
//MP_18_CloseTDoor,
/// <summary>
/// 移库:返回待机点,轴2/轴1动作至P1 开始
/// </summary>
MP_19_GoBack
,
#
endregion
#
region
送料搅拌步骤
回温区
1
->
搅拌
1
,回温区
2
->
搅拌
2
4001
/// <summary>
///送料1搅拌:进出轴到P1,回温轴停止匀速旋转
/// </summary>
ST_01_InoutToP1
=
4001
,
/// <summary>
///送料1搅拌:,回温轴回原点
/// </summary>
ST_02_AxisHome
,
/// <summary>
/// 送料1搅拌: 旋转轴至P2( 库位点),升降轴至P5(库位出库前点), 回温轴到P2
/// </summary>
ST_03_ToBag
,
/// <summary>
/// 送料1搅拌:进出轴 至P3(库位取放料点)
/// </summary>
ST_05_InoutToP3
,
/// <summary>
///送料1搅拌: 夹爪夹紧
/// </summary>
ST_06_Clamping_Work
,
/// <summary>
///送料1搅拌:升降轴到缓冲点P6
/// </summary>
ST_07_UpdownToP6
,
/// <summary>
///送料1搅拌:进出轴返回P1,搅拌气缸上升
/// </summary>
ST_08_InoutToP1
,
/// <summary>
/// 送料1搅拌:移动到搅拌位置,升降轴到搅拌区高点P101,旋转轴到P101, 搅拌轴到P1
/// </summary>
ST_09_MoveToStir
,
/// <summary>
/// 送料1搅拌:搅拌气缸下降
/// </summary>
ST_10_LocationDown
,
/// <summary>
/// 送料1搅拌:进出轴移动到搅拌区取放料点P101
/// </summary>
ST_11_InoutToP101
,
/// <summary>
/// 送料1搅拌:升降轴下降到P102
/// </summary>
ST_12_UpdownToP102
,
/// <summary>
/// 送料1搅拌:夹爪放松
/// </summary>
ST_13_Clamping_Relax
,
/// <summary>
/// 送料1搅拌:进出轴后退到P1
/// </summary>
ST_14_InoutToP1
,
/// <summary>
/// 送料2搅拌: 旋转轴至P2( 库位点),升降轴至P5(库位出库前点) ,回温轴到P2
/// </summary>
ST_23_ToBag
,
/// <summary>
/// 送料2搅拌:进出轴 至P3(库位取放料点)
/// </summary>
ST_25_InoutToP3
,
/// <summary>
///送料2搅拌: 夹爪夹紧
/// </summary>
ST_26_Clamping_Work
,
/// <summary>
///送料2搅拌:升降轴到缓冲点P6
/// </summary>
ST_27_UpdownToP6
,
/// <summary>
///送料2搅拌:进出轴返回P1,搅拌气缸上升
/// </summary>
ST_28_InoutToP1
,
/// <summary>
/// 送料2搅拌:移动到搅拌位置,升降轴到搅拌区高点P101,旋转轴到P101, 搅拌轴到P2
/// </summary>
ST_29_MoveToStir
,
/// <summary>
/// 送料2搅拌:搅拌气缸下降
/// </summary>
ST_30_LocationDown
,
/// <summary>
/// 送料2搅拌:进出轴移动到搅拌区取放料点P101
/// </summary>
ST_31_InoutToP101
,
/// <summary>
/// 送料2搅拌:升降轴下降到P102
/// </summary>
ST_32_UpdownToP102
,
/// <summary>
/// 送料2搅拌:夹爪放松
/// </summary>
ST_33_Clamping_Relax
,
/// <summary>
/// 送料2搅拌:进出轴后退到P1
/// </summary>
ST_34_InoutToP1
,
/// <summary>
/// 送料2搅拌:搅拌气缸上升
/// </summary>
ST_35_LocationUp
,
/// <summary>
/// 搅拌:开始搅拌,回温轴,搅拌轴,开始匀速旋转
/// </summary>
ST_41_StartStir
,
#
endregion
#
region
搅拌回库
步骤
搅拌
1
->
回温区
1
,搅拌
2
->
回温区
2
4050
/// <summary>
/// 搅拌1回库:进出轴到P1,搅拌轴停止转动,回温区停止匀速运动,搅拌气缸上升
/// </summary>
SR_51_InoutBack
=
4051
,
/// <summary>
/// 搅拌1回库:移动到搅拌位置,升降轴到搅拌区低点P102,旋转轴到P101, 搅拌轴到P1
/// </summary>
SR_52_MoveToStir
,
/// <summary>
/// 搅拌1回库:搅拌气缸下降
/// </summary>
SR_53_LocationDown
,
/// <summary>
/// 搅拌1回库:进出轴到P101
/// </summary>
SR_54_InoutToP101
,
/// <summary>
/// 搅拌1回库:夹爪气缸夹紧
/// </summary>
SR_55_Clamping_Work
,
/// <summary>
/// 搅拌1回库:升降轴上升到高点P101
/// </summary>
SR_56_UpdownToP101
,
/// <summary>
/// 搅拌1回库:进出轴返回P1
/// </summary>
SR_57_InoutToP1
,
/// <summary>
/// 搅拌1回库:移动到库位点,旋转轴 至P2( 库位点)升降轴至P3(库位入库前点),回温轴回原点
/// </summary>
SR_58_MoveToBag
,
/// <summary>
/// 搅拌1回库:回温轴到P2点
/// </summary>
SR_59_TargetAxisToP2
,
/// <summary>
/// 搅拌1回库:叉子进入库位中,进出轴至P3(库位取放料点)
/// </summary>
SR_61_InoutToP3
,
/// <summary>
/// 搅拌1回库:放下物品,升降轴至P4( 库位入料缓冲点)
/// </summary>
SR_62_UpdownToP4
,
/// <summary>
/// 搅拌1回库:夹爪放松
/// </summary>
SR_63_Clamping_Relax
,
/// <summary>
/// 搅拌1回库:叉子从库位中返回,进出轴动作至P1
/// </summary>
SR_64_InOutToP1
,
/// <summary>
/// 搅拌2回库:进出轴返回,定位气缸上升,
/// </summary>
SR_71_LocationUp
,
/// <summary>
/// 搅拌2回库:移动到搅拌位置,升降轴到搅拌区低点P102,旋转轴到P101, 搅拌轴到P2
/// </summary>
SR_72_MoveToStir
,
/// <summary>
/// 搅拌2回库:搅拌气缸下降
/// </summary>
SR_73_LocationDown
,
/// <summary>
/// 搅拌2回库:进出轴到P101
/// </summary>
SR_74_InoutToP101
,
/// <summary>
/// 搅拌2回库:夹爪气缸夹紧
/// </summary>
SR_75_Clamping_Work
,
/// <summary>
/// 搅拌2回库:升降轴上升到高点P101
/// </summary>
SR_76_UpdownToP101
,
/// <summary>
/// 搅拌2回库:进出轴返回P1
/// </summary>
SR_77_InoutToP1
,
/// <summary>
/// 搅拌2回库:移动到库位点,旋转轴 至P2( 库位点)升降轴至P3(库位入库前点),回温轴到P2点
/// </summary>
SR_78_MoveToBag
,
///// <summary>
///// 搅拌2回库:冷藏轴或回温轴到P2点
///// </summary>
//SR_79_TargetAxisToP2,
/// <summary>
/// 搅拌2回库:叉子进入库位中,进出轴至P3(库位取放料点)
/// </summary>
SR_81_InoutToP3
,
/// <summary>
/// 搅拌2回库:放下物品,升降轴至P4( 库位入料缓冲点)
/// </summary>
SR_82_UpdownToP4
,
/// <summary>
/// 搅拌2回库:夹爪放松
/// </summary>
SR_83_Clamping_Relax
,
/// <summary>
/// 搅拌2回库:叉子从库位中返回,进出轴动作至P1
/// </summary>
SR_84_InOutToP1
,
#
endregion
}
public
enum
StoreAlarmType
...
...
source/DeviceLibrary/store/model/StoreMoveInfo.cs
查看文件 @
e178b7d
...
...
@@ -14,9 +14,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public
class
StoreMoveInfo
{
/// <summary>
/// 超时时间
/// </summary>
public
string
Name
=
""
;
public
int
TimeOutSeconds
=
60
;
public
StoreMoveInfo
(
int
storeId
)
{
...
...
source/LoadCVSLibrary/position/VerticalPosition.cs
查看文件 @
e178b7d
...
...
@@ -33,8 +33,34 @@ namespace OnlineStore.LoadCSVLibrary
/// 亮灯索引
/// </summary>
[
CSVAttribute
(
"亮灯索引"
)]
public
string
Led_Index
{
get
;
set
;
}
public
string
LedIndex
{
get
;
set
;
}
private
List
<
int
>
LedList
=
null
;
public
List
<
int
>
GetLedList
()
{
if
(
LedList
==
null
)
{
LedList
=
new
List
<
int
>();
string
[]
arrays
=
LedIndex
.
Split
(
';'
);
if
(
arrays
.
Length
>
0
)
{
foreach
(
string
str
in
arrays
)
{
try
{
int
led
=
Convert
.
ToInt32
(
str
.
Trim
());
LedList
.
Add
(
led
);
}
catch
(
Exception
ex
)
{
}
}
}
}
return
LedList
;
}
public
static
bool
CheckPosition
(
VerticalPosition
position
,
VerticalStoreConfig
Config
)
{
...
...
source/LoadCVSLibrary/storeConfig/CSVConfigReader.cs
查看文件 @
e178b7d
...
...
@@ -137,7 +137,7 @@ namespace OnlineStore.LoadCSVLibrary
public
static
StoreConfig
LoadConfig
(
int
storeId
,
string
cid
,
string
storeType
,
string
filePath
)
{
StoreConfig
config
=
null
;
if
(
storeType
.
Equals
(
StoreType
.
RC_AC_SA_
TIN
))
if
(
storeType
.
Equals
(
StoreType
.
RC_AC_SA_
Vertical
))
{
config
=
new
VerticalStoreConfig
(
storeId
,
cid
,
storeType
,
filePath
);
}
...
...
source/LoadCVSLibrary/storeConfig/ConfigItemBase.cs
查看文件 @
e178b7d
...
...
@@ -136,6 +136,11 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
[
CSVAttribute
(
"脉冲最大限位"
)]
public
int
PositionMax
{
get
;
set
;
}
public
string
Axis_Brake_DO
=
""
;
public
string
Axis_Run_DO
=
""
;
public
string
GetNameStr
()
{
return
DeviceName
+
"_"
+
GetAxisValue
();
...
...
@@ -148,11 +153,13 @@ namespace OnlineStore.LoadCSVLibrary
}
return
false
;
}
public
bool
PositionIsHasLimit
(){
public
bool
PositionIsHasLimit
()
{
if
(
PositionMin
.
Equals
(
PositionMax
))
{
return
false
;
}
return
true
;
}
return
true
;
}
/// <summary>
/// 下拉列表显示
...
...
source/LoadCVSLibrary/storeConfig/config/IO_Type.cs
查看文件 @
e178b7d
...
...
@@ -72,17 +72,10 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
public
static
string
Axis_Brake
=
"Axis_Brake"
;
/// <summary>
/// DO,升降门刹车ON,
Camera_Led
,6,192.168.200.21,升降门刹车ON,Y07,Y07,,,,,,,,,,
/// DO,升降门刹车ON,
Door_Break
,6,192.168.200.21,升降门刹车ON,Y07,Y07,,,,,,,,,,
/// </summary>
public
static
string
Camera_Led
=
"Camera_Led"
;
///// <summary>
///// DO,升降门电机上升,Door_Up,7,192.168.200.21,升降门电机上升,Y08,Y08,,,,,,,,,,
///// </summary>
//public static string Door_Up = "Door_Up";
///// <summary>
///// DO,升降门电机下降,Door_Down,8,192.168.200.21,升降门电机下降,Y09,Y09,,,,,,,,,,
///// </summary>
//public static string Door_Down = "Door_Down";
public
static
string
Door_Break
=
"Door_Break"
;
/// <summary>
/// DO,设备照明ON,Device_Led,9,192.168.200.21,设备照明ON,Y10,Y10,,,,,,,,,,
/// </summary>
...
...
source/LoadCVSLibrary/storeConfig/config/StoreType.cs
查看文件 @
e178b7d
...
...
@@ -8,6 +8,6 @@ namespace OnlineStore.LoadCSVLibrary
{
public
class
StoreType
{
public
static
string
RC_AC_SA_
TIN
=
"RC_AC_SA_TIN
"
;
public
static
string
RC_AC_SA_
Vertical
=
"RC_AC_SA_Vertical
"
;
}
}
source/LoadCVSLibrary/storeConfig/config/VerticalStoreConfig.cs
查看文件 @
e178b7d
...
...
@@ -75,8 +75,13 @@ namespace OnlineStore.LoadCSVLibrary
/// PRO,(轴一)旋转轴最大限位,MiddleAxis_PositionMax,0,,,,,,,,,,,,,,
/// </summary>
[
ConfigProAttribute
(
"MiddleAxis_PositionMax"
)]
public
int
MiddleAxis_PositionMax
{
get
;
set
;
}
public
int
MiddleAxis_PositionMax
{
get
;
set
;
}
/// <summary>
/// PRO,Led控制器IP,LED_IP,192.168.200.192,,,,,,,,,,,,,,
/// </summary>
[
ConfigProAttribute
(
"LED_IP"
)]
public
string
LED_IP
{
get
;
set
;
}
protected
override
void
initMustHavePro
()
{
MustHaveDIList
=
new
List
<
string
>();
...
...
@@ -86,7 +91,6 @@ namespace OnlineStore.LoadCSVLibrary
MustHaveDIList
.
Add
(
IO_Type
.
Door_Up
);
MustHaveDIList
.
Add
(
IO_Type
.
Door_Down
);
MustHaveDIList
.
Add
(
IO_Type
.
SafetyLightCurtains
);
MustHaveDIList
.
Add
(
IO_Type
.
SafetyLightCurtains
);
MustHaveDOList
.
Add
(
IO_Type
.
AutoRun_HddLed
);
...
...
@@ -98,7 +102,7 @@ namespace OnlineStore.LoadCSVLibrary
MustHaveDOList
.
Add
(
IO_Type
.
Axis_Brake
);
MustHaveDOList
.
Add
(
IO_Type
.
Door_Up
);
MustHaveDOList
.
Add
(
IO_Type
.
Door_Down
);
MustHaveDOList
.
Add
(
IO_Type
.
Camera_Led
);
MustHaveDOList
.
Add
(
IO_Type
.
Door_Break
);
}
public
static
void
ConfigAxis
(
VerticalStoreConfig
con
)
{
...
...
@@ -170,58 +174,7 @@ namespace OnlineStore.LoadCSVLibrary
}
return
16
;
}
//private Dictionary<string, string> CodeSizeMap = null;
//private static char codeSpilt = '#';
//public string GetCodeSize(ref string code)
//{
// try
// {
// if (CodeSizeMap == null)
// {
// CodeSizeMap = new Dictionary<string, string>();
// string[] array = CodeSizeConfig.Split(codeSpilt);
// if (array.Length > 0)
// {
// foreach (string str in array)
// {
// string[] codeStr = str.Split('=');
// if (codeStr.Length == 2)
// {
// string key = codeStr[0].Trim();
// string value = codeStr[1].Trim();
// CodeSizeMap.Add(key, value);
// }
// }
// }
// }
// foreach (string key in CodeSizeMap.Keys)
// {
// string[] array = key.Split(';');
// if (array.Length == 1 && code.Trim().StartsWith(key))
// {
// return CodeSizeMap[key];
// }
// else if (array.Length >= 2)
// {
// if (code.Trim().StartsWith(array[0]))
// {
// int leng = array[0].Length;
// code = code.Trim() + key.Substring(leng, key.Length - leng);
// return CodeSizeMap[key];
// }
// }
// }
// }
// catch (Exception ex)
// {
// LOGGER.Error("获取二维码【" + code + "】的固定尺寸出错:" + ex.ToString());
// }
// return "";
//}
}
}
source/VerticalStoreClinet/App.config
查看文件 @
e178b7d
...
...
@@ -16,7 +16,7 @@
<!--
start
one
store
config
-->
<
add
key
=
"Store_Position_Config"
value
=
"\StoreConfig\linePositions.csv"
/>
<
add
key
=
"Store_ConfigPath"
value
=
"\StoreConfig\StoreConfig.csv"
/>
<
add
key
=
"Store_Type"
value
=
"RC_AC_SA_
TIN
"
/>
<
add
key
=
"Store_Type"
value
=
"RC_AC_SA_
Vertical
"
/>
<
add
key
=
"Store_CID"
value
=
"rc1258ac-1"
/>
<!--
end
one
store
config
-->
...
...
source/VerticalStoreClinet/FrmIOStatus.Designer.cs
查看文件 @
e178b7d
...
...
@@ -18,6 +18,8 @@
this
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
timer1
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
groupBox2
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
btnCloseDoor
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnOpenDoor
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnCloseLed
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnOpenLed
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnCloseAxisBreak
=
new
System
.
Windows
.
Forms
.
Button
();
...
...
@@ -38,6 +40,7 @@
this
.
groupBox3
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
tableLayoutPanel1
=
new
System
.
Windows
.
Forms
.
TableLayoutPanel
();
this
.
chbAutoRead
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
btnStopDoor
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
groupBox2
.
SuspendLayout
();
this
.
groupBox1
.
SuspendLayout
();
this
.
groupBox4
.
SuspendLayout
();
...
...
@@ -54,6 +57,9 @@
this
.
groupBox2
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnStopDoor
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnCloseDoor
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnOpenDoor
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnCloseLed
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnOpenLed
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnCloseAxisBreak
);
...
...
@@ -65,6 +71,30 @@
this
.
groupBox2
.
TabStop
=
false
;
this
.
groupBox2
.
Text
=
"操作测试"
;
//
// btnCloseDoor
//
this
.
btnCloseDoor
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnCloseDoor
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnCloseDoor
.
Location
=
new
System
.
Drawing
.
Point
(
37
,
176
);
this
.
btnCloseDoor
.
Name
=
"btnCloseDoor"
;
this
.
btnCloseDoor
.
Size
=
new
System
.
Drawing
.
Size
(
120
,
34
);
this
.
btnCloseDoor
.
TabIndex
=
258
;
this
.
btnCloseDoor
.
Text
=
"关闭升降门"
;
this
.
btnCloseDoor
.
UseVisualStyleBackColor
=
true
;
this
.
btnCloseDoor
.
Click
+=
new
System
.
EventHandler
(
this
.
btnCloseDoor_Click
);
//
// btnOpenDoor
//
this
.
btnOpenDoor
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnOpenDoor
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnOpenDoor
.
Location
=
new
System
.
Drawing
.
Point
(
37
,
139
);
this
.
btnOpenDoor
.
Name
=
"btnOpenDoor"
;
this
.
btnOpenDoor
.
Size
=
new
System
.
Drawing
.
Size
(
120
,
34
);
this
.
btnOpenDoor
.
TabIndex
=
257
;
this
.
btnOpenDoor
.
Text
=
"打开升降门"
;
this
.
btnOpenDoor
.
UseVisualStyleBackColor
=
true
;
this
.
btnOpenDoor
.
Click
+=
new
System
.
EventHandler
(
this
.
btnOpenDoor_Click
);
//
// btnCloseLed
//
this
.
btnCloseLed
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
...
...
@@ -73,7 +103,7 @@
this
.
btnCloseLed
.
Name
=
"btnCloseLed"
;
this
.
btnCloseLed
.
Size
=
new
System
.
Drawing
.
Size
(
120
,
34
);
this
.
btnCloseLed
.
TabIndex
=
256
;
this
.
btnCloseLed
.
Text
=
"关闭照明"
;
this
.
btnCloseLed
.
Text
=
"关闭
设备
照明"
;
this
.
btnCloseLed
.
UseVisualStyleBackColor
=
true
;
this
.
btnCloseLed
.
Click
+=
new
System
.
EventHandler
(
this
.
btnCloseLed_Click
);
//
...
...
@@ -85,7 +115,7 @@
this
.
btnOpenLed
.
Name
=
"btnOpenLed"
;
this
.
btnOpenLed
.
Size
=
new
System
.
Drawing
.
Size
(
120
,
34
);
this
.
btnOpenLed
.
TabIndex
=
255
;
this
.
btnOpenLed
.
Text
=
"打开照明"
;
this
.
btnOpenLed
.
Text
=
"打开
设备
照明"
;
this
.
btnOpenLed
.
UseVisualStyleBackColor
=
true
;
this
.
btnOpenLed
.
Click
+=
new
System
.
EventHandler
(
this
.
btnOpenLed_Click
);
//
...
...
@@ -97,7 +127,7 @@
this
.
btnCloseAxisBreak
.
Name
=
"btnCloseAxisBreak"
;
this
.
btnCloseAxisBreak
.
Size
=
new
System
.
Drawing
.
Size
(
120
,
34
);
this
.
btnCloseAxisBreak
.
TabIndex
=
253
;
this
.
btnCloseAxisBreak
.
Text
=
"关闭刹车"
;
this
.
btnCloseAxisBreak
.
Text
=
"关闭
伺服
刹车"
;
this
.
btnCloseAxisBreak
.
UseVisualStyleBackColor
=
true
;
this
.
btnCloseAxisBreak
.
Click
+=
new
System
.
EventHandler
(
this
.
btnCloseAxisBreak_Click
);
//
...
...
@@ -109,7 +139,7 @@
this
.
btnOpenAxisBreak
.
Name
=
"btnOpenAxisBreak"
;
this
.
btnOpenAxisBreak
.
Size
=
new
System
.
Drawing
.
Size
(
120
,
34
);
this
.
btnOpenAxisBreak
.
TabIndex
=
252
;
this
.
btnOpenAxisBreak
.
Text
=
"打开刹车"
;
this
.
btnOpenAxisBreak
.
Text
=
"打开
伺服
刹车"
;
this
.
btnOpenAxisBreak
.
UseVisualStyleBackColor
=
true
;
this
.
btnOpenAxisBreak
.
Click
+=
new
System
.
EventHandler
(
this
.
btnOpenAxisBreak_Click
);
//
...
...
@@ -320,6 +350,18 @@
this
.
chbAutoRead
.
Text
=
"自动读取"
;
this
.
chbAutoRead
.
UseVisualStyleBackColor
=
true
;
//
// btnStopDoor
//
this
.
btnStopDoor
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnStopDoor
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnStopDoor
.
Location
=
new
System
.
Drawing
.
Point
(
37
,
216
);
this
.
btnStopDoor
.
Name
=
"btnStopDoor"
;
this
.
btnStopDoor
.
Size
=
new
System
.
Drawing
.
Size
(
120
,
34
);
this
.
btnStopDoor
.
TabIndex
=
259
;
this
.
btnStopDoor
.
Text
=
"停止升降门"
;
this
.
btnStopDoor
.
UseVisualStyleBackColor
=
true
;
this
.
btnStopDoor
.
Click
+=
new
System
.
EventHandler
(
this
.
btnStopDoor_Click
);
//
// FrmIOStatus
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
7F
,
17F
);
...
...
@@ -372,6 +414,9 @@
private
System
.
Windows
.
Forms
.
Button
btnOpenDo
;
private
System
.
Windows
.
Forms
.
Button
btnWriteSingleDO
;
private
System
.
Windows
.
Forms
.
Button
btnCloseAll
;
private
System
.
Windows
.
Forms
.
Button
btnCloseDoor
;
private
System
.
Windows
.
Forms
.
Button
btnOpenDoor
;
private
System
.
Windows
.
Forms
.
Button
btnStopDoor
;
}
}
source/VerticalStoreClinet/FrmIOStatus.cs
查看文件 @
e178b7d
...
...
@@ -211,12 +211,12 @@ namespace OnlineStore.TinPasteStore
private
void
btnOpenLed_Click
(
object
sender
,
EventArgs
e
)
{
IOManager
.
IOMove
(
IO_Type
.
Camera
_Led
,
IO_VALUE
.
HIGH
);
IOManager
.
IOMove
(
IO_Type
.
Device
_Led
,
IO_VALUE
.
HIGH
);
}
private
void
btnCloseLed_Click
(
object
sender
,
EventArgs
e
)
{
IOManager
.
IOMove
(
IO_Type
.
Camera
_Led
,
IO_VALUE
.
LOW
);
IOManager
.
IOMove
(
IO_Type
.
Device
_Led
,
IO_VALUE
.
LOW
);
}
private
void
WriteDO
(
IO_VALUE
value
)
{
...
...
@@ -244,6 +244,22 @@ namespace OnlineStore.TinPasteStore
WriteDO
(
IO_VALUE
.
LOW
);
}
private
void
btnOpenDoor_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
"用户点击:打开升降门"
);
DoorBean
.
StartOpen
(
null
);
}
private
void
btnCloseDoor_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
"用户点击:关闭升降门"
);
DoorBean
.
StartClose
(
null
);
}
private
void
btnStopDoor_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
"用户点击:停止升降门"
);
DoorBean
.
Stop
();
}
}
}
source/VerticalStoreClinet/FrmStoreBox.Designer.cs
查看文件 @
e178b7d
...
...
@@ -37,40 +37,62 @@
this
.
btnStoreStop
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnStoreStart
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnDebug
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAxisOff
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAxisOn
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
button4
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnClearL
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
tabControl1
=
new
System
.
Windows
.
Forms
.
TabControl
();
this
.
tabPage3
=
new
System
.
Windows
.
Forms
.
TabPage
();
this
.
richTextBox1
=
new
System
.
Windows
.
Forms
.
RichTextBox
();
this
.
tabPage7
=
new
System
.
Windows
.
Forms
.
TabPage
();
this
.
groupTest
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
btnCloseLed
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
label7
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label8
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnOpenLed
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
label12
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblB
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblG
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblR
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
trackBar3
=
new
System
.
Windows
.
Forms
.
TrackBar
();
this
.
trackBar2
=
new
System
.
Windows
.
Forms
.
TrackBar
();
this
.
trackBar1
=
new
System
.
Windows
.
Forms
.
TrackBar
();
this
.
btnCAll
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btOAll
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
txtLedIp
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label6
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label3
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label4
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
txtLedIndex
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
numYu
=
new
System
.
Windows
.
Forms
.
NumericUpDown
();
this
.
axisMoveControl1
=
new
OnlineStore
.
ACPackingStore
.
AxisMoveControl
();
this
.
groupInout
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnDoorPSave
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
lblMsg
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
txt
InOutP1
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
btnSave
Position
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
txt
Leds
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
btnSave
Config
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnStartAuTo
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
label9
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
txtJiange
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtMP1
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtM
iddle
P2
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtMP2
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
cmbPosition
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
btnInStore
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnOutStore
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnMP1
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnMiddleP2
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
groupBox3
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
btnCloseDoor
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
panel1
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
lblWarnMsg
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblThisSta
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
button1
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
contextMenuStrip1
.
SuspendLayout
();
this
.
tabControl1
.
SuspendLayout
();
this
.
tabPage3
.
SuspendLayout
();
this
.
tabPage7
.
SuspendLayout
();
this
.
groupTest
.
SuspendLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar3
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar2
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar1
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
numYu
)).
BeginInit
();
this
.
groupInout
.
SuspendLayout
();
this
.
groupBox3
.
SuspendLayout
();
this
.
panel1
.
SuspendLayout
();
...
...
@@ -133,7 +155,7 @@
// btnStoreExit
//
this
.
btnStoreExit
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnStoreExit
.
Location
=
new
System
.
Drawing
.
Point
(
40
3
,
3
);
this
.
btnStoreExit
.
Location
=
new
System
.
Drawing
.
Point
(
40
2
,
3
);
this
.
btnStoreExit
.
Name
=
"btnStoreExit"
;
this
.
btnStoreExit
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
39
);
this
.
btnStoreExit
.
TabIndex
=
4
;
...
...
@@ -190,7 +212,7 @@
// btnDebug
//
this
.
btnDebug
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnDebug
.
Location
=
new
System
.
Drawing
.
Point
(
309
,
333
);
this
.
btnDebug
.
Location
=
new
System
.
Drawing
.
Point
(
953
,
417
);
this
.
btnDebug
.
Name
=
"btnDebug"
;
this
.
btnDebug
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
39
);
this
.
btnDebug
.
TabIndex
=
12
;
...
...
@@ -198,32 +220,10 @@
this
.
btnDebug
.
UseVisualStyleBackColor
=
true
;
this
.
btnDebug
.
Click
+=
new
System
.
EventHandler
(
this
.
btnDebug_Click
);
//
// btnAxisOff
//
this
.
btnAxisOff
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnAxisOff
.
Location
=
new
System
.
Drawing
.
Point
(
153
,
333
);
this
.
btnAxisOff
.
Name
=
"btnAxisOff"
;
this
.
btnAxisOff
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
39
);
this
.
btnAxisOff
.
TabIndex
=
11
;
this
.
btnAxisOff
.
Text
=
"料仓运转OFF"
;
this
.
btnAxisOff
.
UseVisualStyleBackColor
=
true
;
this
.
btnAxisOff
.
Click
+=
new
System
.
EventHandler
(
this
.
料仓运转
OFFToolStripMenuItem_Click
);
//
// btnAxisOn
//
this
.
btnAxisOn
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnAxisOn
.
Location
=
new
System
.
Drawing
.
Point
(
20
,
333
);
this
.
btnAxisOn
.
Name
=
"btnAxisOn"
;
this
.
btnAxisOn
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
39
);
this
.
btnAxisOn
.
TabIndex
=
10
;
this
.
btnAxisOn
.
Text
=
"料仓运转ON"
;
this
.
btnAxisOn
.
UseVisualStyleBackColor
=
true
;
this
.
btnAxisOn
.
Click
+=
new
System
.
EventHandler
(
this
.
料仓运转
ONToolStripMenuItem_Click
);
//
// button4
//
this
.
button4
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
button4
.
Location
=
new
System
.
Drawing
.
Point
(
5
41
,
3
);
this
.
button4
.
Location
=
new
System
.
Drawing
.
Point
(
5
35
,
3
);
this
.
button4
.
Name
=
"button4"
;
this
.
button4
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
39
);
this
.
button4
.
TabIndex
=
15
;
...
...
@@ -234,7 +234,7 @@
// btnClearL
//
this
.
btnClearL
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnClearL
.
Location
=
new
System
.
Drawing
.
Point
(
6
79
,
3
);
this
.
btnClearL
.
Location
=
new
System
.
Drawing
.
Point
(
6
68
,
3
);
this
.
btnClearL
.
Name
=
"btnClearL"
;
this
.
btnClearL
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
39
);
this
.
btnClearL
.
TabIndex
=
14
;
...
...
@@ -279,11 +279,10 @@
//
// tabPage7
//
this
.
tabPage7
.
Controls
.
Add
(
this
.
groupTest
);
this
.
tabPage7
.
Controls
.
Add
(
this
.
btnDebug
);
this
.
tabPage7
.
Controls
.
Add
(
this
.
axisMoveControl1
);
this
.
tabPage7
.
Controls
.
Add
(
this
.
btnAxisOff
);
this
.
tabPage7
.
Controls
.
Add
(
this
.
groupInout
);
this
.
tabPage7
.
Controls
.
Add
(
this
.
btnAxisOn
);
this
.
tabPage7
.
Location
=
new
System
.
Drawing
.
Point
(
4
,
29
);
this
.
tabPage7
.
Name
=
"tabPage7"
;
this
.
tabPage7
.
Size
=
new
System
.
Drawing
.
Size
(
1165
,
498
);
...
...
@@ -291,34 +290,277 @@
this
.
tabPage7
.
Text
=
" 库位操作 "
;
this
.
tabPage7
.
UseVisualStyleBackColor
=
true
;
//
// groupTest
//
this
.
groupTest
.
Controls
.
Add
(
this
.
btnCloseLed
);
this
.
groupTest
.
Controls
.
Add
(
this
.
label7
);
this
.
groupTest
.
Controls
.
Add
(
this
.
label8
);
this
.
groupTest
.
Controls
.
Add
(
this
.
btnOpenLed
);
this
.
groupTest
.
Controls
.
Add
(
this
.
label12
);
this
.
groupTest
.
Controls
.
Add
(
this
.
lblB
);
this
.
groupTest
.
Controls
.
Add
(
this
.
lblG
);
this
.
groupTest
.
Controls
.
Add
(
this
.
lblR
);
this
.
groupTest
.
Controls
.
Add
(
this
.
trackBar3
);
this
.
groupTest
.
Controls
.
Add
(
this
.
trackBar2
);
this
.
groupTest
.
Controls
.
Add
(
this
.
trackBar1
);
this
.
groupTest
.
Controls
.
Add
(
this
.
btnCAll
);
this
.
groupTest
.
Controls
.
Add
(
this
.
btOAll
);
this
.
groupTest
.
Controls
.
Add
(
this
.
txtLedIp
);
this
.
groupTest
.
Controls
.
Add
(
this
.
label6
);
this
.
groupTest
.
Controls
.
Add
(
this
.
label3
);
this
.
groupTest
.
Controls
.
Add
(
this
.
label4
);
this
.
groupTest
.
Controls
.
Add
(
this
.
txtLedIndex
);
this
.
groupTest
.
Controls
.
Add
(
this
.
numYu
);
this
.
groupTest
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
235
);
this
.
groupTest
.
Name
=
"groupTest"
;
this
.
groupTest
.
Size
=
new
System
.
Drawing
.
Size
(
509
,
237
);
this
.
groupTest
.
TabIndex
=
111
;
this
.
groupTest
.
TabStop
=
false
;
this
.
groupTest
.
Text
=
"灯条测试"
;
//
// btnCloseLed
//
this
.
btnCloseLed
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
btnCloseLed
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnCloseLed
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnCloseLed
.
Location
=
new
System
.
Drawing
.
Point
(
372
,
103
);
this
.
btnCloseLed
.
Name
=
"btnCloseLed"
;
this
.
btnCloseLed
.
Size
=
new
System
.
Drawing
.
Size
(
115
,
35
);
this
.
btnCloseLed
.
TabIndex
=
274
;
this
.
btnCloseLed
.
Text
=
"关灯测试"
;
this
.
btnCloseLed
.
UseVisualStyleBackColor
=
false
;
this
.
btnCloseLed
.
Click
+=
new
System
.
EventHandler
(
this
.
btnCloseLed_Click
);
//
// label7
//
this
.
label7
.
AutoSize
=
true
;
this
.
label7
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label7
.
Location
=
new
System
.
Drawing
.
Point
(
9
,
176
);
this
.
label7
.
Name
=
"label7"
;
this
.
label7
.
Size
=
new
System
.
Drawing
.
Size
(
33
,
17
);
this
.
label7
.
TabIndex
=
128
;
this
.
label7
.
Text
=
"Blue"
;
this
.
label7
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// label8
//
this
.
label8
.
AutoSize
=
true
;
this
.
label8
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label8
.
Location
=
new
System
.
Drawing
.
Point
(
9
,
128
);
this
.
label8
.
Name
=
"label8"
;
this
.
label8
.
Size
=
new
System
.
Drawing
.
Size
(
43
,
17
);
this
.
label8
.
TabIndex
=
127
;
this
.
label8
.
Text
=
"Green"
;
this
.
label8
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// btnOpenLed
//
this
.
btnOpenLed
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
btnOpenLed
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnOpenLed
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnOpenLed
.
Location
=
new
System
.
Drawing
.
Point
(
372
,
62
);
this
.
btnOpenLed
.
Name
=
"btnOpenLed"
;
this
.
btnOpenLed
.
Size
=
new
System
.
Drawing
.
Size
(
115
,
35
);
this
.
btnOpenLed
.
TabIndex
=
272
;
this
.
btnOpenLed
.
Text
=
"开灯测试"
;
this
.
btnOpenLed
.
UseVisualStyleBackColor
=
false
;
this
.
btnOpenLed
.
Click
+=
new
System
.
EventHandler
(
this
.
btnOpenLed_Click
);
//
// label12
//
this
.
label12
.
AutoSize
=
true
;
this
.
label12
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label12
.
Location
=
new
System
.
Drawing
.
Point
(
9
,
80
);
this
.
label12
.
Name
=
"label12"
;
this
.
label12
.
Size
=
new
System
.
Drawing
.
Size
(
31
,
17
);
this
.
label12
.
TabIndex
=
126
;
this
.
label12
.
Text
=
"Red"
;
this
.
label12
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// lblB
//
this
.
lblB
.
AutoSize
=
true
;
this
.
lblB
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblB
.
Location
=
new
System
.
Drawing
.
Point
(
330
,
182
);
this
.
lblB
.
Name
=
"lblB"
;
this
.
lblB
.
Size
=
new
System
.
Drawing
.
Size
(
15
,
17
);
this
.
lblB
.
TabIndex
=
125
;
this
.
lblB
.
Text
=
"0"
;
this
.
lblB
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// lblG
//
this
.
lblG
.
AutoSize
=
true
;
this
.
lblG
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblG
.
Location
=
new
System
.
Drawing
.
Point
(
330
,
134
);
this
.
lblG
.
Name
=
"lblG"
;
this
.
lblG
.
Size
=
new
System
.
Drawing
.
Size
(
15
,
17
);
this
.
lblG
.
TabIndex
=
124
;
this
.
lblG
.
Text
=
"0"
;
this
.
lblG
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// lblR
//
this
.
lblR
.
AutoSize
=
true
;
this
.
lblR
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblR
.
Location
=
new
System
.
Drawing
.
Point
(
330
,
86
);
this
.
lblR
.
Name
=
"lblR"
;
this
.
lblR
.
Size
=
new
System
.
Drawing
.
Size
(
15
,
17
);
this
.
lblR
.
TabIndex
=
123
;
this
.
lblR
.
Text
=
"0"
;
this
.
lblR
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// trackBar3
//
this
.
trackBar3
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
trackBar3
.
LargeChange
=
10
;
this
.
trackBar3
.
Location
=
new
System
.
Drawing
.
Point
(
53
,
176
);
this
.
trackBar3
.
Maximum
=
255
;
this
.
trackBar3
.
Name
=
"trackBar3"
;
this
.
trackBar3
.
Size
=
new
System
.
Drawing
.
Size
(
273
,
45
);
this
.
trackBar3
.
TabIndex
=
122
;
this
.
trackBar3
.
TickStyle
=
System
.
Windows
.
Forms
.
TickStyle
.
None
;
this
.
trackBar3
.
ValueChanged
+=
new
System
.
EventHandler
(
this
.
trackBar3_ValueChanged
);
//
// trackBar2
//
this
.
trackBar2
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
trackBar2
.
LargeChange
=
10
;
this
.
trackBar2
.
Location
=
new
System
.
Drawing
.
Point
(
53
,
128
);
this
.
trackBar2
.
Maximum
=
255
;
this
.
trackBar2
.
Name
=
"trackBar2"
;
this
.
trackBar2
.
Size
=
new
System
.
Drawing
.
Size
(
273
,
45
);
this
.
trackBar2
.
TabIndex
=
121
;
this
.
trackBar2
.
TickStyle
=
System
.
Windows
.
Forms
.
TickStyle
.
None
;
this
.
trackBar2
.
ValueChanged
+=
new
System
.
EventHandler
(
this
.
trackBar2_ValueChanged
);
//
// trackBar1
//
this
.
trackBar1
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
trackBar1
.
LargeChange
=
10
;
this
.
trackBar1
.
Location
=
new
System
.
Drawing
.
Point
(
53
,
80
);
this
.
trackBar1
.
Maximum
=
255
;
this
.
trackBar1
.
Name
=
"trackBar1"
;
this
.
trackBar1
.
Size
=
new
System
.
Drawing
.
Size
(
273
,
45
);
this
.
trackBar1
.
TabIndex
=
120
;
this
.
trackBar1
.
TickStyle
=
System
.
Windows
.
Forms
.
TickStyle
.
None
;
this
.
trackBar1
.
ValueChanged
+=
new
System
.
EventHandler
(
this
.
trackBar1_ValueChanged
);
//
// btnCAll
//
this
.
btnCAll
.
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
this
.
btnCAll
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnCAll
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnCAll
.
Location
=
new
System
.
Drawing
.
Point
(
372
,
185
);
this
.
btnCAll
.
Name
=
"btnCAll"
;
this
.
btnCAll
.
Size
=
new
System
.
Drawing
.
Size
(
115
,
35
);
this
.
btnCAll
.
TabIndex
=
119
;
this
.
btnCAll
.
Text
=
"全关"
;
this
.
btnCAll
.
UseVisualStyleBackColor
=
false
;
this
.
btnCAll
.
Click
+=
new
System
.
EventHandler
(
this
.
btnCAll_Click
);
//
// btOAll
//
this
.
btOAll
.
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
this
.
btOAll
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btOAll
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btOAll
.
Location
=
new
System
.
Drawing
.
Point
(
372
,
144
);
this
.
btOAll
.
Name
=
"btOAll"
;
this
.
btOAll
.
Size
=
new
System
.
Drawing
.
Size
(
115
,
35
);
this
.
btOAll
.
TabIndex
=
118
;
this
.
btOAll
.
Text
=
"全开"
;
this
.
btOAll
.
UseVisualStyleBackColor
=
false
;
this
.
btOAll
.
Click
+=
new
System
.
EventHandler
(
this
.
btOAll_Click
);
//
// txtLedIp
//
this
.
txtLedIp
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
txtLedIp
.
Location
=
new
System
.
Drawing
.
Point
(
71
,
27
);
this
.
txtLedIp
.
Name
=
"txtLedIp"
;
this
.
txtLedIp
.
Size
=
new
System
.
Drawing
.
Size
(
143
,
26
);
this
.
txtLedIp
.
TabIndex
=
117
;
//
// label6
//
this
.
label6
.
AutoSize
=
true
;
this
.
label6
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label6
.
Location
=
new
System
.
Drawing
.
Point
(
9
,
32
);
this
.
label6
.
Name
=
"label6"
;
this
.
label6
.
Size
=
new
System
.
Drawing
.
Size
(
55
,
17
);
this
.
label6
.
TabIndex
=
116
;
this
.
label6
.
Text
=
"模块IP:"
;
this
.
label6
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// label3
//
this
.
label3
.
AutoSize
=
true
;
this
.
label3
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label3
.
Location
=
new
System
.
Drawing
.
Point
(
219
,
32
);
this
.
label3
.
Name
=
"label3"
;
this
.
label3
.
Size
=
new
System
.
Drawing
.
Size
(
44
,
17
);
this
.
label3
.
TabIndex
=
115
;
this
.
label3
.
Text
=
"区域:"
;
this
.
label3
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// label4
//
this
.
label4
.
AutoSize
=
true
;
this
.
label4
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label4
.
Location
=
new
System
.
Drawing
.
Point
(
339
,
32
);
this
.
label4
.
Name
=
"label4"
;
this
.
label4
.
Size
=
new
System
.
Drawing
.
Size
(
56
,
17
);
this
.
label4
.
TabIndex
=
114
;
this
.
label4
.
Text
=
"灯地址:"
;
this
.
label4
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
// txtLedIndex
//
this
.
txtLedIndex
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
txtLedIndex
.
Location
=
new
System
.
Drawing
.
Point
(
400
,
27
);
this
.
txtLedIndex
.
Name
=
"txtLedIndex"
;
this
.
txtLedIndex
.
Size
=
new
System
.
Drawing
.
Size
(
82
,
26
);
this
.
txtLedIndex
.
TabIndex
=
35
;
this
.
txtLedIndex
.
Text
=
"0"
;
//
// numYu
//
this
.
numYu
.
Location
=
new
System
.
Drawing
.
Point
(
268
,
27
);
this
.
numYu
.
Maximum
=
new
decimal
(
new
int
[]
{
255
,
0
,
0
,
0
});
this
.
numYu
.
Name
=
"numYu"
;
this
.
numYu
.
Size
=
new
System
.
Drawing
.
Size
(
66
,
26
);
this
.
numYu
.
TabIndex
=
113
;
//
// axisMoveControl1
//
this
.
axisMoveControl1
.
Location
=
new
System
.
Drawing
.
Point
(
5
19
,
4
);
this
.
axisMoveControl1
.
Location
=
new
System
.
Drawing
.
Point
(
5
25
,
4
);
this
.
axisMoveControl1
.
Name
=
"axisMoveControl1"
;
this
.
axisMoveControl1
.
Size
=
new
System
.
Drawing
.
Size
(
5
6
4
,
394
);
this
.
axisMoveControl1
.
Size
=
new
System
.
Drawing
.
Size
(
5
7
4
,
394
);
this
.
axisMoveControl1
.
TabIndex
=
0
;
//
// groupInout
//
this
.
groupInout
.
Controls
.
Add
(
this
.
label1
);
this
.
groupInout
.
Controls
.
Add
(
this
.
btnDoorPSave
);
this
.
groupInout
.
Controls
.
Add
(
this
.
lblMsg
);
this
.
groupInout
.
Controls
.
Add
(
this
.
txt
InOutP1
);
this
.
groupInout
.
Controls
.
Add
(
this
.
btnSave
Position
);
this
.
groupInout
.
Controls
.
Add
(
this
.
txt
Leds
);
this
.
groupInout
.
Controls
.
Add
(
this
.
btnSave
Config
);
this
.
groupInout
.
Controls
.
Add
(
this
.
btnStartAuTo
);
this
.
groupInout
.
Controls
.
Add
(
this
.
label9
);
this
.
groupInout
.
Controls
.
Add
(
this
.
txtJiange
);
this
.
groupInout
.
Controls
.
Add
(
this
.
txtMP1
);
this
.
groupInout
.
Controls
.
Add
(
this
.
txtM
iddle
P2
);
this
.
groupInout
.
Controls
.
Add
(
this
.
txtMP2
);
this
.
groupInout
.
Controls
.
Add
(
this
.
cmbPosition
);
this
.
groupInout
.
Controls
.
Add
(
this
.
btnInStore
);
this
.
groupInout
.
Controls
.
Add
(
this
.
btnOutStore
);
this
.
groupInout
.
Controls
.
Add
(
this
.
btnMP1
);
this
.
groupInout
.
Controls
.
Add
(
this
.
btnMiddleP2
);
this
.
groupInout
.
Enabled
=
false
;
this
.
groupInout
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
4
);
this
.
groupInout
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
4
);
this
.
groupInout
.
Name
=
"groupInout"
;
this
.
groupInout
.
Size
=
new
System
.
Drawing
.
Size
(
50
3
,
314
);
this
.
groupInout
.
Size
=
new
System
.
Drawing
.
Size
(
50
9
,
227
);
this
.
groupInout
.
TabIndex
=
100
;
this
.
groupInout
.
TabStop
=
false
;
this
.
groupInout
.
Text
=
"库位信息"
;
...
...
@@ -326,72 +568,59 @@
// label1
//
this
.
label1
.
AutoSize
=
true
;
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
49
,
243
);
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
273
,
131
);
this
.
label1
.
Name
=
"label1"
;
this
.
label1
.
Size
=
new
System
.
Drawing
.
Size
(
82
,
20
);
this
.
label1
.
TabIndex
=
273
;
this
.
label1
.
Text
=
"灯地址列表:"
;
//
// btnDoorPSave
//
this
.
btnDoorPSave
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
this
.
btnDoorPSave
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnDoorPSave
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnDoorPSave
.
Location
=
new
System
.
Drawing
.
Point
(
304
,
243
);
this
.
btnDoorPSave
.
Name
=
"btnDoorPSave"
;
this
.
btnDoorPSave
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
38
);
this
.
btnDoorPSave
.
TabIndex
=
272
;
this
.
btnDoorPSave
.
Text
=
"仓门/搅拌/待机 位置保存"
;
this
.
btnDoorPSave
.
UseVisualStyleBackColor
=
false
;
this
.
btnDoorPSave
.
Click
+=
new
System
.
EventHandler
(
this
.
btnDoorPSave_Click
);
//
// lblMsg
//
this
.
lblMsg
.
AutoSize
=
true
;
this
.
lblMsg
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblMsg
.
ForeColor
=
System
.
Drawing
.
Color
.
Green
;
this
.
lblMsg
.
Location
=
new
System
.
Drawing
.
Point
(
2
68
,
93
);
this
.
lblMsg
.
Location
=
new
System
.
Drawing
.
Point
(
2
71
,
81
);
this
.
lblMsg
.
Name
=
"lblMsg"
;
this
.
lblMsg
.
Size
=
new
System
.
Drawing
.
Size
(
135
,
20
);
this
.
lblMsg
.
TabIndex
=
223
;
this
.
lblMsg
.
Text
=
"没有开启自动出入库"
;
//
// txt
InOutP1
//
this
.
txt
InOutP1
.
AcceptsReturn
=
true
;
this
.
txt
InOutP1
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Window
;
this
.
txt
InOutP1
.
Cursor
=
System
.
Windows
.
Forms
.
Cursors
.
IBeam
;
this
.
txt
InOutP1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
txt
InOutP1
.
ForeColor
=
System
.
Drawing
.
SystemColors
.
WindowText
;
this
.
txt
InOutP1
.
Location
=
new
System
.
Drawing
.
Point
(
141
,
240
);
this
.
txt
InOutP1
.
MaxLength
=
0
;
this
.
txt
InOutP1
.
Name
=
"txtInOutP1
"
;
this
.
txt
InOutP1
.
RightToLeft
=
System
.
Windows
.
Forms
.
RightToLeft
.
No
;
this
.
txt
InOutP1
.
Size
=
new
System
.
Drawing
.
Size
(
111
,
26
);
this
.
txt
InOutP1
.
TabIndex
=
210
;
this
.
txt
InOutP1
.
Text
=
"9999"
;
//
// btnSave
Position
//
this
.
btnSave
Position
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
this
.
btnSave
Position
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnSave
Position
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnSave
Position
.
Location
=
new
System
.
Drawing
.
Point
(
304
,
188
);
this
.
btnSave
Position
.
Name
=
"btnSavePosition
"
;
this
.
btnSave
Position
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
38
);
this
.
btnSave
Position
.
TabIndex
=
217
;
this
.
btnSave
Position
.
Text
=
"位置保存
"
;
this
.
btnSave
Position
.
UseVisualStyleBackColor
=
false
;
this
.
btnSave
Position
.
Click
+=
new
System
.
EventHandler
(
this
.
btnSavePosition_Click
);
// txt
Leds
//
this
.
txt
Leds
.
AcceptsReturn
=
true
;
this
.
txt
Leds
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Window
;
this
.
txt
Leds
.
Cursor
=
System
.
Windows
.
Forms
.
Cursors
.
IBeam
;
this
.
txt
Leds
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
txt
Leds
.
ForeColor
=
System
.
Drawing
.
SystemColors
.
WindowText
;
this
.
txt
Leds
.
Location
=
new
System
.
Drawing
.
Point
(
376
,
128
);
this
.
txt
Leds
.
MaxLength
=
0
;
this
.
txt
Leds
.
Name
=
"txtLeds
"
;
this
.
txt
Leds
.
RightToLeft
=
System
.
Windows
.
Forms
.
RightToLeft
.
No
;
this
.
txt
Leds
.
Size
=
new
System
.
Drawing
.
Size
(
111
,
26
);
this
.
txt
Leds
.
TabIndex
=
210
;
this
.
txt
Leds
.
Text
=
"9999"
;
//
// btnSave
Config
//
this
.
btnSave
Config
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
btnSave
Config
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnSave
Config
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnSave
Config
.
Location
=
new
System
.
Drawing
.
Point
(
382
,
169
);
this
.
btnSave
Config
.
Name
=
"btnSaveConfig
"
;
this
.
btnSave
Config
.
Size
=
new
System
.
Drawing
.
Size
(
105
,
38
);
this
.
btnSave
Config
.
TabIndex
=
217
;
this
.
btnSave
Config
.
Text
=
"保存配置
"
;
this
.
btnSave
Config
.
UseVisualStyleBackColor
=
false
;
this
.
btnSave
Config
.
Click
+=
new
System
.
EventHandler
(
this
.
btnSavePosition_Click
);
//
// btnStartAuTo
//
this
.
btnStartAuTo
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
this
.
btnStartAuTo
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
btnStartAuTo
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnStartAuTo
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnStartAuTo
.
Location
=
new
System
.
Drawing
.
Point
(
1
55
,
84
);
this
.
btnStartAuTo
.
Location
=
new
System
.
Drawing
.
Point
(
1
46
,
73
);
this
.
btnStartAuTo
.
Name
=
"btnStartAuTo"
;
this
.
btnStartAuTo
.
Size
=
new
System
.
Drawing
.
Size
(
1
11
,
38
);
this
.
btnStartAuTo
.
Size
=
new
System
.
Drawing
.
Size
(
1
05
,
38
);
this
.
btnStartAuTo
.
TabIndex
=
222
;
this
.
btnStartAuTo
.
Text
=
"启动自动模式"
;
this
.
btnStartAuTo
.
UseVisualStyleBackColor
=
false
;
...
...
@@ -401,15 +630,15 @@
//
this
.
label9
.
AutoSize
=
true
;
this
.
label9
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label9
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
96
);
this
.
label9
.
Location
=
new
System
.
Drawing
.
Point
(
29
,
84
);
this
.
label9
.
Name
=
"label9"
;
this
.
label9
.
Size
=
new
System
.
Drawing
.
Size
(
83
,
17
);
this
.
label9
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
17
);
this
.
label9
.
TabIndex
=
220
;
this
.
label9
.
Text
=
"入库间隔
仓位
:"
;
this
.
label9
.
Text
=
"入库间隔:"
;
//
// txtJiange
//
this
.
txtJiange
.
Location
=
new
System
.
Drawing
.
Point
(
107
,
90
);
this
.
txtJiange
.
Location
=
new
System
.
Drawing
.
Point
(
94
,
79
);
this
.
txtJiange
.
Name
=
"txtJiange"
;
this
.
txtJiange
.
Size
=
new
System
.
Drawing
.
Size
(
37
,
26
);
this
.
txtJiange
.
TabIndex
=
221
;
...
...
@@ -422,7 +651,7 @@
this
.
txtMP1
.
Cursor
=
System
.
Windows
.
Forms
.
Cursors
.
IBeam
;
this
.
txtMP1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
txtMP1
.
ForeColor
=
System
.
Drawing
.
SystemColors
.
WindowText
;
this
.
txtMP1
.
Location
=
new
System
.
Drawing
.
Point
(
14
1
,
157
);
this
.
txtMP1
.
Location
=
new
System
.
Drawing
.
Point
(
14
0
,
129
);
this
.
txtMP1
.
MaxLength
=
0
;
this
.
txtMP1
.
Name
=
"txtMP1"
;
this
.
txtMP1
.
RightToLeft
=
System
.
Windows
.
Forms
.
RightToLeft
.
No
;
...
...
@@ -430,20 +659,20 @@
this
.
txtMP1
.
TabIndex
=
194
;
this
.
txtMP1
.
Text
=
"9999"
;
//
// txtM
iddle
P2
//
this
.
txtM
iddle
P2
.
AcceptsReturn
=
true
;
this
.
txtM
iddle
P2
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Window
;
this
.
txtM
iddle
P2
.
Cursor
=
System
.
Windows
.
Forms
.
Cursors
.
IBeam
;
this
.
txtM
iddle
P2
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
txtM
iddle
P2
.
ForeColor
=
System
.
Drawing
.
SystemColors
.
WindowText
;
this
.
txtM
iddleP2
.
Location
=
new
System
.
Drawing
.
Point
(
140
,
196
);
this
.
txtM
iddle
P2
.
MaxLength
=
0
;
this
.
txtM
iddleP2
.
Name
=
"txtMiddle
P2"
;
this
.
txtM
iddle
P2
.
RightToLeft
=
System
.
Windows
.
Forms
.
RightToLeft
.
No
;
this
.
txtM
iddle
P2
.
Size
=
new
System
.
Drawing
.
Size
(
111
,
26
);
this
.
txtM
iddle
P2
.
TabIndex
=
192
;
this
.
txtM
iddle
P2
.
Text
=
"9999"
;
// txtMP2
//
this
.
txtMP2
.
AcceptsReturn
=
true
;
this
.
txtMP2
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Window
;
this
.
txtMP2
.
Cursor
=
System
.
Windows
.
Forms
.
Cursors
.
IBeam
;
this
.
txtMP2
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
txtMP2
.
ForeColor
=
System
.
Drawing
.
SystemColors
.
WindowText
;
this
.
txtM
P2
.
Location
=
new
System
.
Drawing
.
Point
(
140
,
169
);
this
.
txtMP2
.
MaxLength
=
0
;
this
.
txtM
P2
.
Name
=
"txtM
P2"
;
this
.
txtMP2
.
RightToLeft
=
System
.
Windows
.
Forms
.
RightToLeft
.
No
;
this
.
txtMP2
.
Size
=
new
System
.
Drawing
.
Size
(
111
,
26
);
this
.
txtMP2
.
TabIndex
=
192
;
this
.
txtMP2
.
Text
=
"9999"
;
//
// cmbPosition
//
...
...
@@ -453,18 +682,18 @@
this
.
cmbPosition
.
Items
.
AddRange
(
new
object
[]
{
"料仓0"
,
"料仓1"
});
this
.
cmbPosition
.
Location
=
new
System
.
Drawing
.
Point
(
1
5
,
27
);
this
.
cmbPosition
.
Location
=
new
System
.
Drawing
.
Point
(
1
8
,
29
);
this
.
cmbPosition
.
Name
=
"cmbPosition"
;
this
.
cmbPosition
.
Size
=
new
System
.
Drawing
.
Size
(
2
50
,
28
);
this
.
cmbPosition
.
Size
=
new
System
.
Drawing
.
Size
(
2
33
,
28
);
this
.
cmbPosition
.
TabIndex
=
174
;
this
.
cmbPosition
.
SelectedIndexChanged
+=
new
System
.
EventHandler
(
this
.
cmbPosition_SelectedIndexChanged
);
//
// btnInStore
//
this
.
btnInStore
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
this
.
btnInStore
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
btnInStore
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnInStore
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnInStore
.
Location
=
new
System
.
Drawing
.
Point
(
27
1
,
22
);
this
.
btnInStore
.
Location
=
new
System
.
Drawing
.
Point
(
27
4
,
24
);
this
.
btnInStore
.
Name
=
"btnInStore"
;
this
.
btnInStore
.
Size
=
new
System
.
Drawing
.
Size
(
105
,
38
);
this
.
btnInStore
.
TabIndex
=
102
;
...
...
@@ -474,10 +703,10 @@
//
// btnOutStore
//
this
.
btnOutStore
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
this
.
btnOutStore
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
btnOutStore
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnOutStore
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnOutStore
.
Location
=
new
System
.
Drawing
.
Point
(
3
79
,
22
);
this
.
btnOutStore
.
Location
=
new
System
.
Drawing
.
Point
(
3
82
,
24
);
this
.
btnOutStore
.
Name
=
"btnOutStore"
;
this
.
btnOutStore
.
Size
=
new
System
.
Drawing
.
Size
(
105
,
38
);
this
.
btnOutStore
.
TabIndex
=
101
;
...
...
@@ -493,7 +722,7 @@
this
.
btnMP1
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnMP1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnMP1
.
ForeColor
=
System
.
Drawing
.
Color
.
Blue
;
this
.
btnMP1
.
Location
=
new
System
.
Drawing
.
Point
(
1
9
,
152
);
this
.
btnMP1
.
Location
=
new
System
.
Drawing
.
Point
(
1
8
,
126
);
this
.
btnMP1
.
Name
=
"btnMP1"
;
this
.
btnMP1
.
RightToLeft
=
System
.
Windows
.
Forms
.
RightToLeft
.
No
;
this
.
btnMP1
.
Size
=
new
System
.
Drawing
.
Size
(
113
,
33
);
...
...
@@ -501,7 +730,7 @@
this
.
btnMP1
.
Text
=
"旋转轴待机点P1:"
;
this
.
btnMP1
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleLeft
;
this
.
btnMP1
.
UseVisualStyleBackColor
=
false
;
this
.
btnMP1
.
Click
+=
new
System
.
EventHandler
(
this
.
btn
InOutP3
_Click
);
this
.
btnMP1
.
Click
+=
new
System
.
EventHandler
(
this
.
btn
MiddleP1
_Click
);
//
// btnMiddleP2
//
...
...
@@ -511,7 +740,7 @@
this
.
btnMiddleP2
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnMiddleP2
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnMiddleP2
.
ForeColor
=
System
.
Drawing
.
Color
.
Blue
;
this
.
btnMiddleP2
.
Location
=
new
System
.
Drawing
.
Point
(
18
,
1
91
);
this
.
btnMiddleP2
.
Location
=
new
System
.
Drawing
.
Point
(
18
,
1
64
);
this
.
btnMiddleP2
.
Name
=
"btnMiddleP2"
;
this
.
btnMiddleP2
.
RightToLeft
=
System
.
Windows
.
Forms
.
RightToLeft
.
No
;
this
.
btnMiddleP2
.
Size
=
new
System
.
Drawing
.
Size
(
113
,
33
);
...
...
@@ -525,7 +754,7 @@
//
this
.
groupBox3
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)(((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
groupBox3
.
Controls
.
Add
(
this
.
b
utton1
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
b
tnCloseDoor
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
panel1
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
lblWarnMsg
);
this
.
groupBox3
.
Controls
.
Add
(
this
.
lblThisSta
);
...
...
@@ -536,6 +765,18 @@
this
.
groupBox3
.
TabStop
=
false
;
this
.
groupBox3
.
Text
=
"设备状态"
;
//
// btnCloseDoor
//
this
.
btnCloseDoor
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
btnCloseDoor
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btnCloseDoor
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnCloseDoor
.
Location
=
new
System
.
Drawing
.
Point
(
1019
,
114
);
this
.
btnCloseDoor
.
Name
=
"btnCloseDoor"
;
this
.
btnCloseDoor
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
39
);
this
.
btnCloseDoor
.
TabIndex
=
275
;
this
.
btnCloseDoor
.
Text
=
"关闭升降门"
;
this
.
btnCloseDoor
.
UseVisualStyleBackColor
=
false
;
//
// panel1
//
this
.
panel1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)(((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
...
...
@@ -560,7 +801,7 @@
this
.
lblWarnMsg
.
ForeColor
=
System
.
Drawing
.
Color
.
Red
;
this
.
lblWarnMsg
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
114
);
this
.
lblWarnMsg
.
Name
=
"lblWarnMsg"
;
this
.
lblWarnMsg
.
Size
=
new
System
.
Drawing
.
Size
(
9
00
,
56
);
this
.
lblWarnMsg
.
Size
=
new
System
.
Drawing
.
Size
(
9
83
,
56
);
this
.
lblWarnMsg
.
TabIndex
=
224
;
this
.
lblWarnMsg
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleCenter
;
//
...
...
@@ -575,18 +816,6 @@
this
.
lblThisSta
.
TabIndex
=
216
;
this
.
lblThisSta
.
Text
=
"等待启动"
;
//
// button1
//
this
.
button1
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
this
.
button1
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
button1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
button1
.
Location
=
new
System
.
Drawing
.
Point
(
961
,
132
);
this
.
button1
.
Name
=
"button1"
;
this
.
button1
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
38
);
this
.
button1
.
TabIndex
=
275
;
this
.
button1
.
Text
=
"仓门/搅拌/待机 位置保存"
;
this
.
button1
.
UseVisualStyleBackColor
=
false
;
//
// FrmStoreBox
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
96F
,
96F
);
...
...
@@ -606,6 +835,12 @@
this
.
tabControl1
.
ResumeLayout
(
false
);
this
.
tabPage3
.
ResumeLayout
(
false
);
this
.
tabPage7
.
ResumeLayout
(
false
);
this
.
groupTest
.
ResumeLayout
(
false
);
this
.
groupTest
.
PerformLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar3
)).
EndInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar2
)).
EndInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
trackBar1
)).
EndInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
numYu
)).
EndInit
();
this
.
groupInout
.
ResumeLayout
(
false
);
this
.
groupInout
.
PerformLayout
();
this
.
groupBox3
.
ResumeLayout
(
false
);
...
...
@@ -633,8 +868,6 @@
private
System
.
Windows
.
Forms
.
Button
btnStoreExit
;
private
System
.
Windows
.
Forms
.
Button
btnSotreReset
;
private
System
.
Windows
.
Forms
.
Button
btnStoreStop
;
private
System
.
Windows
.
Forms
.
Button
btnAxisOff
;
private
System
.
Windows
.
Forms
.
Button
btnAxisOn
;
private
System
.
Windows
.
Forms
.
Button
button4
;
private
System
.
Windows
.
Forms
.
Button
btnClearL
;
private
System
.
Windows
.
Forms
.
Button
btnStoreStart
;
...
...
@@ -645,22 +878,41 @@
private
ACPackingStore
.
AxisMoveControl
axisMoveControl1
;
private
System
.
Windows
.
Forms
.
GroupBox
groupInout
;
private
System
.
Windows
.
Forms
.
Label
lblMsg
;
public
System
.
Windows
.
Forms
.
TextBox
txt
InOutP1
;
private
System
.
Windows
.
Forms
.
Button
btnSave
Position
;
public
System
.
Windows
.
Forms
.
TextBox
txt
Leds
;
private
System
.
Windows
.
Forms
.
Button
btnSave
Config
;
private
System
.
Windows
.
Forms
.
Button
btnStartAuTo
;
private
System
.
Windows
.
Forms
.
Label
label9
;
private
System
.
Windows
.
Forms
.
TextBox
txtJiange
;
public
System
.
Windows
.
Forms
.
TextBox
txtMP1
;
public
System
.
Windows
.
Forms
.
TextBox
txtM
iddle
P2
;
public
System
.
Windows
.
Forms
.
TextBox
txtMP2
;
private
System
.
Windows
.
Forms
.
ComboBox
cmbPosition
;
private
System
.
Windows
.
Forms
.
Button
btnInStore
;
private
System
.
Windows
.
Forms
.
Button
btnOutStore
;
public
System
.
Windows
.
Forms
.
Button
btnMP1
;
public
System
.
Windows
.
Forms
.
Button
btnMiddleP2
;
private
System
.
Windows
.
Forms
.
Button
btn
DoorPSave
;
private
System
.
Windows
.
Forms
.
Button
btn
OpenLed
;
private
System
.
Windows
.
Forms
.
Panel
panel1
;
private
System
.
Windows
.
Forms
.
Label
label1
;
private
System
.
Windows
.
Forms
.
Button
button1
;
private
System
.
Windows
.
Forms
.
Button
btnCloseDoor
;
private
System
.
Windows
.
Forms
.
Button
btnCloseLed
;
private
System
.
Windows
.
Forms
.
GroupBox
groupTest
;
private
System
.
Windows
.
Forms
.
Label
label7
;
private
System
.
Windows
.
Forms
.
Label
label8
;
private
System
.
Windows
.
Forms
.
Label
label12
;
private
System
.
Windows
.
Forms
.
Label
lblB
;
private
System
.
Windows
.
Forms
.
Label
lblG
;
private
System
.
Windows
.
Forms
.
Label
lblR
;
private
System
.
Windows
.
Forms
.
TrackBar
trackBar3
;
private
System
.
Windows
.
Forms
.
TrackBar
trackBar2
;
private
System
.
Windows
.
Forms
.
TrackBar
trackBar1
;
private
System
.
Windows
.
Forms
.
Button
btnCAll
;
private
System
.
Windows
.
Forms
.
Button
btOAll
;
private
System
.
Windows
.
Forms
.
TextBox
txtLedIp
;
private
System
.
Windows
.
Forms
.
Label
label6
;
private
System
.
Windows
.
Forms
.
Label
label3
;
private
System
.
Windows
.
Forms
.
Label
label4
;
private
System
.
Windows
.
Forms
.
TextBox
txtLedIndex
;
private
System
.
Windows
.
Forms
.
NumericUpDown
numYu
;
}
}
source/VerticalStoreClinet/FrmStoreBox.cs
查看文件 @
e178b7d
...
...
@@ -49,24 +49,34 @@ namespace OnlineStore.TinPasteStore
{
cmbPosition
.
DataSource
=
store
.
PositionNumList
;
cmbPosition
.
SelectedIndex
=
0
;
ktkPosition
=
CSVPositionReader
<
VerticalPosition
>.
GetPositon
(
cmbPosition
.
Text
);
ktkPosition
=
CSVPositionReader
<
VerticalPosition
>.
GetPositon
(
cmbPosition
.
Text
);
}
timer1
.
Enabled
=
true
;
}
this
.
ShowInTaskbar
=
true
;
this
.
Text
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
App_Title
);
notifyIcon1
.
Text
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
App_Title
);
this
.
chbBuzzer
.
Checked
=
store
.
UseBuzzer
;
axisMoveControl1
.
LoadData
(
store
,
store
.
moveAxisList
.
ToArray
());
txtLedIp
.
Text
=
store
.
Config
.
LED_IP
;
txtMP1
.
Text
=
store
.
Config
.
MiddleAxis_P1
.
ToString
();
FrmIOStatus
frm
=
new
FrmIOStatus
();
trackBar1
.
Value
=
Light
.
defaultR
;
trackBar2
.
Value
=
Light
.
defaultG
;
trackBar3
.
Value
=
Light
.
defaultB
;
#
endregion
frm
.
SetStore
(
store
);
AddForm
(
" IO状态查看 "
,
frm
);
private
void
start_button_Click
(
object
sender
,
EventArgs
e
)
{
store
.
StartRun
();
if
(
store
.
runStatus
>=
StoreRunStatus
.
HomeMoving
)
{
StoreOpenStatus
(
true
);
}
LoadOk
=
true
;
this
.
Opacity
=
1
;
}
#
endregion
private
void
stop_button_Click
(
object
sender
,
EventArgs
e
)
{
try
...
...
@@ -99,26 +109,11 @@ namespace OnlineStore.TinPasteStore
private
bool
LoadOk
=
false
;
private
void
FrmTest_Load
(
object
sender
,
EventArgs
e
)
{
{
string
version
=
GetVersion
(
true
);
cmbPosition
.
Items
.
Clear
();
LogUtil
.
logBox
=
this
.
richTextBox1
;
InitStoreValue
();
this
.
ShowInTaskbar
=
true
;
this
.
Text
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
App_Title
);
notifyIcon1
.
Text
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
App_Title
);
this
.
chbBuzzer
.
Checked
=
store
.
UseBuzzer
;
axisMoveControl1
.
LoadData
(
store
,
store
.
moveAxisList
.
ToArray
());
FrmIOStatus
frm
=
new
FrmIOStatus
();
frm
.
SetStore
(
store
);
AddForm
(
"IO状态查看"
,
frm
);
LoadOk
=
true
;
this
.
Opacity
=
1
;
InitStoreValue
();
}
private
void
AddForm
(
string
text
,
Form
form
)
{
...
...
@@ -261,8 +256,8 @@ namespace OnlineStore.TinPasteStore
if
(
store
.
runStatus
>=
StoreRunStatus
.
HomeMoving
)
{
string
selectPositionNum
=
cmbPosition
.
Text
;
StoreMoveP
ktk
=
GetMoveP
();
store
.
StartOutStore
(
new
InOutParam
(
MoveType
.
OutStore
,
selectPositionNum
,
ktk
));
//
StoreMoveP ktk = GetMoveP();
//
store.StartOutStore(new InOutParam(MoveType.OutStore, selectPositionNum, ktk));
}
else
{
...
...
@@ -275,36 +270,33 @@ namespace OnlineStore.TinPasteStore
if
(
store
.
runStatus
>=
StoreRunStatus
.
HomeMoving
)
{
string
selectPositionNum
=
cmbPosition
.
Text
;
StoreMoveP
ktk
=
GetMoveP
();
store
.
StartInStore
(
new
InOutParam
(
MoveType
.
InStore
,
selectPositionNum
,
ktk
));
//
StoreMoveP ktk = GetMoveP();
//
store.StartInStore(new InOutParam(MoveType.InStore, selectPositionNum, ktk));
}
else
{
MessageBox
.
Show
(
"请先启动料仓!"
);
}
}
private
StoreMoveP
GetMoveP
()
{
throw
new
NotImplementedException
();
}
private
void
cmbPosition_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
if
(
cmbPosition
.
SelectedIndex
>=
0
)
{
string
PosId
=
cmbPosition
.
Text
;
VerticalPosition
position
=
CSVPositionReader
<
VerticalPosition
>.
GetPositon
(
PosId
);
txtMP2
.
Text
=
position
.
MiddleAxis_P2
.
ToString
();
txtLeds
.
Text
=
position
.
LedIndex
;
}
}
private
void
btnSavePosition_Click
(
object
sender
,
EventArgs
e
)
{
string
selectPositionNum
=
cmbPosition
.
Text
;
VerticalPosition
position
=
CSVPositionReader
<
VerticalPosition
>.
GetPositon
(
selectPositionNum
);
position
=
GetPosition
(
position
);
position
.
MiddleAxis_P2
=
FormUtil
.
GetIntValue
(
txtMP2
);
position
.
LedIndex
=
txtLeds
.
Text
;
string
appPath
=
Application
.
StartupPath
;
string
positionConfigFile
=
appPath
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_Position_Config
);
if
(!
File
.
Exists
(
positionConfigFile
))
...
...
@@ -314,63 +306,32 @@ namespace OnlineStore.TinPasteStore
bool
result
=
CSVPositionReader
<
VerticalPosition
>.
SavePostion
(
positionConfigFile
,
position
);
if
(!
result
)
{
MessageBox
.
Show
(
"
库位["
+
selectPositionNum
+
"]
保存失败 "
);
MessageBox
.
Show
(
"
保存失败 "
);
}
else
{
MessageBox
.
Show
(
"
库位["
+
selectPositionNum
+
"]
保存成功 "
);
MessageBox
.
Show
(
"
保存成功 "
);
}
}
private
VerticalPosition
GetPosition
(
VerticalPosition
position
)
{
throw
new
NotImplementedException
();
}
#
region
轴运动测试
}
private
void
AxisABSMove
(
ConfigMoveAxis
moveAxis
,
TextBox
txt
,
int
targetSpeed
)
{
{
int
targetPosition
=
FormUtil
.
GetIntValue
(
txt
);
moveAxis
.
TargetPosition
=
targetPosition
;
ACServerManager
.
AbsMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
targetPosition
,
targetSpeed
);
}
}
private
void
btnMiddleP2_Click
(
object
sender
,
EventArgs
e
)
{
AxisABSMove
(
store
.
Config
.
Middle_Axis
,
txtMiddleP2
,
store
.
Config
.
MiddleAxis_P2_Speed
);
}
private
void
btnInOutP1_Click
(
object
sender
,
EventArgs
e
)
{
// AxisABSMove(store.Config.InOut_Axis, txtInOutP1, store.Config.InOutAxis_P1_Speed);
}
private
void
btnInOutP3_Click
(
object
sender
,
EventArgs
e
)
AxisABSMove
(
store
.
Config
.
Middle_Axis
,
txtMP2
,
store
.
Config
.
MiddleAxis_P2_Speed
);
}
private
void
btnMiddleP1_Click
(
object
sender
,
EventArgs
e
)
{
// AxisABSMove(store.Config.InOut_Axis, txtMP1, store.Config.InOutAxis_P3_Speed);
}
#
endregion
AxisABSMove
(
store
.
Config
.
Middle_Axis
,
txtMP1
,
store
.
Config
.
MiddleAxis_P1_Speed
);
}
#
region
菜单操作
private
void
button1_Click
(
object
sender
,
EventArgs
e
)
{
//FormManager.ShowAxisDebug(store);
}
private
void
btnStartAuTo_Click
(
object
sender
,
EventArgs
e
)
{
if
(
store
.
runStatus
>=
StoreRunStatus
.
HomeMoving
)
...
...
@@ -407,16 +368,15 @@ namespace OnlineStore.TinPasteStore
{
MessageBox
.
Show
(
"请先启动料仓!"
);
}
}
private
void
btnAxisP_Click
(
object
sender
,
EventArgs
e
)
{
button1_Click
(
null
,
null
);
}
}
private
void
启动
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
start_button_Click
(
null
,
null
);
store
.
StartRun
();
if
(
store
.
runStatus
>=
StoreRunStatus
.
HomeMoving
)
{
StoreOpenStatus
(
true
);
}
}
private
void
停止
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
...
...
@@ -427,58 +387,7 @@ namespace OnlineStore.TinPasteStore
private
void
复位
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
this
.
store
.
Reset
();
}
private
void
料仓运转
ONToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
this
.
Enabled
=
false
;
store
.
RunAxis
(
false
);
this
.
Enabled
=
true
;
LogUtil
.
info
(
"料仓运转ON完成"
);
}
private
void
btnScanCode_Click
(
object
sender
,
EventArgs
e
)
{
IOManager
.
IOMove
(
IO_Type
.
Camera_Led
,
IO_VALUE
.
HIGH
);
string
message
=
""
;
List
<
CodeInfo
>
codeList
=
CodeManager
.
CameraScan
();
foreach
(
CodeInfo
str
in
codeList
)
{
message
=
message
+
str
.
X
+
"x"
+
str
.
Y
+
"="
+
str
.
CodeStr
+
"##"
;
}
LogUtil
.
info
(
"扫码测试收到二维码 :"
+
message
);
IOManager
.
IOMove
(
IO_Type
.
Camera_Led
,
IO_VALUE
.
LOW
);
}
private
void
料仓运转
OFFToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
store
.
CloseAllAxis
();
LogUtil
.
info
(
"料仓运转OFF完成"
);
}
private
void
回待机点
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
if
(
store
.
runStatus
>=
StoreRunStatus
.
HomeMoving
)
{
if
(
store
.
MoveInfo
.
MoveType
.
Equals
(
MoveType
.
None
)
&&
store
.
alarmType
.
Equals
(
StoreAlarmType
.
None
))
{
store
.
MoveToP1
();
}
else
{
MessageBox
.
Show
(
"无报警,无出入库或者重置操作时,才可以回待机点!"
);
}
}
else
{
MessageBox
.
Show
(
"请先启动料仓!"
);
}
}
}
private
void
chbAuto_CheckedChanged
(
object
sender
,
EventArgs
e
)
{
if
(!
LoadOk
)
...
...
@@ -563,23 +472,7 @@ namespace OnlineStore.TinPasteStore
}
}
//private void btnUpdown_Click(object sender, EventArgs e)
//{
// string PortName = store.Config.UpDown_Axis.DeviceName;
// int slvAddr = store.Config.UpDown_Axis.GetAxisValue();
// string ioIP = "192.168.200.13";
// int ioIndex = 0;
// // if (store.Config.StoreDIList.ContainsKey(IO_Type.UpdownPositionSingal))
// if (store.Config.StoreDIList.ContainsKey(IO_Type.TinCheck_Fixture))
// {
// ioIP = store.Config.StoreDIList[IO_Type.TinCheck_Fixture].IO_IP;
// ioIndex = store.Config.StoreDIList[IO_Type.TinCheck_Fixture].GetIOAddr();
// }
// FrmPositionTool frm = new FrmPositionTool(PortName, slvAddr, ioIP, ioIndex);
// frm.ShowDialog();
// LogUtil.logBox = this.richTextBox1;
//}
#
endregion
...
...
@@ -622,14 +515,7 @@ namespace OnlineStore.TinPasteStore
{
ExitApp
();
}
private
void
btnCodeLearn_Click
(
object
sender
,
EventArgs
e
)
{
IOManager
.
IOMove
(
IO_Type
.
Camera_Led
,
IO_VALUE
.
HIGH
);
CodeLibrary
.
FrmCodeDecode
frm
=
new
FrmCodeDecode
();
frm
.
ShowDialog
();
IOManager
.
IOMove
(
IO_Type
.
Camera_Led
,
IO_VALUE
.
LOW
);
}
private
void
btnClearL_Click
(
object
sender
,
EventArgs
e
)
{
...
...
@@ -649,44 +535,61 @@ namespace OnlineStore.TinPasteStore
axisMoveControl1
.
Enabled
=
status
;
groupInout
.
Enabled
=
status
;
}
private
void
rdbLeft_CheckedChanged
(
object
sender
,
EventArgs
e
)
}
private
void
btnOpenLed_Click
(
object
sender
,
EventArgs
e
)
{
// ShowSPosition();
}
private
void
btnDoorPSave_Click
(
object
sender
,
EventArgs
e
)
string
ip
=
txtLedIp
.
Text
;
int
index
=
FormUtil
.
GetIntValue
(
txtLedIndex
);
int
dmxId
=
(
int
)
numYu
.
Value
;
LEDManager
.
GetLedModule
(
ip
).
LightOn
(
Light
.
DefaultLight
(
dmxId
,
index
));
}
private
void
trackBar1_ValueChanged
(
object
sender
,
EventArgs
e
)
{
//更新缓存
bool
result
=
StoreManager
.
UpdateBoxConfig
(
store
.
Config
);
if
(!
result
)
if
(!
trackBar1
.
Value
.
Equals
(
Light
.
defaultR
))
{
MessageBox
.
Show
(
"仓门/搅拌/待机 位置保存失败 "
)
;
Light
.
defaultR
=
(
byte
)
trackBar1
.
Value
;
}
else
lblR
.
Text
=
Light
.
defaultR
.
ToString
();
}
private
void
trackBar2_ValueChanged
(
object
sender
,
EventArgs
e
)
{
if
(!
trackBar2
.
Value
.
Equals
(
Light
.
defaultG
))
{
MessageBox
.
Show
(
"仓门/搅拌/待机 位置保存成功 "
)
;
Light
.
defaultG
=
(
byte
)
trackBar2
.
Value
;
}
}
lblG
.
Text
=
Light
.
defaultG
.
ToString
();
}
p
ublic
int
getCount
(
int
[]
A
)
p
rivate
void
trackBar3_ValueChanged
(
object
sender
,
EventArgs
e
)
{
int
i
=
0
;
for
(
int
nSize
=
0
;
nSize
<
A
.
Length
;
nSize
++)
if
(!
trackBar3
.
Value
.
Equals
(
Light
.
defaultB
))
{
if
(
A
[
nSize
]
!=
0
)
{
int
temp
=
A
[
0
];
A
[
0
]
=
A
[
nSize
];
A
[
nSize
]
=
temp
;
i
++;
}
Light
.
defaultB
=
(
byte
)
trackBar3
.
Value
;
}
return
i
;
lblB
.
Text
=
Light
.
defaultB
.
ToString
();
}
private
void
btnCloseLed_Click
(
object
sender
,
EventArgs
e
)
{
string
ip
=
txtLedIp
.
Text
;
int
index
=
FormUtil
.
GetIntValue
(
txtLedIndex
);
int
dmxId
=
(
int
)
numYu
.
Value
;
LEDManager
.
GetLedModule
(
ip
).
LightOff
(
Light
.
DefaultLight
(
dmxId
,
index
));
}
private
void
btOAll_Click
(
object
sender
,
EventArgs
e
)
{
string
ip
=
txtLedIp
.
Text
;
LEDManager
.
GetLedModule
(
ip
).
AllLightOn
(
Light
.
DefaultLight
(
0
,
0
));
}
private
void
btnCAll_Click
(
object
sender
,
EventArgs
e
)
{
string
ip
=
txtLedIp
.
Text
;
LEDManager
.
GetLedModule
(
ip
).
AllLightOn
(
Light
.
DefaultLight
(
0
,
0
));
}
}
}
source/VerticalStoreClinet/useControl/AxisMoveControl.cs
查看文件 @
e178b7d
...
...
@@ -19,6 +19,7 @@ namespace OnlineStore.ACPackingStore
public
partial
class
AxisMoveControl
:
UserControl
{
private
List
<
ConfigMoveAxis
>
axisList
=
new
List
<
ConfigMoveAxis
>();
private
List
<
AxisBean
>
axisBeans
=
new
List
<
AxisBean
>();
private
VerticalStoreBean
BoxBean
=
null
;
private
string
PortName
=
""
;
private
int
SlvAddr
=
0
;
...
...
@@ -31,7 +32,7 @@ namespace OnlineStore.ACPackingStore
{
this
.
BoxBean
=
boxBean
;
axisList
=
new
List
<
ConfigMoveAxis
>(
moveAxis
);
axisBeans
=
new
List
<
AxisBean
>()
{
BoxBean
.
MiddleAxis
};
if
(
axisList
.
Count
>
0
)
{
comboBox1
.
Items
.
Clear
();
...
...
@@ -50,33 +51,34 @@ namespace OnlineStore.ACPackingStore
private
void
btnOpenAxis_Click
(
object
sender
,
EventArgs
e
)
{
int
bro
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
ACBaudRate
);
LogUtil
.
info
(
"点击【打开伺服】,端口号【"
+
PortName
+
"】地址【"
+
SlvAddr
+
"】波特率【"
+
bro
+
"】 "
);
ACServerManager
.
OpenPort
(
PortName
,
bro
);
ACServerManager
.
AlarmClear
(
PortName
,
SlvAddr
);
Thread
.
Sleep
(
100
);
ACServerManager
.
ServoOn
(
PortName
,
SlvAddr
);
LogUtil
.
info
(
"点击【打开伺服】,端口号【"
+
PortName
+
"】地址【"
+
SlvAddr
+
"】波特率【"
+
bro
+
"】 "
);
//ACServerManager.OpenPort(PortName, bro);
//ACServerManager.AlarmClear(PortName, SlvAddr);
//Thread.Sleep(100);
//ACServerManager.ServoOn(PortName, SlvAddr);
int
index
=
comboBox1
.
SelectedIndex
;
string
msg
=
""
;
bool
result
=
axisBeans
[
index
].
Open
(
false
,
out
msg
);
if
(!
result
)
{
MessageBox
.
Show
(
msg
);
}
}
private
void
btnCloseAxis_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
"点击【关闭伺服】,端口号【"
+
PortName
+
"】地址【"
+
SlvAddr
+
"】 "
);
ACServerManager
.
ServoOff
(
PortName
,
SlvAddr
);
// ACServerManager.ServoOff(PortName, SlvAddr);
int
index
=
comboBox1
.
SelectedIndex
;
axisBeans
[
index
].
ServoOff
();
}
private
bool
AxisCanMove
()
private
bool
AxisCanMove
()
{
//if (BoxBean.Config.Middle_Axis.IsSameAxis(PortName, SlvAddr) || BoxBean.Config.UpDown_Axis.IsSameAxis(PortName, SlvAddr))
//{
// int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
// int currValue = ACServerManager.GetActualtPosition(BoxBean.Config.InOut_Axis.DeviceName, BoxBean.Config.InOut_Axis.GetAxisValue());
// //旋转轴和升降轴运动时,叉子必须在待机位
// if (currValue > InOutDefaultPosition)
// {
// MessageBox.Show("叉子不在待机位,请先将叉子退回待机位(" + InOutDefaultPosition + ")", "警告(叉子在待机位时,才能移动升降轴和旋转轴) ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
// return false;
// }
//}
if
(
IOManager
.
IOValue
(
IO_Type
.
SafetyLightCurtains
).
Equals
(
IO_VALUE
.
LOW
))
{
return
false
;
}
return
true
;
}
private
void
btnAxisAMove_Click
(
object
sender
,
EventArgs
e
)
...
...
source/VerticalStoreClinet/记录.txt
查看文件 @
e178b7d
在RC1258-ACSingleStore基础上,
新建锡膏料仓 TinPasteStore
21 锡膏储存/回温/搅拌柜 SO435 1261 TinPasteStore
搅拌轴旋转时 定位气缸必须在上升端。
复位完成后,回温区旋转轴和冷藏区旋转轴需要匀速旋转
\ No newline at end of file
新建VerticalStore
RC1275-SO479-垂直循环料柜
垂直料柜,出库:从服务器查找出库,发posId给客户端。
门打开后,操作人员拿走料盒,点关门按钮关门
入库:服务器点入库按钮->选择物料种类(大料盒或者小料盒)->输入物料名称->发送posId给客户端开始入库
门打开后,操作人员放入料盒,点关门按钮关门
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论