Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
ACSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 6596eb2a
由
LN
编写于
2021-06-28 16:04:52 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
日志修改,增加运行日志:RunLogUtil
1 个父辈
fdf38543
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
38 个修改的文件
包含
648 行增加
和
149 行删除
source/ACSingleStore/App.config
source/ACSingleStore/FrmAxisDebug.cs
source/ACSingleStore/FrmIOStatus.cs
source/ACSingleStore/FrmStoreBox.cs
source/ACSingleStore/Program.cs
source/ACSingleStore/记录.txt
source/Common/Common.csproj
source/Common/packages.config
source/Common/util/AcSerialBean.cs
source/Common/util/ConfigAppSettings.cs
source/Common/util/HttpHelper.cs
source/Common/util/HumitureController.cs
source/Common/util/HumitureServer.cs
source/Common/util/LogUtil.cs
source/Common/util/NetTCPServer.cs
source/Common/util/RunLogUtil.cs
source/Common/util/ScanCodeManager.cs
source/Common/util/TcpClient.cs
source/Common/util/TcpServer.cs
source/Common/util/UdpServer.cs
source/DeviceLibrary/IO/AIOBOX/AIOBOXManager.cs
source/DeviceLibrary/IO/KangNaiDe/KNDManager.cs
source/DeviceLibrary/IO/KangNaiDe/MasterTcpClient.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Inventory.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Partial.cs
source/DeviceLibrary/acSingleStore/StoreManager.cs
source/DeviceLibrary/store/InOutParam.cs
source/DeviceLibrary/store/KTK_Store.cs
source/DeviceLibrary/store/StoreStep.cs
source/DeviceLibrary/store/model/StoreMoveInfo.cs
source/LoadCVSLibrary/CSVReaderBase.cs
source/LoadCVSLibrary/LoadCSVLibrary.csproj
source/LoadCVSLibrary/position/CSVPositionReader.cs
source/LoadCVSLibrary/storeConfig/CSVConfigReader.cs
source/LoadCVSLibrary/storeConfig/ConfigItemBase.cs
source/LoadCVSLibrary/storeConfig/config/StoreConfig.cs
source/UserFromControl/UserFromControl.csproj
source/ACSingleStore/App.config
查看文件 @
6596eb2
...
@@ -49,10 +49,28 @@
...
@@ -49,10 +49,28 @@
<
conversionPattern
value
=
"[%date][%t]%-5p %m%n"
/>
<
conversionPattern
value
=
"[%date][%t]%-5p %m%n"
/>
</
layout
>
</
layout
>
</
appender
>
</
appender
>
<
root
>
<
appender
name
=
"RunLog"
type
=
"log4net.Appender.RollingFileAppender"
>
<
file
type
=
"log4net.Util.PatternString"
value
=
"logs/log/RunLog-%property{fname}.log"
/>
<
param
name
=
"Encoding"
value
=
"UTF-8"
/>
<
appendToFile
value
=
"true"
/>
<
rollingStyle
value
=
"Date"
/>
<
datePattern
value
=
"yyyy-MM-dd"
/>
<
layout
type
=
"log4net.Layout.PatternLayout"
>
<
conversionPattern
value
=
" %m%n"
/>
</
layout
>
</
appender
>
<!--<
root
>
<
level
value
=
"Info"
/>
<
level
value
=
"Info"
/>
<
appender
-
ref
ref
=
"RollingLogFileAppender"
/>
<
appender
-
ref
ref
=
"RollingLogFileAppender"
/>
</
root
>
</
root
>-->
<
logger
name
=
"RollingLogFileAppender"
>
<
level
value
=
"Info"
/>
<
appender
-
ref
ref
=
"RollingLogFileAppender"
/>
</
logger
>
<
logger
name
=
"RunLog"
>
<
level
value
=
"Info"
/>
<
appender
-
ref
ref
=
"RunLog"
/>
</
logger
>
</
log4net
>
</
log4net
>
<
startup
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.6.1"
/>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.6.1"
/>
...
...
source/ACSingleStore/FrmAxisDebug.cs
查看文件 @
6596eb2
...
@@ -26,7 +26,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -26,7 +26,7 @@ namespace OnlineStore.ACSingleStore
private
ConfigMoveAxis
comp
=
null
;
private
ConfigMoveAxis
comp
=
null
;
//private int compress_Slv = 0;
//private int compress_Slv = 0;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public
FrmAxisDebug
(
AC_SA_BoxBean
boxBean
)
public
FrmAxisDebug
(
AC_SA_BoxBean
boxBean
)
{
{
middle
=
boxBean
.
Config
.
Middle_Axis
;
middle
=
boxBean
.
Config
.
Middle_Axis
;
...
@@ -41,7 +41,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -41,7 +41,7 @@ namespace OnlineStore.ACSingleStore
private
void
AxisMove
(
ConfigMoveAxis
axis
,
int
speed
)
private
void
AxisMove
(
ConfigMoveAxis
axis
,
int
speed
)
{
{
LogUtil
.
debug
(
LOGGER
,
"点动:deviceName="
+
axis
.
DeviceName
+
",axis="
+
axis
.
GetAxisValue
()
+
",speed="
+
speed
);
LogUtil
.
debug
(
"点动:deviceName="
+
axis
.
DeviceName
+
",axis="
+
axis
.
GetAxisValue
()
+
",speed="
+
speed
);
ACServerManager
.
SpeedMove
(
axis
.
DeviceName
,
axis
.
GetAxisValue
(),
speed
);
ACServerManager
.
SpeedMove
(
axis
.
DeviceName
,
axis
.
GetAxisValue
(),
speed
);
}
}
...
...
source/ACSingleStore/FrmIOStatus.cs
查看文件 @
6596eb2
...
@@ -24,7 +24,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -24,7 +24,7 @@ namespace OnlineStore.ACSingleStore
{
{
private
int
StoreId
=
1
;
private
int
StoreId
=
1
;
private
AC_SA_BoxBean
boxBean
;
private
AC_SA_BoxBean
boxBean
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public
FrmIOStatus
()
public
FrmIOStatus
()
{
{
Control
.
CheckForIllegalCrossThreadCalls
=
false
;
Control
.
CheckForIllegalCrossThreadCalls
=
false
;
...
@@ -96,7 +96,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -96,7 +96,7 @@ namespace OnlineStore.ACSingleStore
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
MessageBox
.
Show
(
ex
.
StackTrace
,
"Exception(异常)"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
MessageBox
.
Show
(
ex
.
StackTrace
,
"Exception(异常)"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
LogUtil
.
error
(
LOGGER
,
ex
.
StackTrace
);
LogUtil
.
error
(
ex
.
StackTrace
);
}
}
}
}
private
void
btnWriteSingleDO_Click
(
object
sender
,
EventArgs
e
)
private
void
btnWriteSingleDO_Click
(
object
sender
,
EventArgs
e
)
...
...
source/ACSingleStore/FrmStoreBox.cs
查看文件 @
6596eb2
...
@@ -27,7 +27,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -27,7 +27,7 @@ namespace OnlineStore.ACSingleStore
{
{
private
AC_SA_BoxBean
store
;
private
AC_SA_BoxBean
store
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public
FrmStoreBox
()
public
FrmStoreBox
()
{
{
Control
.
CheckForIllegalCrossThreadCalls
=
false
;
Control
.
CheckForIllegalCrossThreadCalls
=
false
;
...
@@ -75,7 +75,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -75,7 +75,7 @@ namespace OnlineStore.ACSingleStore
this
.
store
=
StoreManager
.
InitStore
();
this
.
store
=
StoreManager
.
InitStore
();
if
(
store
==
null
)
if
(
store
==
null
)
{
{
LogUtil
.
error
(
LOGGER
,
"找不到对应的料仓"
);
LogUtil
.
error
(
"找不到对应的料仓"
);
this
.
Close
();
this
.
Close
();
return
;
return
;
}
}
...
@@ -154,7 +154,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -154,7 +154,7 @@ namespace OnlineStore.ACSingleStore
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"出错:"
+
ex
.
StackTrace
);
LogUtil
.
error
(
"出错:"
+
ex
.
StackTrace
);
}
}
}
}
private
bool
preOpen
=
false
;
private
bool
preOpen
=
false
;
...
@@ -399,7 +399,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -399,7 +399,7 @@ namespace OnlineStore.ACSingleStore
if
(
ReturnCode
!=
0
)
if
(
ReturnCode
!=
0
)
{
{
MessageBox
.
Show
(
"错误码:"
+
ReturnCode
.
ToString
(),
""
,
MessageBoxButtons
.
OK
);
MessageBox
.
Show
(
"错误码:"
+
ReturnCode
.
ToString
(),
""
,
MessageBoxButtons
.
OK
);
LogUtil
.
error
(
LOGGER
,
"错误码:"
+
ReturnCode
.
ToString
());
LogUtil
.
error
(
"错误码:"
+
ReturnCode
.
ToString
());
}
}
}
}
private
void
FunctionFail
(
string
funName
,
System
.
Int32
ReturnCode
)
private
void
FunctionFail
(
string
funName
,
System
.
Int32
ReturnCode
)
...
@@ -407,7 +407,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -407,7 +407,7 @@ namespace OnlineStore.ACSingleStore
if
(
ReturnCode
!=
0
)
if
(
ReturnCode
!=
0
)
{
{
MessageBox
.
Show
(
"方法:"
+
funName
+
",错误码:"
+
ReturnCode
.
ToString
(),
""
,
MessageBoxButtons
.
OK
);
MessageBox
.
Show
(
"方法:"
+
funName
+
",错误码:"
+
ReturnCode
.
ToString
(),
""
,
MessageBoxButtons
.
OK
);
LogUtil
.
error
(
LOGGER
,
"方法:"
+
funName
+
",错误码:"
+
ReturnCode
.
ToString
());
LogUtil
.
error
(
"方法:"
+
funName
+
",错误码:"
+
ReturnCode
.
ToString
());
}
}
}
}
...
@@ -977,7 +977,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -977,7 +977,7 @@ namespace OnlineStore.ACSingleStore
store
.
AutoStartIndex
=
currIndex
;
store
.
AutoStartIndex
=
currIndex
;
string
poText
=
cmbPosition
.
Text
;
string
poText
=
cmbPosition
.
Text
;
store
.
autoMsg
=
"自动出库:"
+
poText
;
store
.
autoMsg
=
"自动出库:"
+
poText
;
LogUtil
.
info
(
LOGGER
,
store
.
StoreName
+
"开启自动出入库模式,开始位置【"
+
poText
+
"】(索引="
+
currIndex
+
"),间隔="
+
jiange
+
",入库开始!"
);
LogUtil
.
info
(
store
.
StoreName
+
"开启自动出入库模式,开始位置【"
+
poText
+
"】(索引="
+
currIndex
+
"),间隔="
+
jiange
+
",入库开始!"
);
//store.StartOutStoreMove(new InOutStoreParam("", poText));
//store.StartOutStoreMove(new InOutStoreParam("", poText));
store
.
StartInStoreMove
(
new
InOutParam
(
new
InOutPosInfo
(
"AUTOINOUT"
,
poText
)));
store
.
StartInStoreMove
(
new
InOutParam
(
new
InOutPosInfo
(
"AUTOINOUT"
,
poText
)));
}
}
...
@@ -1231,7 +1231,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -1231,7 +1231,7 @@ namespace OnlineStore.ACSingleStore
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
MessageBox
.
Show
(
ex
.
StackTrace
,
"Exception(异常)"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
MessageBox
.
Show
(
ex
.
StackTrace
,
"Exception(异常)"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
LogUtil
.
error
(
LOGGER
,
ex
.
StackTrace
);
LogUtil
.
error
(
ex
.
StackTrace
);
}
}
}
}
private
void
toolStripMenuItem1_Click
(
object
sender
,
EventArgs
e
)
private
void
toolStripMenuItem1_Click
(
object
sender
,
EventArgs
e
)
...
@@ -1499,7 +1499,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -1499,7 +1499,7 @@ namespace OnlineStore.ACSingleStore
store
.
AutoStartIndex
=
currIndex
;
store
.
AutoStartIndex
=
currIndex
;
string
poText
=
cmbPosition
.
Text
;
string
poText
=
cmbPosition
.
Text
;
store
.
autoMsg
=
"自动盘点:"
+
poText
;
store
.
autoMsg
=
"自动盘点:"
+
poText
;
LogUtil
.
info
(
LOGGER
,
store
.
StoreName
+
"开启自动盘点模式,开始位置【"
+
poText
+
"】(索引="
+
currIndex
+
"),间隔="
+
jiange
+
",盘点开始!"
);
LogUtil
.
info
(
store
.
StoreName
+
"开启自动盘点模式,开始位置【"
+
poText
+
"】(索引="
+
currIndex
+
"),间隔="
+
jiange
+
",盘点开始!"
);
//store.StartOutStoreMove(new InOutStoreParam("", poText));
//store.StartOutStoreMove(new InOutStoreParam("", poText));
store
.
StartInventoryMove
(
new
InOutParam
(
new
InOutPosInfo
(
"AUTOINOUT"
,
poText
)));
store
.
StartInventoryMove
(
new
InOutParam
(
new
InOutPosInfo
(
"AUTOINOUT"
,
poText
)));
}
}
...
...
source/ACSingleStore/Program.cs
查看文件 @
6596eb2
...
@@ -43,7 +43,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -43,7 +43,7 @@ namespace OnlineStore.ACSingleStore
public
static
extern
int
ShowWindow
(
IntPtr
hwnd
,
int
nCmdShow
);
public
static
extern
int
ShowWindow
(
IntPtr
hwnd
,
int
nCmdShow
);
public
const
int
SW_RESTORE
=
9
;
public
const
int
SW_RESTORE
=
9
;
public
static
IntPtr
formhwnd
;
public
static
IntPtr
formhwnd
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#
endregion
#
endregion
...
@@ -53,6 +53,7 @@ namespace OnlineStore.ACSingleStore
...
@@ -53,6 +53,7 @@ namespace OnlineStore.ACSingleStore
[
STAThread
]
[
STAThread
]
static
void
Main
(
string
[]
Args
)
static
void
Main
(
string
[]
Args
)
{
{
RunLogUtil
.
InoutEndLog
(
new
InoutEndLog
(
"name"
,
"type"
,
DateTime
.
Now
.
AddMinutes
(-
1
),
DateTime
.
Now
));
Application
.
ThreadException
+=
new
System
.
Threading
.
ThreadExceptionEventHandler
(
Application_ThreadException
);
Application
.
ThreadException
+=
new
System
.
Threading
.
ThreadExceptionEventHandler
(
Application_ThreadException
);
AppDomain
.
CurrentDomain
.
UnhandledException
+=
new
UnhandledExceptionEventHandler
(
CurrentDomain_UnhandledException
);
AppDomain
.
CurrentDomain
.
UnhandledException
+=
new
UnhandledExceptionEventHandler
(
CurrentDomain_UnhandledException
);
...
@@ -93,7 +94,8 @@ namespace OnlineStore.ACSingleStore
...
@@ -93,7 +94,8 @@ namespace OnlineStore.ACSingleStore
}
}
if
(!
isShow
)
if
(!
isShow
)
{
{
log4net
.
GlobalContext
.
Properties
[
"fname"
]
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_CID
);
log4net
.
GlobalContext
.
Properties
[
"fname"
]
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_CID
);
log4net
.
GlobalContext
.
Properties
[
"fname"
]
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_CID
);
log4net
.
Config
.
XmlConfigurator
.
Configure
();
log4net
.
Config
.
XmlConfigurator
.
Configure
();
System
.
Net
.
ServicePointManager
.
DefaultConnectionLimit
=
512
;
System
.
Net
.
ServicePointManager
.
DefaultConnectionLimit
=
512
;
// XmlConfigurator.Configure();
// XmlConfigurator.Configure();
...
...
source/ACSingleStore/记录.txt
查看文件 @
6596eb2
...
@@ -67,4 +67,42 @@ PRO,,拍照相机名称,PhotoCamera_Name,,,,,,,,,,,,,
...
@@ -67,4 +67,42 @@ PRO,,拍照相机名称,PhotoCamera_Name,,,,,,,,,,,,,
StoreConfig.csv需要增加一行配置:
StoreConfig.csv需要增加一行配置:
PRO,是否启用仓门口料盘检测信号,IsUse_Door_Check,1,,,,,,,,,,,
PRO,是否启用仓门口料盘检测信号,IsUse_Door_Check,1,,,,,,,,,,,
20200628 增加json日志 打印,需要修改日志配置:
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="logs/Store-%property{fname}.log" />
<param name="Encoding" value="UTF-8" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<appender name="RunLog" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="logs/log/RunLog-%property{fname}.log" />
<param name="Encoding" value="UTF-8" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value=" %m%n" />
</layout>
</appender>
<!--<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
</root>-->
<logger name="RollingLogFileAppender">
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
<logger name="RunLog">
<level value="Info" />
<appender-ref ref="RunLog" />
</logger>
</log4net>
\ No newline at end of file
\ No newline at end of file
source/Common/Common.csproj
查看文件 @
6596eb2
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.Common</RootNamespace>
<RootNamespace>OnlineStore.Common</RootNamespace>
<AssemblyName>Common</AssemblyName>
<AssemblyName>Common</AssemblyName>
<TargetFrameworkVersion>v4.
0
</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.
6.1
</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFrameworkProfile />
</PropertyGroup>
</PropertyGroup>
...
@@ -44,6 +44,10 @@
...
@@ -44,6 +44,10 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.Serialization.Primitives.4.3.0\lib\net46\System.Runtime.Serialization.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.DataSetExtensions" />
...
@@ -68,6 +72,7 @@
...
@@ -68,6 +72,7 @@
<Compile Include="util\NetTCPServer.cs">
<Compile Include="util\NetTCPServer.cs">
<SubType>Code</SubType>
<SubType>Code</SubType>
</Compile>
</Compile>
<Compile Include="util\RunLogUtil.cs" />
<Compile Include="util\ScanCodeManager.cs" />
<Compile Include="util\ScanCodeManager.cs" />
<Compile Include="util\TcpClient.cs" />
<Compile Include="util\TcpClient.cs" />
<Compile Include="util\TcpServer.cs" />
<Compile Include="util\TcpServer.cs" />
...
@@ -76,6 +81,9 @@
...
@@ -76,6 +81,9 @@
<ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
<WCFMetadata Include="Service References\" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Other similar extension points exist, see Microsoft.Common.targets.
...
...
source/Common/packages.config
0 → 100644
查看文件 @
6596eb2
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"System.Runtime.Serialization.Primitives"
version
=
"4.3.0"
targetFramework
=
"net461"
/>
</
packages
>
\ No newline at end of file
\ No newline at end of file
source/Common/util/AcSerialBean.cs
查看文件 @
6596eb2
...
@@ -12,7 +12,7 @@ namespace OnlineStore.Common
...
@@ -12,7 +12,7 @@ namespace OnlineStore.Common
public
class
AcSerialBean
public
class
AcSerialBean
{
{
#
region
全部变量
#
region
全部变量
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private
SerialPort
_serialPort
=
null
;
private
SerialPort
_serialPort
=
null
;
private
object
lockObj
=
new
object
();
private
object
lockObj
=
new
object
();
...
...
source/Common/util/ConfigAppSettings.cs
查看文件 @
6596eb2
...
@@ -12,7 +12,7 @@ namespace OnlineStore.Common
...
@@ -12,7 +12,7 @@ namespace OnlineStore.Common
{
{
public
class
ConfigAppSettings
public
class
ConfigAppSettings
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private
static
int
seq
=
1
;
private
static
int
seq
=
1
;
...
@@ -20,7 +20,7 @@ namespace OnlineStore.Common
...
@@ -20,7 +20,7 @@ namespace OnlineStore.Common
{
{
if
(
seq
.
Equals
(
Int32
.
MaxValue
))
if
(
seq
.
Equals
(
Int32
.
MaxValue
))
{
{
L
OGGER
.
I
nfo
(
"seq当前值:"
+
seq
+
",重置seq=0"
);
L
ogUtil
.
i
nfo
(
"seq当前值:"
+
seq
+
",重置seq=0"
);
seq
=
0
;
seq
=
0
;
}
}
Interlocked
.
Increment
(
ref
seq
);
Interlocked
.
Increment
(
ref
seq
);
...
@@ -78,7 +78,7 @@ namespace OnlineStore.Common
...
@@ -78,7 +78,7 @@ namespace OnlineStore.Common
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
{
L
OGGER
.
E
rror
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
L
ogUtil
.
e
rror
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
return
""
;
return
""
;
}
}
else
else
...
@@ -93,7 +93,7 @@ namespace OnlineStore.Common
...
@@ -93,7 +93,7 @@ namespace OnlineStore.Common
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
{
L
OGGER
.
E
rror
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
L
ogUtil
.
e
rror
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
return
a
;
return
a
;
}
}
else
else
...
@@ -110,7 +110,7 @@ namespace OnlineStore.Common
...
@@ -110,7 +110,7 @@ namespace OnlineStore.Common
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
{
L
OGGER
.
E
rror
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
L
ogUtil
.
e
rror
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
return
a
;
return
a
;
}
}
else
else
...
@@ -145,7 +145,7 @@ namespace OnlineStore.Common
...
@@ -145,7 +145,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"SaveValue保存配置出错:AppKey="
+
key
+
",AppValue="
+
value
+
","
+
ex
.
StackTrace
);
LogUtil
.
error
(
"SaveValue保存配置出错:AppKey="
+
key
+
",AppValue="
+
value
+
","
+
ex
.
StackTrace
);
}
}
}
}
...
@@ -167,7 +167,7 @@ namespace OnlineStore.Common
...
@@ -167,7 +167,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"UpdateConfig保存配置出错:name="
+
name
+
",Xvalue="
+
Xvalue
+
","
+
ex
.
StackTrace
);
LogUtil
.
error
(
"UpdateConfig保存配置出错:name="
+
name
+
",Xvalue="
+
Xvalue
+
","
+
ex
.
StackTrace
);
}
}
}
}
///<summary>
///<summary>
...
@@ -199,7 +199,7 @@ namespace OnlineStore.Common
...
@@ -199,7 +199,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"SetValue保存配置出错:AppKey="
+
AppKey
+
",AppValue="
+
AppValue
+
","
+
ex
.
StackTrace
);
LogUtil
.
error
(
"SetValue保存配置出错:AppKey="
+
AppKey
+
",AppValue="
+
AppValue
+
","
+
ex
.
StackTrace
);
}
}
}
}
}
}
...
...
source/Common/util/HttpHelper.cs
查看文件 @
6596eb2
...
@@ -18,7 +18,7 @@ namespace OnlineStore.Common
...
@@ -18,7 +18,7 @@ namespace OnlineStore.Common
{
{
public
class
HttpHelper
public
class
HttpHelper
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public
static
Operation
PostOP
(
string
url
,
Operation
operation
,
out
bool
isTimeOut
)
public
static
Operation
PostOP
(
string
url
,
Operation
operation
,
out
bool
isTimeOut
)
{
{
...
@@ -62,7 +62,7 @@ namespace OnlineStore.Common
...
@@ -62,7 +62,7 @@ namespace OnlineStore.Common
IsTimeOut
=
false
;
IsTimeOut
=
false
;
if
(
isLog
==
1
)
if
(
isLog
==
1
)
{
{
L
OGGER
.
I
nfo
(
"给服务器发送数据【"
+
paramData
+
"】 "
);
L
ogUtil
.
i
nfo
(
"给服务器发送数据【"
+
paramData
+
"】 "
);
}
}
string
result
=
""
;
string
result
=
""
;
...
...
source/Common/util/HumitureController.cs
查看文件 @
6596eb2
...
@@ -14,7 +14,7 @@ namespace OnlineStore.Common
...
@@ -14,7 +14,7 @@ namespace OnlineStore.Common
/// </summary>
/// </summary>
public
class
HumitureController
public
class
HumitureController
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public
static
bool
IsRun
=
false
;
public
static
bool
IsRun
=
false
;
public
static
string
serialPort
=
""
;
public
static
string
serialPort
=
""
;
...
@@ -56,7 +56,7 @@ namespace OnlineStore.Common
...
@@ -56,7 +56,7 @@ namespace OnlineStore.Common
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
LogName
+
"串口打开失败!"
);
LogUtil
.
error
(
LogName
+
"串口打开失败!"
);
IsRun
=
false
;
IsRun
=
false
;
return
false
;
return
false
;
}
}
...
@@ -236,7 +236,7 @@ namespace OnlineStore.Common
...
@@ -236,7 +236,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
L
OGGER
.
I
nfo
(
LogName
+
"转换出错:"
+
ex
.
ToString
());
L
ogUtil
.
i
nfo
(
LogName
+
"转换出错:"
+
ex
.
ToString
());
}
}
return
list
;
return
list
;
}
}
...
@@ -280,7 +280,7 @@ namespace OnlineStore.Common
...
@@ -280,7 +280,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
L
OGGER
.
I
nfo
(
LogName
+
"转换出错:"
+
ex
.
ToString
());
L
ogUtil
.
i
nfo
(
LogName
+
"转换出错:"
+
ex
.
ToString
());
}
}
return
-
1
;
return
-
1
;
}
}
...
@@ -307,7 +307,7 @@ namespace OnlineStore.Common
...
@@ -307,7 +307,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
L
OGGER
.
I
nfo
(
LogName
+
"转换出错:"
+
ex
.
ToString
());
L
ogUtil
.
i
nfo
(
LogName
+
"转换出错:"
+
ex
.
ToString
());
}
}
return
list
;
return
list
;
}
}
...
...
source/Common/util/HumitureServer.cs
查看文件 @
6596eb2
...
@@ -15,7 +15,7 @@ namespace OnlineStore.Common
...
@@ -15,7 +15,7 @@ namespace OnlineStore.Common
/// </summary>
/// </summary>
public
class
HumitureServer
public
class
HumitureServer
{
{
private
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
private static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// <summary>
/// 最后一次接受到的温度信息,key=温湿度传感器IP地址
/// 最后一次接受到的温度信息,key=温湿度传感器IP地址
...
@@ -92,7 +92,7 @@ namespace OnlineStore.Common
...
@@ -92,7 +92,7 @@ namespace OnlineStore.Common
}
}
TemperateIsStart
=
true
;
TemperateIsStart
=
true
;
temperateTcpServer
.
Start
(
port
);
temperateTcpServer
.
Start
(
port
);
LogUtil
.
info
(
LOGGER
,
"温湿度已开始在端口["
+
port
+
"]监听!"
);
LogUtil
.
info
(
"温湿度已开始在端口["
+
port
+
"]监听!"
);
temperateTcpServer
.
ReviceMsgEvent
+=
tcp_ReviceMsgEvent
;
temperateTcpServer
.
ReviceMsgEvent
+=
tcp_ReviceMsgEvent
;
}
}
}
}
...
@@ -111,7 +111,7 @@ namespace OnlineStore.Common
...
@@ -111,7 +111,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"关闭温湿度监听出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"关闭温湿度监听出错:"
+
ex
.
ToString
());
}
}
}
}
...
@@ -132,11 +132,11 @@ namespace OnlineStore.Common
...
@@ -132,11 +132,11 @@ namespace OnlineStore.Common
string
deviceId
=
strList
[
10
];
string
deviceId
=
strList
[
10
];
string
pwd
=
strList
[
11
];
string
pwd
=
strList
[
11
];
LogUtil
.
debug
(
LOGGER
,
"address="
+
add
+
",收到:温度="
+
wendu
+
",湿度="
+
shidu
+
",设备ID="
+
deviceId
+
",密码:"
+
pwd
);
LogUtil
.
debug
(
"address="
+
add
+
",收到:温度="
+
wendu
+
",湿度="
+
shidu
+
",设备ID="
+
deviceId
+
",密码:"
+
pwd
);
if
(
shidu
<=
0
)
if
(
shidu
<=
0
)
{
{
//湿度小于0不处理
//湿度小于0不处理
LogUtil
.
info
(
LOGGER
,
"address="
+
add
+
",收到:温度="
+
wendu
+
",湿度="
+
shidu
+
",设备ID="
+
deviceId
+
",密码:"
+
pwd
+
",湿度小于0不处理"
);
LogUtil
.
info
(
"address="
+
add
+
",收到:温度="
+
wendu
+
",湿度="
+
shidu
+
",设备ID="
+
deviceId
+
",密码:"
+
pwd
+
",湿度小于0不处理"
);
}
}
else
else
{
{
...
@@ -152,7 +152,7 @@ namespace OnlineStore.Common
...
@@ -152,7 +152,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
ex
.
ToString
());
LogUtil
.
error
(
ex
.
ToString
());
}
}
}
}
private
static
double
PreShiDu
=
7
;
private
static
double
PreShiDu
=
7
;
...
@@ -171,7 +171,7 @@ namespace OnlineStore.Common
...
@@ -171,7 +171,7 @@ namespace OnlineStore.Common
TemperateParamMap
.
Remove
(
IP
);
TemperateParamMap
.
Remove
(
IP
);
}
}
TemperateParamMap
.
Add
(
IP
,
ast
);
TemperateParamMap
.
Add
(
IP
,
ast
);
//LogUtil.info(
LOGGER,
"address=" + IP + ",收到:温度=" + newWenDu + ",湿度=" + newShiDu + " ");
//LogUtil.info(
"address=" + IP + ",收到:温度=" + newWenDu + ",湿度=" + newShiDu + " ");
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
...
...
source/Common/util/LogUtil.cs
查看文件 @
6596eb2
...
@@ -210,5 +210,9 @@ namespace OnlineStore.Common
...
@@ -210,5 +210,9 @@ namespace OnlineStore.Common
info
(
LOGGER
,
msg
);
info
(
LOGGER
,
msg
);
}
}
}
}
}
}
source/Common/util/NetTCPServer.cs
查看文件 @
6596eb2
...
@@ -11,7 +11,7 @@ namespace OnlineStore
...
@@ -11,7 +11,7 @@ namespace OnlineStore
{
{
public
class
NetTCPServer
public
class
NetTCPServer
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// <summary>
/// TCP服务端监听
/// TCP服务端监听
...
@@ -118,13 +118,13 @@ namespace OnlineStore
...
@@ -118,13 +118,13 @@ namespace OnlineStore
NetworkStream
ns
=
client
.
tcpClient
.
GetStream
();
NetworkStream
ns
=
client
.
tcpClient
.
GetStream
();
StreamReader
sr
=
new
StreamReader
(
ns
);
StreamReader
sr
=
new
StreamReader
(
ns
);
string
str
=
sr
.
ReadLine
();
string
str
=
sr
.
ReadLine
();
LOGGER
.
I
nfo
(
"读取到数据:"
+
str
);
Common
.
LogUtil
.
i
nfo
(
"读取到数据:"
+
str
);
byte
[]
recdata
=
new
byte
[
ns
.
EndRead
(
ar
)];
byte
[]
recdata
=
new
byte
[
ns
.
EndRead
(
ar
)];
if
(
recdata
.
Length
>
0
)
if
(
recdata
.
Length
>
0
)
{
{
//Array.Copy(client.Buffer, recdata, recdata.Length);
//Array.Copy(client.Buffer, recdata, recdata.Length);
LOGGER
.
I
nfo
(
"读取到数据1111:"
+
Encoding
.
ASCII
.
GetString
(
recdata
));
Common
.
LogUtil
.
i
nfo
(
"读取到数据1111:"
+
Encoding
.
ASCII
.
GetString
(
recdata
));
//ns.BeginRead(client.Buffer, 0, client.Buffer.Length, new AsyncCallback(TCPCallBack), client);
//ns.BeginRead(client.Buffer, 0, client.Buffer.Length, new AsyncCallback(TCPCallBack), client);
}
}
else
else
...
...
source/Common/util/RunLogUtil.cs
0 → 100644
查看文件 @
6596eb2
using
log4net
;
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Runtime.Serialization
;
using
System.Text
;
namespace
OnlineStore.Common
{
public
class
RunLogUtil
{
public
static
readonly
ILog
RunLog
=
LogManager
.
GetLogger
(
"RunLog"
);
public
static
void
ErrorLog
(
ErrorLog
log
)
{
string
jsonStr
=
JsonHelper
.
SerializeObject
(
log
);
RunLog
.
Error
(
jsonStr
);
}
public
static
void
MoveLog
(
MoveLog
log
)
{
if
(
log
==
null
||
(!
log
.
IsValid
()))
{
return
;
}
string
jsonStr
=
JsonHelper
.
SerializeObject
(
log
);
RunLog
.
Info
(
jsonStr
);
}
public
static
void
InoutEndLog
(
InoutEndLog
log
)
{
if
(
log
==
null
||
(!
log
.
IsValid
()))
{
return
;
}
string
jsonStr
=
JsonHelper
.
SerializeObject
(
log
);
RunLog
.
Info
(
jsonStr
);
}
public
static
void
AxisLog
(
AxisMoveLog
log
)
{
string
jsonStr
=
JsonHelper
.
SerializeObject
(
log
);
RunLog
.
Error
(
jsonStr
);
}
}
public
class
BaseLog
{
[
JsonProperty
(
Order
=
0
)]
public
string
Name
{
get
;
set
;
}
=
"四楼料仓"
;
[
JsonProperty
(
Order
=
1
)]
public
string
DeviceName
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
2
)]
public
string
LogType
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
3
)]
public
string
StartTime
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
4
)]
public
string
EndTime
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
5
)]
public
string
timeSpan
{
get
;
set
;
}
=
""
;
}
public
class
ErrorLog
:
BaseLog
{
public
ErrorLog
()
{
this
.
LogType
=
"Error"
;
}
public
ErrorLog
(
string
deviceName
,
string
errType
,
string
errMsg
,
DateTime
startTime
,
DateTime
endTime
,
string
operType
=
""
,
string
posid
=
""
,
string
barcode
=
""
)
{
this
.
LogType
=
"Error"
;
this
.
DeviceName
=
deviceName
.
Trim
();
this
.
ErrorType
=
errType
.
Trim
();
this
.
ErrorMsg
=
errMsg
.
Trim
();
this
.
StartTime
=
startTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
EndTime
=
endTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
OperateType
=
operType
.
Trim
();
this
.
PosId
=
posid
.
Trim
();
this
.
Barcode
=
barcode
.
Trim
();
TimeSpan
span
=
endTime
-
startTime
;
this
.
timeSpan
=
(
Math
.
Round
(
span
.
TotalMinutes
,
2
)).
ToString
();
//两位小数的分钟
}
public
bool
IsValid
()
{
if
(
string
.
IsNullOrEmpty
(
DeviceName
)||
String
.
IsNullOrEmpty
(
LogType
)
||
string
.
IsNullOrEmpty
(
ErrorType
)
||
string
.
IsNullOrEmpty
(
ErrorMsg
))
{
return
false
;
}
return
true
;
}
[
JsonProperty
(
Order
=
11
)]
public
string
ErrorType
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
12
)]
public
string
ErrorMsg
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
13
)]
public
string
OperateType
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
14
)]
public
string
PosId
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
15
)]
public
string
Barcode
{
get
;
set
;
}
=
""
;
}
public
class
MoveLog
:
BaseLog
{
public
MoveLog
()
{
this
.
LogType
=
"Running"
;
}
public
MoveLog
(
string
deviceName
,
string
moveType
,
string
moveMsg
,
DateTime
startTime
,
DateTime
endTime
,
string
posid
=
""
,
string
barcode
=
""
)
{
this
.
LogType
=
"Running"
;
this
.
DeviceName
=
deviceName
.
Replace
(
"-Move"
,
""
).
Replace
(
"-SMove"
,
""
).
Trim
();
this
.
MoveType
=
moveType
.
Trim
();
this
.
MoveMsg
=
moveMsg
.
Trim
();
this
.
StartTime
=
startTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
EndTime
=
endTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
PosId
=
posid
.
Trim
();
this
.
Barcode
=
barcode
.
Trim
();
TimeSpan
span
=
endTime
-
startTime
;
this
.
timeSpan
=
(
Math
.
Round
(
span
.
TotalMinutes
,
2
)).
ToString
();
//两位小数的分钟
}
public
bool
IsValid
()
{
if
(
string
.
IsNullOrEmpty
(
DeviceName
)
||
String
.
IsNullOrEmpty
(
LogType
)
||
string
.
IsNullOrEmpty
(
MoveType
)
||
string
.
IsNullOrEmpty
(
MoveMsg
))
{
return
false
;
}
return
true
;
}
[
JsonProperty
(
Order
=
11
)]
public
string
MoveType
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
12
)]
public
string
MoveMsg
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
13
)]
public
string
PosId
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
14
)]
public
string
Barcode
{
get
;
set
;
}
=
""
;
}
public
class
InoutEndLog
:
BaseLog
{
public
InoutEndLog
()
{
this
.
LogType
=
"InoutEnd"
;
}
public
InoutEndLog
(
string
deviceName
,
string
moveType
,
DateTime
startTime
,
DateTime
endTime
,
string
posid
=
""
,
string
barcode
=
""
)
{
this
.
LogType
=
"InoutEnd"
;
this
.
DeviceName
=
deviceName
.
Replace
(
"-Move"
,
""
).
Replace
(
"-SMove"
,
""
).
Trim
();
this
.
MoveType
=
moveType
.
Trim
();
this
.
StartTime
=
startTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
EndTime
=
endTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
PosId
=
posid
.
Trim
();
this
.
Barcode
=
barcode
.
Trim
();
TimeSpan
span
=
endTime
-
startTime
;
this
.
timeSpan
=
(
Math
.
Round
(
span
.
TotalMinutes
,
2
)).
ToString
();
//两位小数的分钟
}
public
bool
IsValid
()
{
if
(
string
.
IsNullOrEmpty
(
DeviceName
)
||
string
.
IsNullOrEmpty
(
MoveType
))
{
return
false
;
}
return
true
;
}
[
JsonProperty
(
Order
=
11
)]
public
string
MoveType
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
12
)]
public
string
PosId
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
13
)]
public
string
Barcode
{
get
;
set
;
}
=
""
;
}
public
class
AxisMoveLog
:
BaseLog
{
public
AxisMoveLog
()
{
this
.
LogType
=
"Axis"
;
}
public
AxisMoveLog
(
string
deviceName
,
string
axisName
,
string
moveType
,
int
targetP
,
int
speed
,
DateTime
startTime
,
DateTime
endTime
,
string
posid
=
""
,
string
barcode
=
""
)
{
this
.
LogType
=
"Axis"
;
this
.
DeviceName
=
deviceName
.
Replace
(
"-Move"
,
""
).
Replace
(
"-SMove"
,
""
).
Trim
();
this
.
MoveType
=
moveType
.
Trim
();
this
.
AxisName
=
axisName
;
this
.
TargetPos
=
targetP
;
this
.
StartTime
=
startTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
EndTime
=
endTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
PosId
=
posid
.
Trim
();
this
.
Barcode
=
barcode
.
Trim
();
TimeSpan
span
=
endTime
-
startTime
;
this
.
timeSpan
=
(
Math
.
Round
(
span
.
TotalMinutes
,
2
)).
ToString
();
//两位小数的分钟
this
.
Speed
=
speed
;
}
public
bool
IsValid
()
{
if
(
string
.
IsNullOrEmpty
(
DeviceName
)
||
string
.
IsNullOrEmpty
(
MoveType
))
{
return
false
;
}
return
true
;
}
[
JsonProperty
(
Order
=
11
)]
public
string
AxisName
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
12
)]
public
string
MoveType
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
13
)]
public
int
TargetPos
{
get
;
set
;
}
=
0
;
[
JsonProperty
(
Order
=
14
)]
public
int
Speed
{
get
;
set
;
}
[
JsonProperty
(
Order
=
15
)]
public
string
PosId
{
get
;
set
;
}
=
""
;
[
JsonProperty
(
Order
=
16
)]
public
string
Barcode
{
get
;
set
;
}
=
""
;
}
}
source/Common/util/ScanCodeManager.cs
查看文件 @
6596eb2
...
@@ -13,7 +13,7 @@ namespace OnlineStore.Common
...
@@ -13,7 +13,7 @@ namespace OnlineStore.Common
/// </summary>
/// </summary>
public
class
ScanCodeManager
public
class
ScanCodeManager
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// <summary>
/// 处理接收后的二维码
/// 处理接收后的二维码
/// </summary>
/// </summary>
...
...
source/Common/util/TcpClient.cs
查看文件 @
6596eb2
...
@@ -16,7 +16,7 @@ namespace OnlineStore.Common
...
@@ -16,7 +16,7 @@ namespace OnlineStore.Common
private
static
int
ServerPort
=
0
;
private
static
int
ServerPort
=
0
;
private
System
.
Timers
.
Timer
ReConnectTimer
=
null
;
private
System
.
Timers
.
Timer
ReConnectTimer
=
null
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public
delegate
void
HandleMessage
(
string
message
);
public
delegate
void
HandleMessage
(
string
message
);
private
Socket
m_clientSocket
;
private
Socket
m_clientSocket
;
...
@@ -112,13 +112,13 @@ namespace OnlineStore.Common
...
@@ -112,13 +112,13 @@ namespace OnlineStore.Common
{
{
m_clientSocket
.
BeginReceive
(
m_receiveBuffer
,
0
,
m_receiveBuffer
.
Length
,
0
,
new
AsyncCallback
(
ReceiveCallBack
),
null
);
m_clientSocket
.
BeginReceive
(
m_receiveBuffer
,
0
,
m_receiveBuffer
.
Length
,
0
,
new
AsyncCallback
(
ReceiveCallBack
),
null
);
onReceived
=
HandleMessage
;
onReceived
=
HandleMessage
;
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
serverIP
+
":"
+
serverPort
+
" success!"
);
LogUtil
.
info
(
"Connect to "
+
serverIP
+
":"
+
serverPort
+
" success!"
);
ReConnectTimer
.
Start
();
ReConnectTimer
.
Start
();
return
true
;
return
true
;
}
}
else
else
{
{
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
serverIP
+
":"
+
serverPort
+
" fail!"
);
LogUtil
.
info
(
"Connect to "
+
serverIP
+
":"
+
serverPort
+
" fail!"
);
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
@@ -154,7 +154,7 @@ namespace OnlineStore.Common
...
@@ -154,7 +154,7 @@ namespace OnlineStore.Common
if
(
m_clientSocket
!=
null
)
if
(
m_clientSocket
!=
null
)
{
{
m_clientSocket
.
Close
();
m_clientSocket
.
Close
();
LogUtil
.
debug
(
LOGGER
,
"Socket closed!"
);
LogUtil
.
debug
(
"Socket closed!"
);
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
...
@@ -168,7 +168,7 @@ namespace OnlineStore.Common
...
@@ -168,7 +168,7 @@ namespace OnlineStore.Common
{
{
m_clientSocket
.
BeginReceive
(
m_receiveBuffer
,
0
,
m_receiveBuffer
.
Length
,
0
,
new
AsyncCallback
(
ReceiveCallBack
),
null
);
m_clientSocket
.
BeginReceive
(
m_receiveBuffer
,
0
,
m_receiveBuffer
.
Length
,
0
,
new
AsyncCallback
(
ReceiveCallBack
),
null
);
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
ServerIp
+
":"
+
ServerPort
+
" success!"
);
LogUtil
.
info
(
"Connect to "
+
ServerIp
+
":"
+
ServerPort
+
" success!"
);
}
}
isInProcess
=
false
;
isInProcess
=
false
;
...
@@ -189,11 +189,11 @@ namespace OnlineStore.Common
...
@@ -189,11 +189,11 @@ namespace OnlineStore.Common
if
(
m_clientSocket
!=
null
)
if
(
m_clientSocket
!=
null
)
{
{
m_clientSocket
.
Close
();
m_clientSocket
.
Close
();
LogUtil
.
info
(
LOGGER
,
"Socket closed!"
);
LogUtil
.
info
(
"Socket closed!"
);
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
"No socket is running!"
);
LogUtil
.
error
(
"No socket is running!"
);
}
}
}
}
...
@@ -209,7 +209,7 @@ namespace OnlineStore.Common
...
@@ -209,7 +209,7 @@ namespace OnlineStore.Common
{
{
m_clientSocket
.
Send
(
sendBuffer
);
m_clientSocket
.
Send
(
sendBuffer
);
LogUtil
.
debug
(
LOGGER
,
"Send >> "
+
strSendData
);
LogUtil
.
debug
(
"Send >> "
+
strSendData
);
}
}
}
}
...
...
source/Common/util/TcpServer.cs
查看文件 @
6596eb2
...
@@ -12,7 +12,7 @@ namespace OnlineStore.Common
...
@@ -12,7 +12,7 @@ namespace OnlineStore.Common
{
{
public
class
TcpServer
public
class
TcpServer
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private
Thread
m_serverThread
;
private
Thread
m_serverThread
;
private
Socket
m_serverSocket
;
private
Socket
m_serverSocket
;
...
@@ -210,7 +210,7 @@ namespace OnlineStore.Common
...
@@ -210,7 +210,7 @@ namespace OnlineStore.Common
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
ex
.
ToString
());
Common
.
LogUtil
.
e
rror
(
ex
.
ToString
());
}
}
}
}
...
...
source/Common/util/UdpServer.cs
查看文件 @
6596eb2
...
@@ -12,7 +12,7 @@ namespace OnlineStore.Common
...
@@ -12,7 +12,7 @@ namespace OnlineStore.Common
public
class
UdpServer
public
class
UdpServer
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private
Thread
m_serverThread
;
private
Thread
m_serverThread
;
private
Socket
udpServer
;
private
Socket
udpServer
;
...
@@ -37,7 +37,7 @@ namespace OnlineStore.Common
...
@@ -37,7 +37,7 @@ namespace OnlineStore.Common
}
}
}
}
}
}
LogUtil
.
info
(
LOGGER
,
iplist
+
"]"
);
LogUtil
.
info
(
iplist
+
"]"
);
}
}
...
...
source/DeviceLibrary/IO/AIOBOX/AIOBOXManager.cs
查看文件 @
6596eb2
...
@@ -18,7 +18,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -18,7 +18,7 @@ namespace OnlineStore.DeviceLibrary
//public static uint DefaultDICount = 16;
//public static uint DefaultDICount = 16;
//public static uint DefaultDOCount = 16;
//public static uint DefaultDOCount = 16;
public
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public
Dictionary
<
string
,
AIOBOX
>
AIOMap
=
new
Dictionary
<
string
,
AIOBOX
>();
public
Dictionary
<
string
,
AIOBOX
>
AIOMap
=
new
Dictionary
<
string
,
AIOBOX
>();
public
Dictionary
<
string
,
List
<
Box_Sta
>>
DIValueMap
=
new
Dictionary
<
string
,
List
<
Box_Sta
>>();
public
Dictionary
<
string
,
List
<
Box_Sta
>>
DIValueMap
=
new
Dictionary
<
string
,
List
<
Box_Sta
>>();
...
@@ -124,7 +124,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -124,7 +124,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
error
)
catch
(
Exception
error
)
{
{
LogUtil
.
error
(
LOGGER
,
"连接IO模块 "
+
logName
+
" 出错:"
+
error
.
ToString
());
LogUtil
.
error
(
"连接IO模块 "
+
logName
+
" 出错:"
+
error
.
ToString
());
}
}
}
}
private
DateTime
lastLogTime
=
DateTime
.
Now
;
private
DateTime
lastLogTime
=
DateTime
.
Now
;
...
@@ -292,12 +292,12 @@ namespace OnlineStore.DeviceLibrary
...
@@ -292,12 +292,12 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
"WriteSingleDO出错 没有连接IO模块:"
+
ioIp
);
LogUtil
.
error
(
"WriteSingleDO出错 没有连接IO模块:"
+
ioIp
);
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
"AIO WriteSingleDO ["
+
ioIp
+
"] ["
+
StartAddress
+
"] 出错啦:"
+
ex
.
ToString
());
Common
.
LogUtil
.
e
rror
(
"AIO WriteSingleDO ["
+
ioIp
+
"] ["
+
StartAddress
+
"] 出错啦:"
+
ex
.
ToString
());
}
}
}
}
public
override
void
WriteSingleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
IO_VALUE
onOff
,
int
mSeconds
)
public
override
void
WriteSingleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
IO_VALUE
onOff
,
int
mSeconds
)
...
@@ -317,11 +317,11 @@ namespace OnlineStore.DeviceLibrary
...
@@ -317,11 +317,11 @@ namespace OnlineStore.DeviceLibrary
try
try
{
{
aioBox
.
WriteDO
(
StartAddress
,
aioBox
.
ReverseStatus
(
currBox_Sta
));
aioBox
.
WriteDO
(
StartAddress
,
aioBox
.
ReverseStatus
(
currBox_Sta
));
LogUtil
.
debug
(
LOGGER
,
"**********定时回写入 IO ["
+
ioIp
+
"] ["
+
StartAddress
+
"]值"
+
aioBox
.
ReverseStatus
(
currBox_Sta
)
+
"】:"
);
LogUtil
.
debug
(
"**********定时回写入 IO ["
+
ioIp
+
"] ["
+
StartAddress
+
"]值"
+
aioBox
.
ReverseStatus
(
currBox_Sta
)
+
"】:"
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"**********定时回写入 出错:"
+
ex
.
StackTrace
);
LogUtil
.
error
(
"**********定时回写入 出错:"
+
ex
.
StackTrace
);
}
}
};
};
mytimer
.
AutoReset
=
false
;
//设置是否自动重启,即自动执行多次;
mytimer
.
AutoReset
=
false
;
//设置是否自动重启,即自动执行多次;
...
@@ -330,7 +330,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -330,7 +330,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
"AIO WriteSingleDO ["
+
ioIp
+
"] ["
+
StartAddress
+
"] 出错 没有连接IO模块:"
+
ioIp
);
LogUtil
.
error
(
"AIO WriteSingleDO ["
+
ioIp
+
"] ["
+
StartAddress
+
"] 出错 没有连接IO模块:"
+
ioIp
);
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
@@ -449,7 +449,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -449,7 +449,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
" GetIOValue ["
+
configIO
.
IO_IP
+
"] ["
+
configIO
.
GetIOAddr
()
+
"] 获取数据出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
" GetIOValue ["
+
configIO
.
IO_IP
+
"] ["
+
configIO
.
GetIOAddr
()
+
"] 获取数据出错:"
+
ex
.
ToString
());
}
}
return
value
;
return
value
;
}
}
...
...
source/DeviceLibrary/IO/KangNaiDe/KNDManager.cs
查看文件 @
6596eb2
...
@@ -22,7 +22,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -22,7 +22,7 @@ namespace OnlineStore.DeviceLibrary
//public static ushort DefaultDILength = 16;
//public static ushort DefaultDILength = 16;
//public static ushort DefaultDOLength = 16;
//public static ushort DefaultDOLength = 16;
private
static
byte
DefualtSlaveID
=
255
;
private
static
byte
DefualtSlaveID
=
255
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
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
,
MasterTcpClient
>
mastMap
=
new
Dictionary
<
string
,
MasterTcpClient
>();
public
static
Dictionary
<
string
,
List
<
KNDIO
>>
DIValueMap
=
new
Dictionary
<
string
,
List
<
KNDIO
>>();
public
static
Dictionary
<
string
,
List
<
KNDIO
>>
DIValueMap
=
new
Dictionary
<
string
,
List
<
KNDIO
>>();
public
static
Dictionary
<
string
,
List
<
KNDIO
>>
DOValueMap
=
new
Dictionary
<
string
,
List
<
KNDIO
>>();
public
static
Dictionary
<
string
,
List
<
KNDIO
>>
DOValueMap
=
new
Dictionary
<
string
,
List
<
KNDIO
>>();
...
@@ -87,7 +87,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -87,7 +87,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
error
)
catch
(
Exception
error
)
{
{
LogUtil
.
error
(
LOGGER
,
"连接IO模块["
+
ioIp
+
"]出错:"
+
error
.
ToString
());
LogUtil
.
error
(
"连接IO模块["
+
ioIp
+
"]出错:"
+
error
.
ToString
());
}
}
}
}
public
override
void
ReadAllDI
(
string
ioIp
,
byte
slaveId
)
public
override
void
ReadAllDI
(
string
ioIp
,
byte
slaveId
)
...
@@ -122,7 +122,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -122,7 +122,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"出错啦:"
+
ex
.
ToString
());
LogUtil
.
error
(
"出错啦:"
+
ex
.
ToString
());
}
}
return
false
;
return
false
;
}
}
...
@@ -144,14 +144,14 @@ namespace OnlineStore.DeviceLibrary
...
@@ -144,14 +144,14 @@ namespace OnlineStore.DeviceLibrary
else
else
{
{
ConnectionIP
(
io
);
ConnectionIP
(
io
);
LogUtil
.
error
(
LOGGER
,
io
+
"当前没有连上,重连"
+
io
);
LogUtil
.
error
(
io
+
"当前没有连上,重连"
+
io
);
}
}
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"出错啦:"
+
ex
.
ToString
());
LogUtil
.
error
(
"出错啦:"
+
ex
.
ToString
());
}
}
Thread
.
Sleep
(
1
);
Thread
.
Sleep
(
1
);
}
}
...
@@ -175,7 +175,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -175,7 +175,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
"ReadMultipleDI出错 没有连接IO模块:"
+
ioIp
);
LogUtil
.
error
(
"ReadMultipleDI出错 没有连接IO模块:"
+
ioIp
);
}
}
}
}
public
static
void
ReadMultipleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
ushort
length
)
public
static
void
ReadMultipleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
ushort
length
)
...
@@ -189,7 +189,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -189,7 +189,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
"ReadMultipleDO出错 没有连接IO模块:"
+
ioIp
);
LogUtil
.
error
(
"ReadMultipleDO出错 没有连接IO模块:"
+
ioIp
);
}
}
}
}
//关闭所有的DO
//关闭所有的DO
...
@@ -235,7 +235,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -235,7 +235,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
"WriteMultipleDO 出错 没有连接IO模块:"
+
ioIp
);
LogUtil
.
error
(
"WriteMultipleDO 出错 没有连接IO模块:"
+
ioIp
);
}
}
}
}
public
override
void
WriteSingleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
IO_VALUE
onOff
)
public
override
void
WriteSingleDO
(
string
ioIp
,
byte
slaveId
,
ushort
StartAddress
,
IO_VALUE
onOff
)
...
@@ -252,7 +252,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -252,7 +252,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
"WriteSingleDO 出错没有连接IO模块:"
+
ioIp
);
LogUtil
.
error
(
"WriteSingleDO 出错没有连接IO模块:"
+
ioIp
);
}
}
}
}
...
@@ -282,11 +282,11 @@ namespace OnlineStore.DeviceLibrary
...
@@ -282,11 +282,11 @@ namespace OnlineStore.DeviceLibrary
MBmaster
.
WriteSingleCoils
(
ID
,
StartAddress
,
newValue
,
slaveId
);
MBmaster
.
WriteSingleCoils
(
ID
,
StartAddress
,
newValue
,
slaveId
);
KNDIO
newIo
=
new
KNDIO
(
ioIp
,
slaveId
,
StartAddress
,
newValue
);
KNDIO
newIo
=
new
KNDIO
(
ioIp
,
slaveId
,
StartAddress
,
newValue
);
SaveDOValue
(
newIo
,
ioIp
);
SaveDOValue
(
newIo
,
ioIp
);
LogUtil
.
info
(
LOGGER
,
"**********定时回写入 IO【"
+
ioIp
+
","
+
StartAddress
+
",值"
+
onOff
+
"】:"
);
LogUtil
.
info
(
"**********定时回写入 IO【"
+
ioIp
+
","
+
StartAddress
+
",值"
+
onOff
+
"】:"
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"**********定时回写入 出错:"
+
ex
.
StackTrace
);
LogUtil
.
error
(
"**********定时回写入 出错:"
+
ex
.
StackTrace
);
}
}
};
};
mytimer
.
AutoReset
=
false
;
//设置是否自动重启,即自动执行多次;
mytimer
.
AutoReset
=
false
;
//设置是否自动重启,即自动执行多次;
...
@@ -294,7 +294,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -294,7 +294,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
"WriteSingleDO出错 没有连接IO模块:"
+
ioIp
);
LogUtil
.
error
(
"WriteSingleDO出错 没有连接IO模块:"
+
ioIp
);
}
}
}
}
...
@@ -327,7 +327,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -327,7 +327,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"SaveDOValue出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"SaveDOValue出错:"
+
ex
.
ToString
());
}
}
}
}
public
override
IO_VALUE
GetDOValue
(
string
ioIP
,
byte
slaveId
,
ushort
StartAddress
)
public
override
IO_VALUE
GetDOValue
(
string
ioIP
,
byte
slaveId
,
ushort
StartAddress
)
...
@@ -393,7 +393,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -393,7 +393,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"获取数据出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"获取数据出错:"
+
ex
.
ToString
());
}
}
return
value
;
return
value
;
}
}
...
@@ -413,7 +413,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -413,7 +413,7 @@ namespace OnlineStore.DeviceLibrary
{
{
finalData
=
Convert
.
ToString
(
values
[
0
],
2
).
PadLeft
(
DILength
,
'0'
);
finalData
=
Convert
.
ToString
(
values
[
0
],
2
).
PadLeft
(
DILength
,
'0'
);
}
}
L
OGGER
.
D
ebug
(
"IO模块【"
+
ioIp
+
"】收到DI上传:【"
+
finalData
+
"】"
);
L
ogUtil
.
d
ebug
(
"IO模块【"
+
ioIp
+
"】收到DI上传:【"
+
finalData
+
"】"
);
if
(
finalData
.
Length
>=
DILength
)
if
(
finalData
.
Length
>=
DILength
)
{
{
List
<
KNDIO
>
kndList
=
new
List
<
KNDIO
>();
List
<
KNDIO
>
kndList
=
new
List
<
KNDIO
>();
...
@@ -444,7 +444,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -444,7 +444,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"SaveDIData出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"SaveDIData出错:"
+
ex
.
ToString
());
//LOGGER.Error("处理接受数据出错:", ex);
//LOGGER.Error("处理接受数据出错:", ex);
}
}
}
}
...
@@ -532,7 +532,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -532,7 +532,7 @@ namespace OnlineStore.DeviceLibrary
switch
(
Func
)
switch
(
Func
)
{
{
case
1
:
case
1
:
LOGGER
.
I
nfo
(
"Read coils end:【"
+
reviceMsg
+
"】 "
);
Common
.
LogUtil
.
i
nfo
(
"Read coils end:【"
+
reviceMsg
+
"】 "
);
SaveDOData
(
ioIp
,
SlaveId
,
values
);
SaveDOData
(
ioIp
,
SlaveId
,
values
);
break
;
break
;
case
2
:
case
2
:
...
@@ -553,7 +553,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -553,7 +553,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"处理接受数据出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"处理接受数据出错:"
+
ex
.
ToString
());
//LOGGER.Error("处理接受数据出错:", ex);
//LOGGER.Error("处理接受数据出错:", ex);
}
}
}
}
...
@@ -580,7 +580,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -580,7 +580,7 @@ namespace OnlineStore.DeviceLibrary
default
:
default
:
break
;
break
;
}
}
LOGGER
.
E
rror
(
"接收数据出错:"
+
exc
);
Common
.
LogUtil
.
e
rror
(
"接收数据出错:"
+
exc
);
//MessageBox.Show(exc, "Modbus slave exception");
//MessageBox.Show(exc, "Modbus slave exception");
}
}
}
}
...
...
source/DeviceLibrary/IO/KangNaiDe/MasterTcpClient.cs
查看文件 @
6596eb2
...
@@ -16,7 +16,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -16,7 +16,7 @@ namespace OnlineStore.DeviceLibrary
public
class
MasterTcpClient
public
class
MasterTcpClient
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Constants for access
// Constants for access
private
const
byte
fctReadCoil
=
1
;
private
const
byte
fctReadCoil
=
1
;
...
@@ -137,7 +137,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -137,7 +137,7 @@ namespace OnlineStore.DeviceLibrary
connResult
.
AsyncWaitHandle
.
WaitOne
(
this
.
TimeOutTime
,
true
);
//等待2秒
connResult
.
AsyncWaitHandle
.
WaitOne
(
this
.
TimeOutTime
,
true
);
//等待2秒
if
(!
connResult
.
IsCompleted
)
if
(!
connResult
.
IsCompleted
)
{
{
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
ip
+
":"
+
port
+
" fail!"
);
LogUtil
.
info
(
"Connect to "
+
ip
+
":"
+
port
+
" fail!"
);
return
;
return
;
}
}
else
else
...
@@ -155,7 +155,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -155,7 +155,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
System
.
IO
.
IOException
error
)
catch
(
System
.
IO
.
IOException
error
)
{
{
LogUtil
.
info
(
LOGGER
,
"Connect to "
+
ip
+
":"
+
port
+
" fail!"
);
LogUtil
.
info
(
"Connect to "
+
ip
+
":"
+
port
+
" fail!"
);
_connected
=
false
;
_connected
=
false
;
throw
(
error
);
throw
(
error
);
}
}
...
@@ -171,7 +171,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -171,7 +171,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
"IO模块["
+
IP
+
"]出错:"
+
ex
.
ToString
());
Common
.
LogUtil
.
e
rror
(
"IO模块["
+
IP
+
"]出错:"
+
ex
.
ToString
());
}
}
}
}
...
@@ -238,7 +238,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -238,7 +238,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
debug
(
LOGGER
,
clientipe
.
ToString
()
+
"收到数据(无需分包):"
+
str
);
LogUtil
.
debug
(
clientipe
.
ToString
()
+
"收到数据(无需分包):"
+
str
);
ushort
id
=
BitConverter
.
ToUInt16
(
rdata
,
0
);
ushort
id
=
BitConverter
.
ToUInt16
(
rdata
,
0
);
byte
function
=
rdata
[
7
];
byte
function
=
rdata
[
7
];
DataProcess
(
clientipe
.
ToString
(),
id
,
function
,
rdata
);
DataProcess
(
clientipe
.
ToString
(),
id
,
function
,
rdata
);
...
@@ -295,7 +295,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -295,7 +295,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
SocketException
e
)
catch
(
SocketException
e
)
{
{
LogUtil
.
error
(
LOGGER
,
"IO模块["
+
IP
+
"]接收数据出现错误:"
+
e
.
ToString
());
LogUtil
.
error
(
"IO模块["
+
IP
+
"]接收数据出现错误:"
+
e
.
ToString
());
if
(
socketClient
!=
null
)
if
(
socketClient
!=
null
)
{
{
socketClient
.
Close
();
socketClient
.
Close
();
...
@@ -335,7 +335,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -335,7 +335,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
"IO模块["
+
IP
+
"]dispose出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"IO模块["
+
IP
+
"]dispose出错:"
+
ex
.
ToString
());
}
}
socketClient
.
Close
();
socketClient
.
Close
();
}
}
...
@@ -515,7 +515,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -515,7 +515,7 @@ namespace OnlineStore.DeviceLibrary
{
{
if
(
socketClient
==
null
)
if
(
socketClient
==
null
)
{
{
LOGGER
.
E
rror
(
"发送数据时发现socketClient=null"
);
Common
.
LogUtil
.
e
rror
(
"发送数据时发现socketClient=null"
);
return
;
return
;
}
}
IPEndPoint
clientipe
=
(
IPEndPoint
)
socketClient
.
RemoteEndPoint
;
IPEndPoint
clientipe
=
(
IPEndPoint
)
socketClient
.
RemoteEndPoint
;
...
@@ -537,7 +537,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -537,7 +537,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
SystemException
error
)
catch
(
SystemException
error
)
{
{
LogUtil
.
error
(
LOGGER
,
"IO模块 WriteAsyncData出错:"
+
error
.
ToString
());
LogUtil
.
error
(
"IO模块 WriteAsyncData出错:"
+
error
.
ToString
());
CallException
(
id
,
write_data
[
7
],
excExceptionConnectionLost
,
tcpSocketReviceBuffer
);
CallException
(
id
,
write_data
[
7
],
excExceptionConnectionLost
,
tcpSocketReviceBuffer
);
}
}
}
}
...
...
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
查看文件 @
6596eb2
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Inventory.cs
查看文件 @
6596eb2
...
@@ -106,14 +106,14 @@ namespace OnlineStore.DeviceLibrary
...
@@ -106,14 +106,14 @@ namespace OnlineStore.DeviceLibrary
if
(
AutoStartIndex
>=
0
&&
AutoStartIndex
<
PositionNumList
.
Count
)
if
(
AutoStartIndex
>=
0
&&
AutoStartIndex
<
PositionNumList
.
Count
)
{
{
newIndex
=
AutoStartIndex
;
newIndex
=
AutoStartIndex
;
LogUtil
.
info
(
LOGGER
,
StoreName
+
"下一个索引不存在,重新开始自动盘点,索引【"
+
AutoStartIndex
+
"】"
);
LogUtil
.
info
(
StoreName
+
"下一个索引不存在,重新开始自动盘点,索引【"
+
AutoStartIndex
+
"】"
);
}
}
else
else
{
{
autoNext
=
false
;
autoNext
=
false
;
readDITimer
.
Enabled
=
false
;
readDITimer
.
Enabled
=
false
;
autoMsg
=
"自动盘点结束!"
;
autoMsg
=
"自动盘点结束!"
;
LogUtil
.
info
(
LOGGER
,
StoreName
+
"下一个索引不存在,自动盘点结束!"
);
LogUtil
.
info
(
StoreName
+
"下一个索引不存在,自动盘点结束!"
);
//回待机位
//回待机位
MoveToP1
();
MoveToP1
();
}
}
...
@@ -123,7 +123,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -123,7 +123,7 @@ namespace OnlineStore.DeviceLibrary
autoPositionIndex
=
newIndex
;
autoPositionIndex
=
newIndex
;
string
posid
=
PositionNumList
[
autoPositionIndex
];
string
posid
=
PositionNumList
[
autoPositionIndex
];
InOutPosInfo
inoutinfo
=
new
InOutPosInfo
(
autoInoutCode
,
posid
);
InOutPosInfo
inoutinfo
=
new
InOutPosInfo
(
autoInoutCode
,
posid
);
LogUtil
.
info
(
LOGGER
,
StoreName
+
"自动进入下一个仓位:posid="
+
posid
);
LogUtil
.
info
(
StoreName
+
"自动进入下一个仓位:posid="
+
posid
);
autoMsg
=
"自动盘点:"
+
posid
;
autoMsg
=
"自动盘点:"
+
posid
;
StartInventoryMove
(
new
InOutParam
(
inoutinfo
));
StartInventoryMove
(
new
InOutParam
(
inoutinfo
));
...
@@ -132,7 +132,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -132,7 +132,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
LOGGER
,
ex
.
ToString
());
LogUtil
.
error
(
ex
.
ToString
());
}
}
}
}
...
@@ -149,10 +149,10 @@ namespace OnlineStore.DeviceLibrary
...
@@ -149,10 +149,10 @@ namespace OnlineStore.DeviceLibrary
{
{
if
(!
LoadParamPosition
(
param
))
if
(!
LoadParamPosition
(
param
))
{
{
LogUtil
.
error
(
LOGGER
,
StoreName
+
" 启动盘点库位【"
+
posId
+
"】出错,找不到库位信息"
);
LogUtil
.
error
(
StoreName
+
" 启动盘点库位【"
+
posId
+
"】出错,找不到库位信息"
);
return
;
return
;
}
}
LogUtil
.
info
(
LOGGER
,
StoreName
+
" 启动盘点库位【"
+
posId
+
"】"
,
storeMoveColor
);
LogUtil
.
info
(
StoreName
+
" 启动盘点库位【"
+
posId
+
"】"
);
storeRunStatus
=
StoreRunStatus
.
Busy
;
storeRunStatus
=
StoreRunStatus
.
Busy
;
storeStatus
=
StoreStatus
.
CheckPosMove
;
storeStatus
=
StoreStatus
.
CheckPosMove
;
StoreMove
.
NewMove
(
StoreMoveType
.
CheckPosition
,
param
);
StoreMove
.
NewMove
(
StoreMoveType
.
CheckPosition
,
param
);
...
@@ -161,7 +161,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -161,7 +161,7 @@ namespace OnlineStore.DeviceLibrary
}
}
else
else
{
{
LogUtil
.
error
(
LOGGER
,
StoreName
+
" 启动盘点库位【"
+
posId
+
"】出错,当前状态,storeStatus="
+
storeRunStatus
);
LogUtil
.
error
(
StoreName
+
" 启动盘点库位【"
+
posId
+
"】出错,当前状态,storeStatus="
+
storeRunStatus
);
}
}
}
}
...
@@ -174,7 +174,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -174,7 +174,7 @@ namespace OnlineStore.DeviceLibrary
private
void
CheckPositionLog
(
string
msg
)
private
void
CheckPositionLog
(
string
msg
)
{
{
string
posId
=
StoreMove
.
MoveParam
!=
null
?
"【"
+
StoreMove
.
MoveParam
.
PosInfo
.
PosId
+
"】"
:
" "
;
string
posId
=
StoreMove
.
MoveParam
!=
null
?
"【"
+
StoreMove
.
MoveParam
.
PosInfo
.
PosId
+
"】"
:
" "
;
LogUtil
.
info
(
LOGGER
,
posId
+
StoreMove
.
MoveStep
+
" "
+
msg
,
storeMoveColor
);
LogUtil
.
info
(
posId
+
StoreMove
.
MoveStep
+
" "
+
msg
);
}
}
}
}
}
}
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Partial.cs
查看文件 @
6596eb2
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/acSingleStore/StoreManager.cs
查看文件 @
6596eb2
...
@@ -19,7 +19,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -19,7 +19,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
/// </summary>
public
static
int
CurrInOutType
=
0
;
public
static
int
CurrInOutType
=
0
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public
static
AC_SA_BoxBean
Store
=
null
;
public
static
AC_SA_BoxBean
Store
=
null
;
public
static
AC_SA_Config
Config
=
null
;
public
static
AC_SA_Config
Config
=
null
;
private
static
bool
isInit
=
false
;
private
static
bool
isInit
=
false
;
...
@@ -27,8 +27,9 @@ namespace OnlineStore.DeviceLibrary
...
@@ -27,8 +27,9 @@ namespace OnlineStore.DeviceLibrary
public
StoreManager
()
public
StoreManager
()
{
{
}
}
public
static
Dictionary
<
string
,
string
>
StepDesMap
=
new
Dictionary
<
string
,
string
>();
public
static
void
CheckEnum
(
Type
type
)
public
static
void
CheckEnum
(
Type
type
,
bool
isStep
)
{
{
if
(
type
.
IsEnum
)
if
(
type
.
IsEnum
)
{
{
...
@@ -37,11 +38,18 @@ namespace OnlineStore.DeviceLibrary
...
@@ -37,11 +38,18 @@ namespace OnlineStore.DeviceLibrary
{
{
if
(
valueList
.
Contains
(
item
))
if
(
valueList
.
Contains
(
item
))
{
{
LogUtil
.
error
(
LOGGER
,
type
.
Name
+
"枚举值:"
+
item
+
"重复存在,请检查代码!"
);
LogUtil
.
error
(
type
.
Name
+
"枚举值:"
+
item
+
"重复存在,请检查代码!"
);
Application
.
Exit
();
Application
.
Exit
();
break
;
break
;
}
}
valueList
.
Add
(
item
);
valueList
.
Add
(
item
);
if
(
isStep
)
{
StoreMoveStep
en
=
(
StoreMoveStep
)
item
;
string
des
=
EnumDesHelper
.
GetStepDes
(
en
);
StepDesMap
.
Add
(
en
.
ToString
(),
des
);
}
}
}
}
}
}
}
...
@@ -61,13 +69,13 @@ namespace OnlineStore.DeviceLibrary
...
@@ -61,13 +69,13 @@ namespace OnlineStore.DeviceLibrary
{
{
//IsConnectServer = true;
//IsConnectServer = true;
}
}
CheckEnum
(
typeof
(
StoreMoveStep
));
CheckEnum
(
typeof
(
StoreMoveStep
)
,
true
);
CheckEnum
(
typeof
(
StoreStatus
));
CheckEnum
(
typeof
(
StoreStatus
)
,
false
);
CheckEnum
(
typeof
(
StoreRunStatus
));
CheckEnum
(
typeof
(
StoreRunStatus
)
,
false
);
isInit
=
true
;
isInit
=
true
;
string
storeType
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_Type
);
string
storeType
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_Type
);
LogUtil
.
info
(
LOGGER
,
"配置的料仓 类型="
+
storeType
+
",开始加载料仓配置"
);
LogUtil
.
info
(
"配置的料仓 类型="
+
storeType
+
",开始加载料仓配置"
);
if
(
storeType
==
StoreType
.
RC_AC_SA
)
if
(
storeType
==
StoreType
.
RC_AC_SA
)
{
{
string
appPath
=
Application
.
StartupPath
;
string
appPath
=
Application
.
StartupPath
;
...
@@ -79,20 +87,20 @@ namespace OnlineStore.DeviceLibrary
...
@@ -79,20 +87,20 @@ namespace OnlineStore.DeviceLibrary
if
(
File
.
Exists
(
positionConfigFile
))
if
(
File
.
Exists
(
positionConfigFile
))
{
{
LogUtil
.
info
(
LOGGER
,
"加载位置文件:"
+
positionConfigFile
);
LogUtil
.
info
(
"加载位置文件:"
+
positionConfigFile
);
CSVPositionReader
<
ACStorePosition
>.
ReloadCSVFile
(
positionConfigFile
);
CSVPositionReader
<
ACStorePosition
>.
ReloadCSVFile
(
positionConfigFile
);
}
}
Config
=
(
AC_SA_Config
)
storeConfig
;
Config
=
(
AC_SA_Config
)
storeConfig
;
Store
=
new
AC_SA_BoxBean
(
Config
);
Store
=
new
AC_SA_BoxBean
(
Config
);
Store
.
CID
=
CID
;
Store
.
CID
=
CID
;
LogUtil
.
info
(
LOGGER
,
"加载料仓完成!"
);
LogUtil
.
info
(
"加载料仓完成!"
);
return
Store
;
return
Store
;
}
}
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
"出错:"
,
ex
);
Common
.
LogUtil
.
e
rror
(
"出错:"
,
ex
);
MessageBox
.
Show
(
ex
.
ToString
(),
"加载配置错误(请检查配置)"
);
MessageBox
.
Show
(
ex
.
ToString
(),
"加载配置错误(请检查配置)"
);
Application
.
Exit
();
Application
.
Exit
();
}
}
...
@@ -122,14 +130,14 @@ namespace OnlineStore.DeviceLibrary
...
@@ -122,14 +130,14 @@ namespace OnlineStore.DeviceLibrary
bool
result
=
CSVConfigReader
.
SaveBoxPosition
(
configFile
,
storeConfig
);
bool
result
=
CSVConfigReader
.
SaveBoxPosition
(
configFile
,
storeConfig
);
if
(!
result
)
if
(!
result
)
{
{
LOGGER
.
E
rror
(
"保存配置文件失败:"
+
configFile
);
Common
.
LogUtil
.
e
rror
(
"保存配置文件失败:"
+
configFile
);
}
}
Store
.
Config
=
storeConfig
;
Store
.
Config
=
storeConfig
;
Store
.
MoveAxisConfig
();
Store
.
MoveAxisConfig
();
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
"出错:"
,
ex
);
Common
.
LogUtil
.
e
rror
(
"出错:"
,
ex
);
}
}
}
}
private
static
string
api_communication
=
"service/store/communication"
;
//流水线状态通信接口
private
static
string
api_communication
=
"service/store/communication"
;
//流水线状态通信接口
...
...
source/DeviceLibrary/store/InOutParam.cs
查看文件 @
6596eb2
...
@@ -15,7 +15,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -15,7 +15,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
/// </summary>
public
class
InOutParam
public
class
InOutParam
{
{
public
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public
InOutParam
()
public
InOutParam
()
{
{
ACStoreP
=
null
;
ACStoreP
=
null
;
...
@@ -43,7 +43,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -43,7 +43,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
log
,
"出入库获取库位信息GetKTKPosition出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"出入库获取库位信息GetKTKPosition出错:"
+
ex
.
ToString
());
}
}
return
ACStoreP
;
return
ACStoreP
;
}
}
...
...
source/DeviceLibrary/store/KTK_Store.cs
查看文件 @
6596eb2
...
@@ -27,11 +27,12 @@ namespace OnlineStore.DeviceLibrary
...
@@ -27,11 +27,12 @@ namespace OnlineStore.DeviceLibrary
/// 提示消息,一般发给服务器后清空(LineBean表示报警提示消息,BoxBean表示出入库失败的原因记录)
/// 提示消息,一般发给服务器后清空(LineBean表示报警提示消息,BoxBean表示出入库失败的原因记录)
/// </summary>
/// </summary>
public
string
WarnMsg
=
""
;
public
string
WarnMsg
=
""
;
private
WarnParam
warnParam
=
new
WarnParam
();
/// <summary>
/// <summary>
/// 日志颜色
/// 日志颜色
/// </summary>
/// </summary>
protected
static
Color
storeMoveColor
=
Color
.
Blue
;
protected
static
Color
storeMoveColor
=
Color
.
Blue
;
protected
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
protected static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public
string
StoreName
{
get
;
set
;
}
public
string
StoreName
{
get
;
set
;
}
public
int
StoreID
{
get
;
set
;
}
public
int
StoreID
{
get
;
set
;
}
/// <summary>
/// <summary>
...
@@ -98,7 +99,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -98,7 +99,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
ex
.
ToString
());
Common
.
LogUtil
.
e
rror
(
ex
.
ToString
());
}
}
}
}
...
@@ -257,7 +258,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -257,7 +258,7 @@ namespace OnlineStore.DeviceLibrary
protected
void
ACAxisHomeMove
(
ConfigMoveAxis
moveAxis
)
protected
void
ACAxisHomeMove
(
ConfigMoveAxis
moveAxis
)
{
{
moveAxis
.
TargetPosition
=
0
;
moveAxis
.
TargetPosition
=
0
;
LogUtil
.
info
(
LOGGER
,
moveAxis
.
DisplayStr
+
"speed["
+
moveAxis
.
TargetSpeed
+
"]开始原点返回"
);
LogUtil
.
info
(
moveAxis
.
DisplayStr
+
"speed["
+
moveAxis
.
TargetSpeed
+
"]开始原点返回"
);
StoreMove
.
WaitList
.
Add
(
WaitResultInfo
.
WaitAxis
(
moveAxis
,
true
));
StoreMove
.
WaitList
.
Add
(
WaitResultInfo
.
WaitAxis
(
moveAxis
,
true
));
AddAxisMoveTime
(
moveAxis
);
AddAxisMoveTime
(
moveAxis
);
ACServerManager
.
HomeMove
(
moveAxis
.
DeviceName
,
(
short
)
moveAxis
.
GetAxisValue
(),
moveAxis
.
HomeHighSpeed
);
ACServerManager
.
HomeMove
(
moveAxis
.
DeviceName
,
(
short
)
moveAxis
.
GetAxisValue
(),
moveAxis
.
HomeHighSpeed
);
...
@@ -305,7 +306,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -305,7 +306,7 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动
//判断是否需要重新运动
if
(
StoreMove
.
CanWhileCount
>
0
)
if
(
StoreMove
.
CanWhileCount
>
0
)
{
{
LogUtil
.
error
(
LOGGER
,
moveAxis
.
DisplayStr
+
"目标位置["
+
targetPosition
+
"]当前位置["
+
outCount
+
LogUtil
.
error
(
moveAxis
.
DisplayStr
+
"目标位置["
+
targetPosition
+
"]当前位置["
+
outCount
+
"],误差过大,重新开始运动,剩余["
+
StoreMove
.
CanWhileCount
+
"]次"
);
"],误差过大,重新开始运动,剩余["
+
StoreMove
.
CanWhileCount
+
"]次"
);
ACServerManager
.
AbsMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
targetPosition
,
targetSpeed
);
ACServerManager
.
AbsMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
targetPosition
,
targetSpeed
);
StoreMove
.
CanWhileCount
--;
StoreMove
.
CanWhileCount
--;
...
@@ -314,7 +315,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -314,7 +315,7 @@ namespace OnlineStore.DeviceLibrary
{
{
msg
=
StoreName
+
" storeMoveStep="
+
StoreMove
.
MoveStep
+
moveAxis
.
DisplayStr
+
"目标位置["
+
targetPosition
+
"]当前位置["
+
outCount
msg
=
StoreName
+
" storeMoveStep="
+
StoreMove
.
MoveStep
+
moveAxis
.
DisplayStr
+
"目标位置["
+
targetPosition
+
"]当前位置["
+
outCount
+
"],误差过大,需要报警"
;
+
"],误差过大,需要报警"
;
LogUtil
.
error
(
LOGGER
,
msg
);
LogUtil
.
error
(
msg
);
}
}
}
}
return
false
;
return
false
;
...
@@ -334,15 +335,15 @@ namespace OnlineStore.DeviceLibrary
...
@@ -334,15 +335,15 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动
//判断是否需要重新运动
if
(
StoreMove
.
CanWhileCount
>
0
)
if
(
StoreMove
.
CanWhileCount
>
0
)
{
{
LogUtil
.
error
(
LOGGER
,
moveAxis
.
DisplayStr
+
"收到原点完成信号,当前位置["
+
outCount
+
"],重新回原点,剩余["
+
StoreMove
.
CanWhileCount
+
"]次"
);
LogUtil
.
error
(
moveAxis
.
DisplayStr
+
"收到原点完成信号,当前位置["
+
outCount
+
"],重新回原点,剩余["
+
StoreMove
.
CanWhileCount
+
"]次"
);
//LogUtil.error(
LOGGER,
StoreName + moveAxis.DisplayStr + "重新回原点");
//LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager
.
HomeMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
moveAxis
.
HomeHighSpeed
);
ACServerManager
.
HomeMove
(
moveAxis
.
DeviceName
,
moveAxis
.
GetAxisValue
(),
moveAxis
.
HomeHighSpeed
);
StoreMove
.
CanWhileCount
--;
StoreMove
.
CanWhileCount
--;
}
}
else
else
{
{
msg
=
StoreName
+
" storeMoveStep="
+
StoreMove
.
MoveStep
+
moveAxis
.
DisplayStr
+
"收到原点完成信号,当前位置["
+
outCount
+
"],误差过大,需要报警"
;
msg
=
StoreName
+
" storeMoveStep="
+
StoreMove
.
MoveStep
+
moveAxis
.
DisplayStr
+
"收到原点完成信号,当前位置["
+
outCount
+
"],误差过大,需要报警"
;
LogUtil
.
error
(
LOGGER
,
msg
);
LogUtil
.
error
(
msg
);
}
}
}
}
return
false
;
return
false
;
...
@@ -360,7 +361,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -360,7 +361,7 @@ namespace OnlineStore.DeviceLibrary
{
{
if
(!
isInit
)
if
(!
isInit
)
{
{
StoreMove
=
new
StoreMoveInfo
(
StoreID
);
StoreMove
=
new
StoreMoveInfo
(
StoreID
,
StoreName
);
mainTimer
=
new
System
.
Timers
.
Timer
();
mainTimer
=
new
System
.
Timers
.
Timer
();
mainTimer
.
Enabled
=
false
;
mainTimer
.
Enabled
=
false
;
...
@@ -498,7 +499,125 @@ namespace OnlineStore.DeviceLibrary
...
@@ -498,7 +499,125 @@ namespace OnlineStore.DeviceLibrary
return
sta
;
return
sta
;
}
}
}
}
/// <summary>
/// 设置报警消息,报警类型,清除报警时记录日志
/// </summary>
/// <param name="msg"></param>
/// <param name="logtype"></param>
/// <param name="logseconds"></param>
public
void
SetWarnMsg
(
string
msg
=
""
,
string
alarmType
=
""
,
StoreMoveInfo
moveInfo
=
null
,
int
logseconds
=
10
)
{
int
logtype
=
801
;
if
(
moveInfo
!=
null
)
{
logtype
=
StoreID
*
10000
+
(
int
)
moveInfo
.
MoveStep
;
}
if
(
String
.
IsNullOrEmpty
(
msg
).
Equals
(
false
))
{
if
(
WarnMsg
.
Equals
(
msg
))
{
if
(
msg
.
StartsWith
(
StoreName
))
{
LogUtil
.
error
(
msg
,
logtype
,
logseconds
);
}
else
{
LogUtil
.
error
(
StoreName
+
msg
,
logtype
,
logseconds
);
}
}
else
{
if
(
msg
.
StartsWith
(
StoreName
))
{
LogUtil
.
error
(
msg
);
}
else
{
LogUtil
.
error
(
StoreName
+
msg
);
}
}
}
if
(!
warnParam
.
AlarmType
.
Equals
(
alarmType
))
{
//报警类型不一致,若之前不是空,记录日志
if
(!
String
.
IsNullOrEmpty
(
warnParam
.
AlarmType
))
{
RunLogUtil
.
ErrorLog
(
new
ErrorLog
(
StoreName
,
warnParam
.
AlarmType
,
WarnMsg
,
warnParam
.
StartTime
,
DateTime
.
Now
,
warnParam
.
OperteType
,
warnParam
.
PosId
,
warnParam
.
Barcode
));
}
//更新开始时间
warnParam
.
StartTime
=
DateTime
.
Now
;
if
(
moveInfo
!=
null
)
{
warnParam
.
PosId
=
moveInfo
.
MoveParam
?.
PosInfo
?.
PosId
;
warnParam
.
Barcode
=
moveInfo
.
MoveParam
?.
PosInfo
?.
barcode
;
warnParam
.
OperteType
=
moveInfo
.
MoveType
.
ToString
();
}
else
{
warnParam
.
PosId
=
""
;
warnParam
.
Barcode
=
""
;
warnParam
.
OperteType
=
""
;
}
}
WarnMsg
=
msg
;
warnParam
.
AlarmType
=
alarmType
;
}
protected
void
ClearStepAlarm
(
string
stepDes
)
{
if
(
isInSuddenDown
||
isNoAirCheck
)
{
return
;
}
if
(
String
.
IsNullOrEmpty
(
WarnMsg
).
Equals
(
false
)
&&
String
.
IsNullOrEmpty
(
warnParam
.
AlarmType
).
Equals
(
false
))
{
if
(
alarmType
.
Equals
(
StoreAlarmType
.
IoSingleTimeOut
))
{
string
alarmTypeStr
=
stepDes
+
"_超时报警"
;
if
(
warnParam
.
AlarmType
.
Equals
(
alarmTypeStr
))
{
LogUtil
.
info
(
StoreName
+
$
"步骤{stepDes}结束,清理【{ WarnMsg }】 "
);
alarmType
=
StoreAlarmType
.
None
;
SetWarnMsg
(
""
);
}
}
else
if
(
alarmType
.
Equals
(
StoreAlarmType
.
AxisMoveError
))
{
string
alarmTypeStr
=
stepDes
+
"_轴运动报警"
;
if
(
warnParam
.
AlarmType
.
Equals
(
alarmTypeStr
))
{
LogUtil
.
info
(
StoreName
+
$
"步骤{stepDes}结束,清理【{ WarnMsg }】 "
);
alarmType
=
StoreAlarmType
.
None
;
SetWarnMsg
(
""
);
}
}
}
}
}
public
class
WarnParam
{
public
WarnParam
()
{
}
public
WarnParam
(
string
alarmType
,
DateTime
startTime
,
string
operType
,
string
posId
,
string
barcode
)
{
this
.
AlarmType
=
alarmType
;
this
.
StartTime
=
startTime
;
this
.
OperteType
=
operType
;
this
.
PosId
=
posId
;
this
.
Barcode
=
barcode
;
}
public
string
AlarmType
=
""
;
public
DateTime
StartTime
=
DateTime
.
Now
;
public
string
OperteType
=
""
;
public
string
PosId
=
""
;
public
string
Barcode
=
""
;
}
}
}
}
source/DeviceLibrary/store/StoreStep.cs
查看文件 @
6596eb2
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/store/model/StoreMoveInfo.cs
查看文件 @
6596eb2
...
@@ -3,6 +3,7 @@ using OnlineStore.DeviceLibrary;
...
@@ -3,6 +3,7 @@ using OnlineStore.DeviceLibrary;
using
OnlineStore.LoadCSVLibrary
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
...
@@ -14,11 +15,12 @@ namespace OnlineStore.DeviceLibrary
...
@@ -14,11 +15,12 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
/// </summary>
public
class
StoreMoveInfo
public
class
StoreMoveInfo
{
{
private
string
Name
;
/// <summary>
/// <summary>
/// 超时时间
/// 超时时间
/// </summary>
/// </summary>
public
int
TimeOutSeconds
=
60
;
public
int
TimeOutSeconds
=
60
;
public
StoreMoveInfo
(
int
storeId
)
public
StoreMoveInfo
(
int
storeId
,
string
name
)
{
{
moveType
=
StoreMoveType
.
None
;
moveType
=
StoreMoveType
.
None
;
...
@@ -27,6 +29,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -27,6 +29,7 @@ namespace OnlineStore.DeviceLibrary
this
.
moveStep
=
StoreMoveStep
.
Wait
;
this
.
moveStep
=
StoreMoveStep
.
Wait
;
IsInWait
=
false
;
IsInWait
=
false
;
MoveNum
=
0
;
MoveNum
=
0
;
this
.
Name
=
name
;
}
}
public
int
MoveNum
{
get
;
set
;
}
public
int
MoveNum
{
get
;
set
;
}
...
@@ -96,6 +99,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -96,6 +99,7 @@ namespace OnlineStore.DeviceLibrary
public
void
NextMoveStep
(
StoreMoveStep
step
)
public
void
NextMoveStep
(
StoreMoveStep
step
)
{
{
stepMoveLog
();
PreMoveStep
=
moveStep
;
PreMoveStep
=
moveStep
;
moveStep
=
step
;
moveStep
=
step
;
LastSetpTime
=
DateTime
.
Now
;
LastSetpTime
=
DateTime
.
Now
;
...
@@ -105,6 +109,17 @@ namespace OnlineStore.DeviceLibrary
...
@@ -105,6 +109,17 @@ namespace OnlineStore.DeviceLibrary
CanWhileCount
=
5
;
CanWhileCount
=
5
;
TimeOutSeconds
=
60
;
TimeOutSeconds
=
60
;
}
}
private
void
stepMoveLog
()
{
try
{
RunLogUtil
.
MoveLog
(
new
MoveLog
(
Name
,
GetMoveType
(),
GetStepDes
(),
LastSetpTime
,
DateTime
.
Now
,
MoveParam
.
PosInfo
?.
PosId
,
MoveParam
.
PosInfo
?.
barcode
));
}
catch
(
Exception
ex
)
{
}
}
/// <summary>
/// <summary>
/// 当前步骤执行完成
/// 当前步骤执行完成
/// </summary>
/// </summary>
...
@@ -131,6 +146,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -131,6 +146,7 @@ namespace OnlineStore.DeviceLibrary
}
}
public
void
EndMove
()
public
void
EndMove
()
{
{
stepMoveLog
();
this
.
moveType
=
StoreMoveType
.
None
;
this
.
moveType
=
StoreMoveType
.
None
;
this
.
MoveParam
=
null
;
this
.
MoveParam
=
null
;
moveStep
=
StoreMoveStep
.
Wait
;
moveStep
=
StoreMoveStep
.
Wait
;
...
@@ -139,10 +155,45 @@ namespace OnlineStore.DeviceLibrary
...
@@ -139,10 +155,45 @@ namespace OnlineStore.DeviceLibrary
WaitList
=
new
List
<
WaitResultInfo
>();
WaitList
=
new
List
<
WaitResultInfo
>();
CanWhileCount
=
0
;
CanWhileCount
=
0
;
}
}
public
string
GetStepDes
()
{
string
currName
=
moveStep
.
ToString
();
try
{
if
(
StoreManager
.
StepDesMap
.
ContainsKey
(
currName
))
{
return
StoreManager
.
StepDesMap
[
currName
];
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"GetStepDes 出错:"
+
ex
.
ToString
());
}
return
currName
;
}
public
StoreMoveInfo
clone
()
public
StoreMoveInfo
clone
()
{
{
return
(
StoreMoveInfo
)
this
.
MemberwiseClone
();
return
(
StoreMoveInfo
)
this
.
MemberwiseClone
();
}
}
public
string
GetMoveType
()
{
switch
(
moveType
)
{
case
StoreMoveType
.
InStore
:
return
"入料"
;
break
;
case
StoreMoveType
.
OutStore
:
return
"出料"
;
break
;
case
StoreMoveType
.
StoreReset
:
return
"复位"
;
break
;
case
StoreMoveType
.
ReturnHome
:
return
"回原"
;
break
;
}
return
""
;
}
public
List
<
WaitResultInfo
>
WaitList
=
new
List
<
WaitResultInfo
>();
public
List
<
WaitResultInfo
>
WaitList
=
new
List
<
WaitResultInfo
>();
/// <summary>
/// <summary>
...
@@ -154,7 +205,25 @@ namespace OnlineStore.DeviceLibrary
...
@@ -154,7 +205,25 @@ namespace OnlineStore.DeviceLibrary
IsInWait
=
false
;
IsInWait
=
false
;
}
}
}
}
public
static
class
EnumDesHelper
{
public
static
string
GetStepDes
(
this
Enum
val
)
{
var
type
=
val
.
GetType
();
var
memberInfo
=
type
.
GetMember
(
val
.
ToString
());
var
attributes
=
memberInfo
[
0
].
GetCustomAttributes
(
typeof
(
DescriptionAttribute
),
false
);
if
(
attributes
==
null
||
attributes
.
Length
!=
1
)
{
//如果没有定义描述,就把当前枚举值的对应名称返回
return
val
.
ToString
();
}
return
(
attributes
.
Single
()
as
DescriptionAttribute
).
Description
;
}
}
public
class
WaitResultInfo
public
class
WaitResultInfo
{
{
private
WaitResultInfo
()
private
WaitResultInfo
()
...
...
source/LoadCVSLibrary/CSVReaderBase.cs
查看文件 @
6596eb2
...
@@ -13,7 +13,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -13,7 +13,7 @@ namespace OnlineStore.LoadCSVLibrary
public
class
CSVReaderBase
public
class
CSVReaderBase
{
{
public
static
char
Spilt_Char
=
','
;
public
static
char
Spilt_Char
=
','
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// <summary>
/// 获取一个类所有的《字段,AttributeName列名》集合
/// 获取一个类所有的《字段,AttributeName列名》集合
/// </summary>
/// </summary>
...
@@ -110,12 +110,12 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -110,12 +110,12 @@ namespace OnlineStore.LoadCSVLibrary
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
LOGGER
.
E
rror
(
"出错:"
,
e
);
Common
.
LogUtil
.
e
rror
(
"出错:"
,
e
);
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
ex
.
ToString
());
Common
.
LogUtil
.
e
rror
(
ex
.
ToString
());
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -152,7 +152,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -152,7 +152,7 @@ namespace OnlineStore.LoadCSVLibrary
{
{
if
(!
titleIndex
.
ContainsKey
(
str
))
if
(!
titleIndex
.
ContainsKey
(
str
))
{
{
LOGGER
.
E
rror
(
"未找到必须列:"
+
str
+
",加载数据失败!"
);
Common
.
LogUtil
.
e
rror
(
"未找到必须列:"
+
str
+
",加载数据失败!"
);
throw
new
CVSFieldNotMatchingExection
(
"未找到必须列:"
+
str
+
",加载数据失败!"
);
throw
new
CVSFieldNotMatchingExection
(
"未找到必须列:"
+
str
+
",加载数据失败!"
);
}
}
}
}
...
...
source/LoadCVSLibrary/LoadCSVLibrary.csproj
查看文件 @
6596eb2
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<AssemblyName>LoadCSVLibrary</AssemblyName>
<AssemblyName>LoadCSVLibrary</AssemblyName>
<TargetFrameworkVersion>v4.
0
</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.
6.1
</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFrameworkProfile />
</PropertyGroup>
</PropertyGroup>
...
...
source/LoadCVSLibrary/position/CSVPositionReader.cs
查看文件 @
6596eb2
...
@@ -51,7 +51,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -51,7 +51,7 @@ namespace OnlineStore.LoadCSVLibrary
{
{
if
(
hasReadFileList
.
Contains
(
filePath
))
if
(
hasReadFileList
.
Contains
(
filePath
))
{
{
LOGGER
.
E
rror
(
"文件"
+
filePath
+
"已经加载过,直接返回null"
);
Common
.
LogUtil
.
e
rror
(
"文件"
+
filePath
+
"已经加载过,直接返回null"
);
return
null
;
return
null
;
}
}
Type
type
=
typeof
(
T
);
Type
type
=
typeof
(
T
);
...
@@ -59,7 +59,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -59,7 +59,7 @@ namespace OnlineStore.LoadCSVLibrary
Dictionary
<
string
,
string
>
proTitleMap
=
getProAttributeMap
(
typeof
(
T
));
Dictionary
<
string
,
string
>
proTitleMap
=
getProAttributeMap
(
typeof
(
T
));
if
(
proTitleMap
.
Count
<=
4
)
if
(
proTitleMap
.
Count
<=
4
)
{
{
LOGGER
.
E
rror
(
typeof
(
T
).
ToString
()
+
"只读取到"
+
proTitleMap
.
Count
+
"个属性"
);
Common
.
LogUtil
.
e
rror
(
typeof
(
T
).
ToString
()
+
"只读取到"
+
proTitleMap
.
Count
+
"个属性"
);
}
}
List
<
string
>
cvsTitleList
=
new
List
<
string
>(
proTitleMap
.
Values
);
List
<
string
>
cvsTitleList
=
new
List
<
string
>(
proTitleMap
.
Values
);
List
<
string
>
propertyList
=
new
List
<
string
>(
proTitleMap
.
Keys
);
List
<
string
>
propertyList
=
new
List
<
string
>(
proTitleMap
.
Keys
);
...
@@ -117,12 +117,12 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -117,12 +117,12 @@ namespace OnlineStore.LoadCSVLibrary
}
}
else
else
{
{
LOGGER
.
E
rror
(
"读取csv,index="
+
index
+
",数据格式不匹配!,line="
+
line
);
Common
.
LogUtil
.
e
rror
(
"读取csv,index="
+
index
+
",数据格式不匹配!,line="
+
line
);
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
Debug
(
"CSV 读取行【"
+
line
+
"】行转换失败"
);
Common
.
LogUtil
.
info
(
"CSV 读取行【"
+
line
+
"】行转换失败"
);
}
}
}
}
index
++;
index
++;
...
@@ -157,7 +157,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -157,7 +157,7 @@ namespace OnlineStore.LoadCSVLibrary
Dictionary
<
string
,
string
>
proTitleMap
=
getProAttributeMap
(
typeof
(
T
));
Dictionary
<
string
,
string
>
proTitleMap
=
getProAttributeMap
(
typeof
(
T
));
if
(
proTitleMap
.
Count
<=
4
)
if
(
proTitleMap
.
Count
<=
4
)
{
{
LOGGER
.
E
rror
(
typeof
(
T
).
ToString
()
+
"只读取到"
+
proTitleMap
.
Count
+
"个属性"
);
Common
.
LogUtil
.
e
rror
(
typeof
(
T
).
ToString
()
+
"只读取到"
+
proTitleMap
.
Count
+
"个属性"
);
}
}
List
<
string
>
cvsTitleList
=
new
List
<
string
>(
proTitleMap
.
Values
);
List
<
string
>
cvsTitleList
=
new
List
<
string
>(
proTitleMap
.
Values
);
List
<
string
>
propertyList
=
new
List
<
string
>(
proTitleMap
.
Keys
);
List
<
string
>
propertyList
=
new
List
<
string
>(
proTitleMap
.
Keys
);
...
@@ -207,7 +207,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -207,7 +207,7 @@ namespace OnlineStore.LoadCSVLibrary
Dictionary
<
string
,
string
>
proTitleMap
=
getProAttributeMap
(
typeof
(
T
));
Dictionary
<
string
,
string
>
proTitleMap
=
getProAttributeMap
(
typeof
(
T
));
if
(
proTitleMap
.
Count
<=
4
)
if
(
proTitleMap
.
Count
<=
4
)
{
{
LOGGER
.
E
rror
(
typeof
(
T
).
ToString
()
+
"只读取到"
+
proTitleMap
.
Count
+
"个属性"
);
Common
.
LogUtil
.
e
rror
(
typeof
(
T
).
ToString
()
+
"只读取到"
+
proTitleMap
.
Count
+
"个属性"
);
}
}
List
<
string
>
cvsTitleList
=
new
List
<
string
>(
proTitleMap
.
Values
);
List
<
string
>
cvsTitleList
=
new
List
<
string
>(
proTitleMap
.
Values
);
List
<
string
>
propertyList
=
new
List
<
string
>(
proTitleMap
.
Keys
);
List
<
string
>
propertyList
=
new
List
<
string
>(
proTitleMap
.
Keys
);
...
...
source/LoadCVSLibrary/storeConfig/CSVConfigReader.cs
查看文件 @
6596eb2
...
@@ -45,7 +45,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -45,7 +45,7 @@ namespace OnlineStore.LoadCSVLibrary
//必须有列【类型】
//必须有列【类型】
if
(
allTitleIndex
.
Count
<
0
||
!
allTitleIndex
.
ContainsKey
(
"类型"
))
if
(
allTitleIndex
.
Count
<
0
||
!
allTitleIndex
.
ContainsKey
(
"类型"
))
{
{
LOGGER
.
E
rror
(
"未找到必须列:类型,加载数据失败!"
);
Common
.
LogUtil
.
e
rror
(
"未找到必须列:类型,加载数据失败!"
);
throw
new
CVSFieldNotMatchingExection
(
"未找到必须列:类型,加载数据失败!"
);
throw
new
CVSFieldNotMatchingExection
(
"未找到必须列:类型,加载数据失败!"
);
}
}
typeIndex
=
allTitleIndex
[
"类型"
];
typeIndex
=
allTitleIndex
[
"类型"
];
...
@@ -116,14 +116,14 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -116,14 +116,14 @@ namespace OnlineStore.LoadCSVLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
"filepath="
+
filePath
+
",index="
+
index
+
",key="
+
key
+
"出错:"
+
ex
.
ToString
());
Common
.
LogUtil
.
e
rror
(
"filepath="
+
filePath
+
",index="
+
index
+
",key="
+
key
+
"出错:"
+
ex
.
ToString
());
}
}
listIndex
++;
listIndex
++;
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
"filepath="
+
filePath
+
",index="
+
index
+
",key="
+
key
+
"出错:"
+
ex
.
ToString
());
Common
.
LogUtil
.
e
rror
(
"filepath="
+
filePath
+
",index="
+
index
+
",key="
+
key
+
"出错:"
+
ex
.
ToString
());
}
}
}
}
bllIns
.
CheckField
();
bllIns
.
CheckField
();
...
@@ -142,14 +142,14 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -142,14 +142,14 @@ namespace OnlineStore.LoadCSVLibrary
}
}
else
else
{
{
LOGGER
.
E
rror
(
"配置的料仓类型="
+
storeType
+
"未找到处理方法!"
);
Common
.
LogUtil
.
e
rror
(
"配置的料仓类型="
+
storeType
+
"未找到处理方法!"
);
}
}
return
LoadConfig
(
config
);
return
LoadConfig
(
config
);
}
}
public
static
StoreConfig
LoadConfig
(
StoreConfig
config
)
public
static
StoreConfig
LoadConfig
(
StoreConfig
config
)
{
{
LOGGER
.
I
nfo
(
"开始读取文件:"
+
config
.
ConfigFilePath
);
Common
.
LogUtil
.
i
nfo
(
"开始读取文件:"
+
config
.
ConfigFilePath
);
if
(
config
==
null
||
config
.
ConfigFilePath
.
Equals
(
""
))
if
(
config
==
null
||
config
.
ConfigFilePath
.
Equals
(
""
))
{
{
return
null
;
return
null
;
...
@@ -205,7 +205,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -205,7 +205,7 @@ namespace OnlineStore.LoadCSVLibrary
}
}
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
)
{
LOGGER
.
E
rror
(
"出错:"
+
e
.
ToString
());
Common
.
LogUtil
.
e
rror
(
"出错:"
+
e
.
ToString
());
}
}
string
newLine
=
""
;
string
newLine
=
""
;
foreach
(
string
s
in
newArray
)
foreach
(
string
s
in
newArray
)
...
...
source/LoadCVSLibrary/storeConfig/ConfigItemBase.cs
查看文件 @
6596eb2
...
@@ -12,7 +12,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -12,7 +12,7 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
/// </summary>
public
class
ConfigBase
public
class
ConfigBase
{
{
protected
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
protected static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// <summary>
/// DI=输入IO,DO=输出IO,PRO=属性,AXIS=轴
/// DI=输入IO,DO=输出IO,PRO=属性,AXIS=轴
/// </summary>
/// </summary>
...
@@ -268,7 +268,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -268,7 +268,7 @@ namespace OnlineStore.LoadCSVLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
E
rror
(
"出错:"
,
ex
);
Common
.
LogUtil
.
e
rror
(
"出错:"
,
ex
);
}
}
return
value
;
return
value
;
}
}
...
...
source/LoadCVSLibrary/storeConfig/config/StoreConfig.cs
查看文件 @
6596eb2
...
@@ -12,7 +12,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -12,7 +12,7 @@ namespace OnlineStore.LoadCSVLibrary
public
static
Dictionary
<
string
,
string
>
ProIOIpMap
=
null
;
public
static
Dictionary
<
string
,
string
>
ProIOIpMap
=
null
;
public
const
string
IOIP_Str
=
"PRO_AOI_IP"
;
public
const
string
IOIP_Str
=
"PRO_AOI_IP"
;
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
System
.
Reflection
.
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
//
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// <summary>
/// ID
/// ID
/// </summary>
/// </summary>
...
@@ -117,7 +117,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -117,7 +117,7 @@ namespace OnlineStore.LoadCSVLibrary
}
}
else
else
{
{
LOGGER
.
E
rror
(
"配置文件:"
+
this
.
ConfigFilePath
+
",属性名="
+
con
.
ProName
+
"的属性未找到匹配字段!"
);
Common
.
LogUtil
.
e
rror
(
"配置文件:"
+
this
.
ConfigFilePath
+
",属性名="
+
con
.
ProName
+
"的属性未找到匹配字段!"
);
}
}
}
}
else
if
(!
ProIOIpMap
.
ContainsKey
(
con
.
ProName
)
&&
con
.
ProName
.
ToUpper
().
Contains
(
IOIP_Str
))
else
if
(!
ProIOIpMap
.
ContainsKey
(
con
.
ProName
)
&&
con
.
ProName
.
ToUpper
().
Contains
(
IOIP_Str
))
...
@@ -130,7 +130,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -130,7 +130,7 @@ namespace OnlineStore.LoadCSVLibrary
}
}
else
else
{
{
LOGGER
.
E
rror
(
"配置文件:"
+
this
.
ConfigFilePath
+
",属性名="
+
con
.
ProName
+
"的属性未找到匹配字段!"
);
Common
.
LogUtil
.
e
rror
(
"配置文件:"
+
this
.
ConfigFilePath
+
",属性名="
+
con
.
ProName
+
"的属性未找到匹配字段!"
);
}
}
}
}
else
if
(
con
.
ProType
==
ConfigItemType
.
DI
)
else
if
(
con
.
ProType
==
ConfigItemType
.
DI
)
...
@@ -146,7 +146,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -146,7 +146,7 @@ namespace OnlineStore.LoadCSVLibrary
}
}
else
else
{
{
LOGGER
.
E
rror
(
"配置文件:"
+
this
.
ConfigFilePath
+
",属性名="
+
con
.
ProName
+
"的属性未找到匹配字段!"
);
Common
.
LogUtil
.
e
rror
(
"配置文件:"
+
this
.
ConfigFilePath
+
",属性名="
+
con
.
ProName
+
"的属性未找到匹配字段!"
);
}
}
}
}
else
if
(
con
.
ProType
==
ConfigItemType
.
DO
)
else
if
(
con
.
ProType
==
ConfigItemType
.
DO
)
...
@@ -162,7 +162,7 @@ namespace OnlineStore.LoadCSVLibrary
...
@@ -162,7 +162,7 @@ namespace OnlineStore.LoadCSVLibrary
}
}
else
else
{
{
LOGGER
.
E
rror
(
"配置文件:"
+
this
.
ConfigFilePath
+
",属性名="
+
con
.
ProName
+
"的属性未找到匹配字段!"
);
Common
.
LogUtil
.
e
rror
(
"配置文件:"
+
this
.
ConfigFilePath
+
",属性名="
+
con
.
ProName
+
"的属性未找到匹配字段!"
);
}
}
}
}
}
}
...
...
source/UserFromControl/UserFromControl.csproj
查看文件 @
6596eb2
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UserFromControl</RootNamespace>
<RootNamespace>UserFromControl</RootNamespace>
<AssemblyName>UserFromControl</AssemblyName>
<AssemblyName>UserFromControl</AssemblyName>
<TargetFrameworkVersion>v4.
0
</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.
6.1
</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFrameworkProfile />
</PropertyGroup>
</PropertyGroup>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论