Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC30-AutoInOutStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit f2affbe0
由
几米阳光
编写于
2019-01-16 16:38:14 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
批量上料轴增加单独处理。增加版本号。
1 个父辈
f21554bd
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
154 行增加
和
547 行删除
doc/设备IP地址分配.xlsx
source/ACSingleStore/FrmBase.cs
source/ACSingleStore/FrmStoreBox.cs
source/ACSingleStore/Properties/AssemblyInfo.cs
source/ACSingleStore/记录.txt
source/DeviceLibrary/DeviceLibrary.csproj
source/DeviceLibrary/PanasonicServo/BatchAxisController.cs
source/DeviceLibrary/ShuoKe/ShuoKeControls.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Partial.cs
source/DeviceLibrary/acSingleStore/AutomaticBaiting.cs
source/DeviceLibrary/acSingleStore/AutomaticBaiting_Partial.cs
source/DeviceLibrary/store/model/StoreMoveInfo.cs
doc/设备IP地址分配.xlsx
查看文件 @
f2affbe
此文件类型无法预览
source/ACSingleStore/FrmBase.cs
查看文件 @
f2affbe
...
@@ -13,6 +13,33 @@ namespace OnlineStore.AutoInOutStore
...
@@ -13,6 +13,33 @@ namespace OnlineStore.AutoInOutStore
{
{
public
partial
class
FrmBase
:
Form
public
partial
class
FrmBase
:
Form
{
{
public
static
string
GetVersion
()
{
string
str
=
""
;
string
version
=
""
;
DateTime
newData
=
DateTime
.
Parse
(
"2000-01-01"
);
try
{
version
=
System
.
Reflection
.
Assembly
.
GetExecutingAssembly
().
GetName
().
Version
.
ToString
();
string
[]
strArray
=
version
.
Split
(
'.'
);
if
(
strArray
.
Length
.
Equals
(
4
))
{
int
days
=
Convert
.
ToInt32
(
strArray
[
2
]);
int
seconds
=
Convert
.
ToInt32
(
strArray
[
3
]);
DateTime
d1
=
DateTime
.
Parse
(
"2000-01-01"
);
newData
=
d1
.
AddDays
(
days
);
newData
=
newData
.
AddSeconds
(
seconds
*
2
);
str
=
newData
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
}
}
catch
(
Exception
ex
)
{
str
=
version
;
LogUtil
.
error
(
"解析版本号【"
+
str
+
"】出错:"
+
ex
.
ToString
());
}
LogUtil
.
info
(
"版本号["
+
version
+
"]["
+
str
+
"]"
);
return
str
;
}
public
FrmBase
()
public
FrmBase
()
{
{
InitializeComponent
();
InitializeComponent
();
...
...
source/ACSingleStore/FrmStoreBox.cs
查看文件 @
f2affbe
...
@@ -147,7 +147,7 @@ namespace OnlineStore.AutoInOutStore
...
@@ -147,7 +147,7 @@ namespace OnlineStore.AutoInOutStore
private
bool
LoadOk
=
false
;
private
bool
LoadOk
=
false
;
private
void
FrmTest_Load
(
object
sender
,
EventArgs
e
)
private
void
FrmTest_Load
(
object
sender
,
EventArgs
e
)
{
{
GetVersion
();
LogUtil
.
logBox
=
this
.
richTextBox1
;
LogUtil
.
logBox
=
this
.
richTextBox1
;
this
.
ShowInTaskbar
=
true
;
this
.
ShowInTaskbar
=
true
;
this
.
Text
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
App_Title
);
this
.
Text
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
App_Title
);
...
...
source/ACSingleStore/Properties/AssemblyInfo.cs
查看文件 @
f2affbe
...
@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
...
@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
//
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// 方法是按如下所示使用“*”:
//
[assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.*"
)]
[assembly: AssemblyVersion("1.0.0.0")]
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//
[assembly: AssemblyFileVersion("1.0.0.0")]
source/ACSingleStore/记录.txt
查看文件 @
f2affbe
...
@@ -109,6 +109,12 @@ PRO,最后一盘料需要补充的高度,LastTrayAddHeight,10,,,,,,,,,
...
@@ -109,6 +109,12 @@ PRO,最后一盘料需要补充的高度,LastTrayAddHeight,10,,,,,,,,,
20190111修改
1.波特率改为可配置模式。
2.松下伺服通信改为兼容模式。
3.批量上料轴上升过程中,新建一个线程用来验证是否需要停止。
...
...
source/DeviceLibrary/DeviceLibrary.csproj
查看文件 @
f2affbe
...
@@ -67,6 +67,7 @@
...
@@ -67,6 +67,7 @@
<Compile Include="PanasonicServo\ACCMDManager.cs" />
<Compile Include="PanasonicServo\ACCMDManager.cs" />
<Compile Include="PanasonicServo\ACServerManager.cs" />
<Compile Include="PanasonicServo\ACServerManager.cs" />
<Compile Include="PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="PanasonicServo\BatchAxisController.cs" />
<Compile Include="ShuoKe\MeteringSignalBean.cs" />
<Compile Include="ShuoKe\MeteringSignalBean.cs" />
<Compile Include="ShuoKe\ShuoKeController.cs" />
<Compile Include="ShuoKe\ShuoKeController.cs" />
<Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineMoveP.cs" />
...
...
source/DeviceLibrary/PanasonicServo/BatchAxisController.cs
0 → 100644
查看文件 @
f2affbe
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
OnlineStore.DeviceLibrary
{
/// <summary>
/// 批量上下料 轴,检测料盘检测信号处理
/// </summary>
public
class
BatchAxisController
{
private
static
bool
IsStop
=
false
;
private
static
System
.
Timers
.
Timer
checkTimer
=
null
;
public
static
bool
StartCheck
()
{
if
(
checkTimer
==
null
)
{
checkTimer
=
new
System
.
Timers
.
Timer
();
checkTimer
.
AutoReset
=
true
;
checkTimer
.
Interval
+=
50
;
checkTimer
.
Elapsed
+=
CheckTimer_Elapsed
;
}
checkTimer
.
Start
();
return
true
;
}
public
static
bool
StopCheck
()
{
if
(!(
checkTimer
==
null
))
{
checkTimer
.
Stop
();
}
return
true
;
}
private
static
bool
IsInProcess
=
false
;
private
static
void
CheckTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
if
(
IsInProcess
)
{
return
;
}
IsInProcess
=
true
;
bool
result
=
false
;
if
(
KND
.
IOValue
(
LoadCSVLibrary
.
IO_Type
.
TrayCheck_LoadMaterial
).
Equals
(
IO_VALUE
.
HIGH
))
{
LogUtil
.
info
(
"批量上料轴,检测到上料机构料盘信号,可以停止运动"
);
result
=
true
;
}
else
if
(
ACServerManager
.
GetLimitPositiveSingle
(
StoreManager
.
Config
.
Batch_Axis
).
Equals
(
1
))
{
LogUtil
.
info
(
"批量上料轴,检测到正极限信号,可以停止运动"
);
result
=
true
;
}
if
(
result
)
{
//AutoAxisIsMove = 0;
LogUtil
.
debug
(
"批量上料轴, 停止运动"
);
ACServerManager
.
SuddenStop
(
StoreManager
.
Config
.
Batch_Axis
.
DeviceName
,
StoreManager
.
Config
.
Batch_Axis
.
GetAxisValue
());
StopCheck
();
}
IsInProcess
=
true
;
}
}
}
source/DeviceLibrary/ShuoKe/ShuoKeControls.cs
deleted
100644 → 0
查看文件 @
f21554b
using
log4net
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.IO.Ports
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
namespace
OnlineStore.DeviceLibrary
{
/// <summary>
/// 硕科控制模块代码
/// </summary>
public
class
ShuoKeControls
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
private
static
SerialBean
bean
=
null
;
public
static
bool
isRun
=
false
;
private
static
Dictionary
<
int
,
ShuoKeInfo
>
shuokeMap
=
new
Dictionary
<
int
,
ShuoKeInfo
>();
#
region
串口操作
public
static
bool
ResertInitPort
(
string
comPortName
,
int
baudRate
,
int
tparity
,
int
dataBits
,
StopBits
stopBits
)
{
if
(
isRun
)
{
ClosePort
();
}
return
InitPort
(
comPortName
,
baudRate
,
tparity
,
dataBits
,
stopBits
);
}
public
static
bool
InitPort
(
string
comPortName
,
int
baudRate
,
int
tparity
,
int
dataBits
,
StopBits
stopBits
)
{
if
(
isRun
)
{
return
true
;
}
try
{
Parity
parity
=
(
Parity
)
tparity
;
bean
=
new
SerialBean
(
comPortName
,
baudRate
,
parity
,
8
,
stopBits
);
bool
result
=
bean
.
openPort
();
if
(!
result
)
{
return
false
;
}
bean
.
DataReceived
+=
DataReceived
;
isRun
=
true
;
}
catch
(
Exception
ex
)
{
isRun
=
false
;
LogUtil
.
error
(
LOGGER
,
"打开步进控制器串口失败:"
+
ex
.
ToString
());
return
false
;
}
return
true
;
}
public
static
void
ClosePort
()
{
isRun
=
false
;
bean
.
closePort
();
LogUtil
.
info
(
LOGGER
,
"关闭步进控制器串口完成"
);
}
public
static
void
SendData
(
byte
[]
data
)
{
string
strSend
=
""
;
for
(
int
i
=
0
;
i
<
data
.
Length
;
i
++)
{
strSend
+=
string
.
Format
(
"{0:X2} "
,
data
[
i
]);
}
if
(
strSend
.
Equals
(
""
))
{
return
;
}
if
(!
isRun
)
{
LogUtil
.
error
(
LOGGER
,
"电机发送数据【"
+
strSend
+
"】,当前串口未连接上,发送失败!"
);
return
;
}
LogUtil
.
debug
(
LOGGER
,
"电机发送数据【"
+
strSend
+
"】"
);
bean
.
SendData
(
data
,
0
,
data
.
Length
);
}
private
static
void
DataReceived
(
string
portName
,
object
sender
,
SerialDataReceivedEventArgs
e
,
byte
[]
bits
)
{
string
strSend
=
""
;
for
(
int
i
=
0
;
i
<
bits
.
Length
;
i
++)
{
strSend
+=
string
.
Format
(
"{0:X2} "
,
bits
[
i
]);
}
if
(
strSend
.
Equals
(
""
))
{
return
;
}
//校验
ushort
pChecksum
=
0
;
AcSerialBean
.
CalculateCRC
(
bits
,
bits
.
Length
-
2
,
out
pChecksum
);
string
checkStr
=
Convert
.
ToString
(
pChecksum
,
16
);
byte
[]
checkByte
=
AcSerialBean
.
StringToByte
(
checkStr
);
if
(
checkByte
.
Length
==
1
)
{
if
(!
bits
[
bits
.
Length
-
2
].
Equals
(
checkByte
[
0
]))
{
bean
.
clearInBuffer
();
LogUtil
.
info
(
LOGGER
,
"收到数据:端口号 【"
+
portName
+
"】 数据【"
+
strSend
+
"】,校验错误"
);
return
;
}
}
else
{
if
(!
bits
[
bits
.
Length
-
1
].
Equals
(
checkByte
[
0
])
||
(!
bits
[
bits
.
Length
-
2
].
Equals
(
checkByte
[
1
])))
{
bean
.
clearInBuffer
();
LogUtil
.
info
(
LOGGER
,
"收到数据:端口号 【"
+
portName
+
"】 数据【"
+
strSend
+
"】,校验错误"
);
return
;
}
}
LogUtil
.
debug
(
LOGGER
,
"收到数据:端口号 【"
+
portName
+
"】 数据【"
+
strSend
+
"】"
);
int
slvAddr
=
(
int
)
bits
[
0
];
byte
cmd
=
bits
[
1
];
//查询状态
if
(
cmd
.
Equals
(
ShuoKeCMD
.
SearchMoveStatus
))
{
//[数据1]:1表示运动中,0表示停止
//[数据2]:LL-左限位IO状态 1表示有效 0表示无效
//[数据3]:O-原点IO状态 1表示有效 0表示无效,,=1表示原点灭,=0表示当前原点亮
// [数据4]:RL-右限位IO状态 1表示有效 0表示无效
//[数据5]:EN-使能IO状态 1表示有效 0表示无效
int
isInMove
=
bits
[
3
];
int
isLLimit
=
bits
[
4
];
int
isOrg
=
bits
[
5
];
int
isRLimit
=
bits
[
6
];
int
isEn
=
bits
[
7
];
try
{
ShuoKeInfo
info
=
new
ShuoKeInfo
(
isInMove
,
slvAddr
,
isLLimit
,
isOrg
,
isRLimit
,
isEn
);
if
(
shuokeMap
.
ContainsKey
(
slvAddr
))
{
info
.
LastPosition
=
shuokeMap
[
slvAddr
].
LastPosition
;
shuokeMap
.
Remove
(
slvAddr
);
}
shuokeMap
.
Add
(
slvAddr
,
info
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
LOGGER
,
"记录状态出错:"
+
ex
.
ToString
());
}
LogUtil
.
debug
(
LOGGER
,
"收到驱动器【"
+
slvAddr
+
"】运动状态:运动【"
+
isInMove
+
"】左限位【"
+
isLLimit
+
"】右限位【"
+
isRLimit
+
"】原点【"
+
isOrg
+
"】使能【"
+
isEn
+
"】"
);
}
else
if
(
cmd
.
Equals
(
ShuoKeCMD
.
GetAbsPosition
))
{
byte
[]
positionData
=
new
byte
[
4
];
Array
.
Copy
(
bits
,
3
,
positionData
,
0
,
4
);
string
a
=
SerialBean
.
byteToHexStr
(
positionData
);
int
absValue
=
Convert
.
ToInt32
(
a
,
16
);
LogUtil
.
info
(
LOGGER
,
"收到驱动器【"
+
slvAddr
+
"】绝对位置【"
+
absValue
+
"】"
);
if
(
shuokeMap
.
ContainsKey
(
slvAddr
))
{
shuokeMap
[
slvAddr
].
LastPosition
=
absValue
;
}
else
{
ShuoKeInfo
info
=
new
ShuoKeInfo
(
slvAddr
,
absValue
);
shuokeMap
.
Add
(
slvAddr
,
info
);
}
}
}
public
static
int
GetLastPosition
(
int
slvAddr
)
{
if
(
shuokeMap
.
ContainsKey
(
slvAddr
))
{
ShuoKeInfo
info
=
shuokeMap
[
slvAddr
];
return
info
.
LastPosition
;
}
return
-
1
;
}
#
endregion
#
region
流水线逻辑判断
public
static
bool
IsMoveEnd
(
int
slvAddr
,
DateTime
time
,
out
ShuoKeInfo
shuokeInfo
)
{
shuokeInfo
=
null
;
if
(
shuokeMap
.
ContainsKey
(
slvAddr
))
{
ShuoKeInfo
info
=
shuokeMap
[
slvAddr
];
shuokeInfo
=
info
;
if
(
info
.
IsInMove
==
0
&&
info
.
UpdateTime
>
time
)
{
return
true
;
}
}
return
false
;
}
public
static
bool
IsHomeMoveEnd
(
int
slvAddr
,
DateTime
time
,
out
ShuoKeInfo
shuokeInfo
)
{
shuokeInfo
=
null
;
if
(
shuokeMap
.
ContainsKey
(
slvAddr
))
{
ShuoKeInfo
info
=
shuokeMap
[
slvAddr
];
shuokeInfo
=
info
;
if
(
info
.
IsInMove
==
0
&&
info
.
UpdateTime
>
time
&&
info
.
Org
==
0
)
{
return
true
;
}
}
return
false
;
}
#
endregion
#
region
驱动器操作方法
public
static
void
GetStatus
(
int
slvAddr
)
{
byte
[]
sendData
=
WriteData
(
slvAddr
,
ShuoKeCMD
.
SearchMoveStatus
,
0x00
,
0
);
}
public
static
void
DStoop
(
int
slvAddr
)
{
byte
[]
sendData
=
WriteData
(
slvAddr
,
ShuoKeCMD
.
DStopMove
,
0x00
,
0
);
}
public
static
void
SuddownStop
(
int
slvAddr
)
{
byte
[]
sendData
=
WriteData
(
slvAddr
,
ShuoKeCMD
.
SuddownStopMove
,
0x00
,
0
);
}
public
static
void
GetABSPosition
(
int
slvAddr
)
{
byte
[]
sendData
=
WriteData
(
slvAddr
,
ShuoKeCMD
.
GetAbsPosition
,
0x00
,
0
);
}
/// <summary>
///
/// </summary>
/// <param name="slvAddr"></param>
/// <param name="homeType">0=反方向,1=正方向</param>
public
static
void
HomeMove
(
int
slvAddr
,
byte
homeType
)
{
string
fangx
=
homeType
.
Equals
(
0
)
?
"反方向"
:
"正方向"
;
LogUtil
.
info
(
"压紧轴原点返回:"
+
fangx
);
byte
[]
sendData
=
WriteData
(
slvAddr
,
ShuoKeCMD
.
HomeMove
,
0x01
,
homeType
);
Thread
.
Sleep
(
100
);
}
public
static
void
SetConfigSpeed
(
AUTO_SA_Config
Config
)
{
ShuoKeControls
.
SetSpeed
(
Config
.
CompressAxis_Slv
,
ShuoKeCMD
.
SetAddSpeed
,
Config
.
CompressAxis_AddSpeed
);
Thread
.
Sleep
(
60
);
ShuoKeControls
.
SetSpeed
(
Config
.
CompressAxis_Slv
,
ShuoKeCMD
.
SetDelSpeed
,
Config
.
CompressAxis_DelSpeed
);
Thread
.
Sleep
(
60
);
ShuoKeControls
.
SetSpeed
(
Config
.
CompressAxis_Slv
,
ShuoKeCMD
.
SetEndSpeed
,
Config
.
CompressAxis_EndSpeed
);
Thread
.
Sleep
(
60
);
ShuoKeControls
.
SetSpeed
(
Config
.
CompressAxis_Slv
,
ShuoKeCMD
.
SetHomeSpeed
,
Config
.
CompressAxis_HomeSpeed
);
Thread
.
Sleep
(
60
);
ShuoKeControls
.
SetSpeed
(
Config
.
CompressAxis_Slv
,
ShuoKeCMD
.
SetMaxSpeed
,
Config
.
CompressAxis_MaxSpeed
);
Thread
.
Sleep
(
60
);
ShuoKeControls
.
SetSpeed
(
Config
.
CompressAxis_Slv
,
ShuoKeCMD
.
SetStartSpeed
,
Config
.
CompressAxis_StartSpeed
);
}
public
static
void
VolMove
(
int
slvAddr
,
int
speed
)
{
byte
[]
sendData
=
WriteData
(
slvAddr
,
ShuoKeCMD
.
VolMove
,
0x04
,
speed
);
}
public
static
void
AbsMove
(
int
slvAddr
,
int
TargetPosition
)
{
// 47、设置绝对位置并开始运动:不支持广播(开环的32位脉冲统计长度)
//正负数表示绝对位置,如果已经到位置,则不做运动。(M4505S特有命令)
//发送: 应答:
//[设备地址] 0x01 [设备地址] 0x01
//[命令] 0x50 [命令] 0x50
//[数据长度] 4 [数据长度] 0
//[数据] xxxxxxxx [数据] 无
//[CRC校验1] 0xnn [CRC校验1] 0xnn
//[CRC校验2] 0xnn [CRC校验2] 0xnn
//数据:4BYTE,(支持32位有符号脉冲位置)
byte
[]
sendData
=
WriteData
(
slvAddr
,
ShuoKeCMD
.
AbsMove
,
0x04
,
TargetPosition
);
}
public
static
void
RelativeMove
(
int
slvAddr
,
int
position
)
{
//1是正方向
byte
fangxiang
=
0x01
;
if
(
position
<
0
)
{
fangxiang
=
0x00
;
position
=
Math
.
Abs
(
position
);
}
byte
dataLength
=
0x04
;
byte
[]
sendData
=
new
byte
[
5
+
dataLength
];
sendData
[
0
]
=
(
byte
)
slvAddr
;
sendData
[
1
]
=
ShuoKeCMD
.
RelativeMove
;
sendData
[
2
]
=
dataLength
;
sendData
[
3
]
=
0x00
;
sendData
[
4
]
=
0x00
;
sendData
[
5
]
=
0x00
;
sendData
[
6
]
=
0x00
;
string
speed
=
Convert
.
ToString
(
position
,
16
);
byte
[]
speedByte
=
AcSerialBean
.
StringToByte
(
speed
);
for
(
int
i
=
0
;
i
<
speedByte
.
Length
;
i
++)
{
if
(
i
>=
4
)
{
break
;
}
sendData
[
6
-
(
speedByte
.
Length
-
1
-
i
)]
=
speedByte
[
i
];
}
sendData
[
3
]
=
fangxiang
;
sendData
=
buildCheckData
(
sendData
,
3
+
dataLength
);
SendData
(
sendData
);
}
public
static
void
PositionClear
(
int
slvAddr
,
byte
setCMD
)
{
byte
[]
sendData
=
WriteData
(
slvAddr
,
setCMD
,
0x00
,
0
);
}
/// <summary>
/// 设置电机的速度
/// </summary>
/// <param name="slvAddr">电机地址</param>
/// <param name="setCMD">设置速度的命令号</param>
/// <param name="speedValue">速度值</param>
public
static
void
SetSpeed
(
int
slvAddr
,
byte
setCMD
,
int
speedValue
)
{
byte
[]
sendData
=
WriteData
(
slvAddr
,
setCMD
,
0x04
,
speedValue
);
}
private
static
byte
[]
WriteData
(
int
slvAddr
,
byte
cmd
,
byte
dataLength
,
int
dataValue
)
{
byte
[]
sendData
=
new
byte
[
5
+
dataLength
];
sendData
[
0
]
=
(
byte
)
slvAddr
;
sendData
[
1
]
=
cmd
;
sendData
[
2
]
=
dataLength
;
if
(
dataLength
.
Equals
(
0x00
))
{
}
else
if
(
dataLength
.
Equals
(
0x01
))
{
sendData
[
3
]
=
(
byte
)
dataValue
;
}
else
if
(
dataLength
.
Equals
(
0x04
))
{
sendData
[
3
]
=
0x00
;
sendData
[
4
]
=
0x00
;
sendData
[
5
]
=
0x00
;
sendData
[
6
]
=
0x00
;
string
speed
=
Convert
.
ToString
(
dataValue
,
16
);
byte
[]
speedByte
=
AcSerialBean
.
StringToByte
(
speed
);
for
(
int
i
=
0
;
i
<
speedByte
.
Length
;
i
++)
{
if
(
i
>=
4
)
{
break
;
}
sendData
[
6
-
(
speedByte
.
Length
-
1
-
i
)]
=
speedByte
[
i
];
}
}
sendData
=
buildCheckData
(
sendData
,
3
+
dataLength
);
SendData
(
sendData
);
return
sendData
;
}
private
static
byte
[]
buildCheckData
(
byte
[]
sendData
,
int
length
)
{
ushort
pChecksum
=
0
;
AcSerialBean
.
CalculateCRC
(
sendData
,
length
,
out
pChecksum
);
string
checkStr
=
Convert
.
ToString
(
pChecksum
,
16
);
byte
[]
checkByte
=
AcSerialBean
.
StringToByte
(
checkStr
);
if
(
checkByte
.
Length
==
1
)
{
sendData
[
length
]
=
checkByte
[
0
];
sendData
[
length
+
1
]
=
0x00
;
}
else
{
sendData
[
length
+
1
]
=
checkByte
[
0
];
sendData
[
length
]
=
checkByte
[
1
];
}
return
sendData
;
}
#
endregion
}
public
class
ShuoKeCMD
{
/// <summary>
/// 设置运动初速度://SndHex:01 25 04 00 00 00 64 FC DE
/// </summary>
public
static
byte
SetStartSpeed
=
0x25
;
/// <summary>
/// 设置运动最大速度://SndHex:01 27 04 00 00 27 10 E6 EB
/// </summary>
public
static
byte
SetMaxSpeed
=
0x27
;
/// <summary>
/// 设置运动末速度://SndHex:01 29 04 00 00 03 E8 FD 47
/// </summary>
public
static
byte
SetEndSpeed
=
0x29
;
/// <summary>
/// 设置运动加速度://SndHex:01 2B 04 00 00 13 88 F1 4D
/// </summary>
public
static
byte
SetAddSpeed
=
0x2B
;
/// <summary>
/// 设置运动减速度://SndHex:01 2D 04 00 00 03 E8 FC C3
/// </summary>
public
static
byte
SetDelSpeed
=
0x2D
;
/// <summary>
/// 设置归零运动速度://SndHex:01 2F 04 00 00 27 10 E7 A3
/// </summary>
public
static
byte
SetHomeSpeed
=
0x2F
;
/// <summary>
/// //查找原点命令:
//SndHex:01 3E 01 00 61 84
/// </summary>
public
static
byte
HomeMove
=
0x3E
;
/// <summary>
/// 绝对位置运动//SndHex:01 50 04 FF FF D8 F0 AC 30
/// </summary>
public
static
byte
AbsMove
=
0x50
;
/// <summary>
/// 急停命令://SndHex:01 3C 00 31 00
/// </summary>
public
static
byte
SuddownStopMove
=
0x3C
;
/// <summary>
/// 减速停止命令://SndHex:01 3D 00 30 90
/// </summary>
public
static
byte
DStopMove
=
0x3D
;
/// <summary>
/// 绝对位置清零: //SndHex:01 38 00 33 C0
/// </summary>
public
static
byte
AbsPositionClear
=
0x38
;
/// <summary>
/// 相对位置清零: //SndHex:01 3A 00 32 A0
/// </summary>
public
static
byte
RelPositionClear
=
0x3A
;
/// <summary>
/// 查询运动状态://SndHex:01 3B 00 33 30
/// </summary>
public
static
byte
SearchMoveStatus
=
0x3B
;
/// <summary>
//查询设备地址://SndHex:00 21 00 69 90
/// </summary>
public
static
byte
SearchSlvAddr
=
0x21
;
/// <summary>
/// 设置32位运动速度,并恒速运动:SndHex:01 33 04 00 00 27 10 E5 FF
/// </summary>
public
static
byte
VolMove
=
0x33
;
/// <summary>
/// 查询绝对位置
/// </summary>
public
static
byte
GetAbsPosition
=
0x37
;
/// <summary>
/// 相对位置运动
/// </summary>
public
static
byte
RelativeMove
=
0x32
;
}
public
class
ShuoKeInfo
{
public
ShuoKeInfo
(
int
slv
,
int
position
)
{
this
.
IsInMove
=
0
;
this
.
SlvAddr
=
slv
;
this
.
LLimit
=
0
;
this
.
RLimit
=
0
;
this
.
Org
=
0
;
this
.
En
=
0
;
UpdateTime
=
DateTime
.
Now
;
LastPosition
=
position
;
}
public
ShuoKeInfo
(
int
ismove
,
int
slv
,
int
ll
,
int
org
,
int
rl
,
int
en
)
{
this
.
IsInMove
=
ismove
;
this
.
SlvAddr
=
slv
;
this
.
LLimit
=
ll
;
this
.
RLimit
=
rl
;
this
.
Org
=
org
;
this
.
En
=
en
;
UpdateTime
=
DateTime
.
Now
;
LastPosition
=
0
;
}
public
int
LastPosition
{
get
;
set
;
}
/// <summary>
/// 驱动器地址
/// </summary>
public
int
SlvAddr
{
get
;
set
;
}
/// <summary>
/// 是否在运动中
/// </summary>
public
int
IsInMove
{
get
;
set
;
}
/// <summary>
/// 左极限
/// </summary>
public
int
LLimit
{
get
;
set
;
}
/// <summary>
/// 右极限
/// </summary>
public
int
RLimit
{
get
;
set
;
}
/// <summary>
/// 原点信号是否有效
/// </summary>
public
int
Org
{
get
;
set
;
}
/// <summary>
/// 使能是否有效
/// </summary>
public
int
En
{
get
;
set
;
}
public
DateTime
UpdateTime
{
get
;
set
;
}
public
string
ToShowStr
()
{
return
"运动["
+
IsInMove
+
"]左限位["
+
LLimit
+
"]右限位["
+
RLimit
+
"]原点["
+
Org
+
"]使能["
+
En
+
"]["
+
UpdateTime
.
ToShortTimeString
()+
"]"
;
}
}
}
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
查看文件 @
f2affbe
...
@@ -1216,6 +1216,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -1216,6 +1216,7 @@ namespace OnlineStore.DeviceLibrary
}
}
public
override
void
StopMove
(
bool
IsCloseAxis
)
public
override
void
StopMove
(
bool
IsCloseAxis
)
{
{
BatchAxisController
.
StopCheck
();
AxisSuddenStop
();
AxisSuddenStop
();
if
(
IsHasCompress_Axis
)
if
(
IsHasCompress_Axis
)
{
{
...
@@ -1237,11 +1238,10 @@ namespace OnlineStore.DeviceLibrary
...
@@ -1237,11 +1238,10 @@ namespace OnlineStore.DeviceLibrary
LogUtil
.
info
(
LOGGER
,
StoreName
+
"StopMove"
);
LogUtil
.
info
(
LOGGER
,
StoreName
+
"StopMove"
);
KND
.
IOMove
(
IO_Type
.
Door_Down
,
IO_VALUE
.
LOW
);
KND
.
IOMove
(
IO_Type
.
Door_Down
,
IO_VALUE
.
LOW
);
KND
.
IOMove
(
IO_Type
.
Door_Up
,
IO_VALUE
.
LOW
);
KND
.
IOMove
(
IO_Type
.
Door_Up
,
IO_VALUE
.
LOW
);
AutomaticBaiting
.
StopMove
();
AutomaticBaiting
.
StopMove
();
MeteringSignal
.
StopCheck
();
MeteringSignal
.
StopCheck
();
isInPro
=
false
;
isInPro
=
false
;
}
}
...
...
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Partial.cs
查看文件 @
f2affbe
...
@@ -139,11 +139,6 @@ namespace OnlineStore.DeviceLibrary
...
@@ -139,11 +139,6 @@ namespace OnlineStore.DeviceLibrary
{
{
wait
.
IsEnd
=
ACAxisMoveIsEnd
(
wait
.
AxisInfo
,
wait
.
TargetPosition
,
wait
.
TargetSpeed
,
out
msg
);
wait
.
IsEnd
=
ACAxisMoveIsEnd
(
wait
.
AxisInfo
,
wait
.
TargetPosition
,
wait
.
TargetSpeed
,
out
msg
);
}
}
if
(!
wait
.
IsEnd
&&
(
Config
.
Batch_Axis
.
IsSameAxis
(
wait
.
AxisInfo
.
DeviceName
,
wait
.
AxisInfo
.
GetAxisValue
()))
&&
wait
.
TargetPosition
.
Equals
(
Config
.
BatchAxis_P1
))
{
wait
.
IsEnd
=
AutomaticBaiting
.
BatchAxisIsEnd
(
wait
);
}
if
(!
msg
.
Equals
(
""
))
if
(!
msg
.
Equals
(
""
))
{
{
isOk
=
false
;
isOk
=
false
;
...
@@ -183,6 +178,29 @@ namespace OnlineStore.DeviceLibrary
...
@@ -183,6 +178,29 @@ namespace OnlineStore.DeviceLibrary
{
{
wait
.
IsEnd
=
AutomaticBaiting
.
IsGetTrayGo
;
wait
.
IsEnd
=
AutomaticBaiting
.
IsGetTrayGo
;
}
}
else
if
(
wait
.
WaitType
==
(
int
)
Wait_Type
.
BatchAxisMove_10
)
{
//if ((Config.Batch_Axis.IsSameAxis(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue())) && wait.TargetPosition.Equals(Config.BatchAxis_P1))
//{
if
(!
wait
.
IsEnd
)
{
wait
.
IsEnd
=
AutomaticBaiting
.
BatchAxisIsEnd
(
wait
);
}
if
(!
wait
.
IsEnd
)
{
bool
MoveEnd
=
ACServerManager
.
GetBusyStatus
(
wait
.
AxisInfo
.
DeviceName
,
wait
.
AxisInfo
.
GetAxisValue
()).
Equals
(
0
);
int
outCount
=
ACServerManager
.
GetActualtPosition
(
wait
.
AxisInfo
.
DeviceName
,
wait
.
AxisInfo
.
GetAxisValue
());
int
errorCount
=
Math
.
Abs
(
outCount
-
wait
.
TargetPosition
);
if
(
MoveEnd
&&
errorCount
<
wait
.
AxisInfo
.
CanErrorCountMax
)
{
wait
.
IsEnd
=
true
;
}
}
if
(
wait
.
IsEnd
)
{
BatchAxisController
.
StopCheck
();
}
}
else
if
(
wait
.
WaitType
==
(
int
)
Wait_Type
.
ShuoKe_5
)
else
if
(
wait
.
WaitType
==
(
int
)
Wait_Type
.
ShuoKe_5
)
{
{
string
msg
=
""
;
string
msg
=
""
;
...
@@ -211,9 +229,9 @@ namespace OnlineStore.DeviceLibrary
...
@@ -211,9 +229,9 @@ namespace OnlineStore.DeviceLibrary
StoreMove
.
EndStepWait
();
StoreMove
.
EndStepWait
();
}
}
else
if
(
span
.
TotalSeconds
>
StoreMove
.
TimeOutSeconds
)
else
if
(
span
.
TotalSeconds
>
StoreMove
.
TimeOutSeconds
)
{
{
WarnMsg
=
"["
+
StoreMove
.
MoveStep
+
"]等待["
+
NotOkMsg
+
"]超时["
+
Math
.
Round
(
span
.
TotalSeconds
,
1
)
+
"]秒"
;
WarnMsg
=
"["
+
StoreMove
.
MoveStep
+
"]等待["
+
NotOkMsg
+
"]超时["
+
Math
.
Round
(
span
.
TotalSeconds
,
1
)
+
"]秒"
;
LogUtil
.
error
(
WarnMsg
,
15
);
LogUtil
.
error
(
WarnMsg
,
15
);
Alarm
(
StoreAlarmType
.
IoSingleTimeOut
,
""
,
WarnMsg
,
StoreMove
.
MoveType
);
Alarm
(
StoreAlarmType
.
IoSingleTimeOut
,
""
,
WarnMsg
,
StoreMove
.
MoveType
);
}
}
}
}
...
@@ -803,7 +821,11 @@ namespace OnlineStore.DeviceLibrary
...
@@ -803,7 +821,11 @@ namespace OnlineStore.DeviceLibrary
if
(
KND
.
IOValue
(
IO_Type
.
TrayCheck_LoadMaterial
).
Equals
(
IO_VALUE
.
LOW
))
if
(
KND
.
IOValue
(
IO_Type
.
TrayCheck_LoadMaterial
).
Equals
(
IO_VALUE
.
LOW
))
{
{
StoreMove
.
TimeOutSeconds
=
120
;
StoreMove
.
TimeOutSeconds
=
120
;
ACAxisMove
(
Config
.
Batch_Axis
,
Config
.
BatchAxis_P1
,
Config
.
BatchAxis_P1_Speed
);
//ACAxisMove(Config.Batch_Axis, Config.BatchAxis_P1, Config.BatchAxis_P1_Speed);
StoreMove
.
WaitList
.
Add
(
WaitResultInfo
.
WaitBatchAxisStop
(
Config
.
Batch_Axis
,
Config
.
BatchAxis_P1
));
BatchAxisController
.
StartCheck
();
Config
.
Batch_Axis
.
TargetPosition
=
Config
.
BatchAxis_P1
;
ACServerManager
.
AbsMove
(
Config
.
Batch_Axis
.
DeviceName
,
Config
.
Batch_Axis
.
GetAxisValue
(),
Config
.
BatchAxis_P1
,
Config
.
BatchAxis_P1_Speed
);
OutStoreLog
(
"出库:SO_02 批量上下料轴到P1点【"
+
Config
.
BatchAxis_P1
+
"】 "
);
OutStoreLog
(
"出库:SO_02 批量上下料轴到P1点【"
+
Config
.
BatchAxis_P1
+
"】 "
);
}
}
}
}
...
...
source/DeviceLibrary/acSingleStore/AutomaticBaiting.cs
查看文件 @
f2affbe
...
@@ -113,7 +113,8 @@ namespace OnlineStore.DeviceLibrary
...
@@ -113,7 +113,8 @@ namespace OnlineStore.DeviceLibrary
ClearOutStoreInfo
();
ClearOutStoreInfo
();
}
}
public
static
void
StopMove
()
public
static
void
StopMove
()
{
{
BatchAxisController
.
StopCheck
();
StoreMove
.
EndMove
();
StoreMove
.
EndMove
();
ClearInStoreInfo
();
ClearInStoreInfo
();
KND
.
IOMove
(
IO_Type
.
SuckingDisc_Work
,
IO_VALUE
.
LOW
);
KND
.
IOMove
(
IO_Type
.
SuckingDisc_Work
,
IO_VALUE
.
LOW
);
...
...
source/DeviceLibrary/acSingleStore/AutomaticBaiting_Partial.cs
查看文件 @
f2affbe
...
@@ -19,8 +19,9 @@ namespace OnlineStore.DeviceLibrary
...
@@ -19,8 +19,9 @@ namespace OnlineStore.DeviceLibrary
//AutoAxisIsMove = 1;
//AutoAxisIsMove = 1;
StartMovePosition
=
ACServerManager
.
GetActualtPosition
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
());
StartMovePosition
=
ACServerManager
.
GetActualtPosition
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
());
EndMovePosition
=
StartMovePosition
;
EndMovePosition
=
StartMovePosition
;
LogUtil
.
info
(
"当前坐标:"
+
StartMovePosition
+
",批量上料轴开始匀速"
+
targetSpeed
+
"上升"
);
LogUtil
.
info
(
"当前坐标:"
+
StartMovePosition
+
",批量上料轴开始匀速"
+
targetSpeed
+
"上升"
);
StoreMove
.
WaitList
.
Add
(
WaitResultInfo
.
WaitBatchAxisStop
(
moveAxis
));
StoreMove
.
WaitList
.
Add
(
WaitResultInfo
.
WaitBatchAxisStop
(
moveAxis
,
0
));
BatchAxisController
.
StartCheck
();
ACServerManager
.
SpeedMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
targetSpeed
);
ACServerManager
.
SpeedMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
targetSpeed
);
}
}
...
@@ -133,6 +134,10 @@ namespace OnlineStore.DeviceLibrary
...
@@ -133,6 +134,10 @@ namespace OnlineStore.DeviceLibrary
else
if
(
wait
.
WaitType
==
(
int
)
Wait_Type
.
BatchAxisMove_10
)
else
if
(
wait
.
WaitType
==
(
int
)
Wait_Type
.
BatchAxisMove_10
)
{
{
wait
.
IsEnd
=
BatchAxisIsEnd
(
wait
);
wait
.
IsEnd
=
BatchAxisIsEnd
(
wait
);
if
(
wait
.
IsEnd
)
{
BatchAxisController
.
StopCheck
();
}
}
}
else
if
(
wait
.
WaitType
==
(
int
)
Wait_Type
.
ScanCode_11
)
else
if
(
wait
.
WaitType
==
(
int
)
Wait_Type
.
ScanCode_11
)
{
{
...
@@ -235,17 +240,13 @@ namespace OnlineStore.DeviceLibrary
...
@@ -235,17 +240,13 @@ namespace OnlineStore.DeviceLibrary
bool
result
=
false
;
bool
result
=
false
;
if
(
KND
.
IOValue
(
IO_Type
.
TrayCheck_LoadMaterial
).
Equals
(
IO_VALUE
.
HIGH
))
if
(
KND
.
IOValue
(
IO_Type
.
TrayCheck_LoadMaterial
).
Equals
(
IO_VALUE
.
HIGH
))
{
{
LogUtil
.
info
(
wait
.
ToStr
()
+
"检测到上料机构料盘信号,可以停止运动"
);
LogUtil
.
info
(
wait
.
ToStr
()
+
"检测到上料机构料盘信号,可以停止运动"
);
result
=
true
;
result
=
true
;
}
}
else
else
if
(
ACServerManager
.
GetLimitPositiveSingle
(
wait
.
AxisInfo
).
Equals
(
1
))
{
{
int
limitP
=
ACServerManager
.
GetLimitPositiveSingle
(
wait
.
AxisInfo
);
LogUtil
.
info
(
wait
.
ToStr
()
+
"检测到正极限信号,可以停止运动"
);
if
(
limitP
.
Equals
(
1
))
result
=
true
;
{
LogUtil
.
info
(
wait
.
ToStr
()
+
"检测到正极限信号,可以停止运动"
);
result
=
true
;
}
}
}
if
(
result
)
if
(
result
)
{
{
...
...
source/DeviceLibrary/store/model/StoreMoveInfo.cs
查看文件 @
f2affbe
...
@@ -277,9 +277,10 @@ namespace OnlineStore.DeviceLibrary
...
@@ -277,9 +277,10 @@ namespace OnlineStore.DeviceLibrary
/// 10=等待批量上下料轴运动 停止
/// 10=等待批量上下料轴运动 停止
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
public
static
WaitResultInfo
WaitBatchAxisStop
(
ConfigMoveAxis
moveAxis
)
public
static
WaitResultInfo
WaitBatchAxisStop
(
ConfigMoveAxis
moveAxis
,
int
targetPosition
)
{
{
WaitResultInfo
wait
=
new
WaitResultInfo
();
WaitResultInfo
wait
=
new
WaitResultInfo
();
wait
.
TargetPosition
=
targetPosition
;
wait
.
CanWhileMoveCount
=
0
;
wait
.
CanWhileMoveCount
=
0
;
wait
.
AxisInfo
=
moveAxis
;
wait
.
AxisInfo
=
moveAxis
;
wait
.
WaitType
=
(
int
)
Wait_Type
.
BatchAxisMove_10
;
wait
.
WaitType
=
(
int
)
Wait_Type
.
BatchAxisMove_10
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论