Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hemei
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
hemei
Commits
21640179
Commit
21640179
authored
Nov 14, 2019
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
收卷也加上了数据库
parent
c9d13bd5
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
486 additions
and
70 deletions
+486
-70
IBCSystem.cs
Project.FLY.IBC/FLY.IBC/Server/IBCSystem.cs
+5
-1
WeightSystem.cs
Project.FLY.Weight/FLY.Weight/Server/WeightSystem.cs
+5
-3
Common.cs
Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Common.cs
+29
-0
FLY.Winder.UI.Client.csproj
...20190413/FLY.Winder.UI.Client/FLY.Winder.UI.Client.csproj
+1
-0
Page_ErrorNewestTable.xaml.cs
...190413/FLY.Winder.UI.Client/Page_ErrorNewestTable.xaml.cs
+11
-3
MainWindow.xaml.cs
...Y.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml.cs
+5
-3
FLY.Winder.csproj
Project.FLY.Winder_20190413/FLY.Winder/FLY.Winder.csproj
+9
-0
OBJ_INTERFACE.cs
...Winder_20190413/FLY.Winder/OBJ_INTERFACE/OBJ_INTERFACE.cs
+3
-0
OBJProxy.cs
...LY.Winder_20190413/FLY.Winder/Server.OBJProxy/OBJProxy.cs
+40
-0
DbModel.cs
...ct.FLY.Winder_20190413/FLY.Winder/Server/Model/DbModel.cs
+42
-0
DbTable.cs
...ct.FLY.Winder_20190413/FLY.Winder/Server/Model/DbTable.cs
+102
-0
HistoryDb.cs
....FLY.Winder_20190413/FLY.Winder/Server/Model/HistoryDb.cs
+72
-0
SysParam.cs
Project.FLY.Winder_20190413/FLY.Winder/Server/SysParam.cs
+42
-0
TDGage.cs
Project.FLY.Winder_20190413/FLY.Winder/Server/TDGage.cs
+24
-45
WinderSystem.cs
...ect.FLY.Winder_20190413/FLY.Winder/Server/WinderSystem.cs
+96
-15
No files found.
Project.FLY.IBC/FLY.IBC/Server/IBCSystem.cs
View file @
21640179
...
...
@@ -165,8 +165,12 @@ namespace FLY.IBC.Server
{
historyDb
.
AddWidthRange
(
dbWidths_1min
);
dbWidths_1min
.
Clear
();
stopwatch_1min
.
Restart
();
}
else
{
stopwatch_1min
.
Reset
();
}
stopwatch_1min
.
Reset
();
}
if
(!
stopwatch_interval
.
IsRunning
)
...
...
Project.FLY.Weight/FLY.Weight/Server/WeightSystem.cs
View file @
21640179
...
...
@@ -401,8 +401,12 @@ namespace FLY.Weight.Server
{
mHistoryDb
.
AddFlowRange
(
lcFlows_1min
);
lcFlows_1min
.
Clear
();
stopwatch_1min
.
Restart
();
}
else
{
stopwatch_1min
.
Reset
();
}
stopwatch_1min
.
Reset
();
}
if
(!
stopwatch_flowInterval
.
IsRunning
)
...
...
@@ -673,7 +677,6 @@ namespace FLY.Weight.Server
public
string
[]
GetSavePropertyNames
()
{
return
new
string
[]{
"FlowListSize"
,
"FlowInterval"
};
}
...
...
@@ -686,7 +689,6 @@ namespace FLY.Weight.Server
{
return
new
string
[]{
"FlowInterval"
,
"FlowListSize"
,
"ItemsCnt"
,
"BinCnts"
};
...
...
Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Common.cs
0 → 100644
View file @
21640179
using
FLY.OBJComponents.Client
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
namespace
FLY.Winder.UI.Client
{
public
static
class
Common
{
public
static
void
BindingWindowSize
<
T
>(
Func
<
int
,
BufferWindow
<
T
>>
createWindow
)
{
int
windowSize
=
30
;
if
(
Application
.
Current
.
Properties
[
"WindowSize"
]
is
int
)
windowSize
=
(
int
)
Application
.
Current
.
Properties
[
"WindowSize"
];
var
window
=
createWindow
(
windowSize
);
window
.
PropertyChanged
+=
(
s
,
e
)
=>
{
if
(
e
.
PropertyName
==
"Size"
)
{
var
w
=
s
as
BufferWindow
<
T
>;
Application
.
Current
.
Properties
[
"WindowSize"
]
=
w
.
Size
;
}
};
}
}
}
Project.FLY.Winder_20190413/FLY.Winder.UI.Client/FLY.Winder.UI.Client.csproj
View file @
21640179
...
...
@@ -58,6 +58,7 @@
<Reference
Include=
"PresentationFramework"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Common.cs"
/>
<Compile
Include=
"Converter\IsGTMultiValueConverter.cs"
/>
<Compile
Include=
"Converter\RatioConverter.cs"
/>
<Compile
Include=
"Page_ErrorNewestTable.xaml.cs"
>
...
...
Project.FLY.Winder_20190413/FLY.Winder.UI.Client/Page_ErrorNewestTable.xaml.cs
View file @
21640179
using
FLY.OBJComponents.Client
;
using
FLY.OBJComponents.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
...
...
@@ -23,8 +25,8 @@ namespace FLY.Winder.UI.Client
public
partial
class
Page_ErrorNewestTable
:
Page
{
FLY
.
OBJComponents
.
Client
.
WarningServiceClient
mWarningService
;
FLY
.
OBJComponents
.
Client
.
BufferWindow
<
FLY
.
OBJComponents
.
Common
.
FlyData_WarningHistory
>
mWindow
;
WarningServiceClient
mWarningService
;
BufferWindow
<
FlyData_WarningHistory
>
mWindow
;
public
Page_ErrorNewestTable
()
{
...
...
@@ -36,7 +38,13 @@ namespace FLY.Winder.UI.Client
void
Init
()
{
mWarningService
=
TDGage
.
Current
.
mWarningService
;
mWindow
=
new
OBJComponents
.
Client
.
BufferWindow
<
OBJComponents
.
Common
.
FlyData_WarningHistory
>(
mWarningService
.
NewestList
);
Common
.
BindingWindowSize
((
windowSize
)
=>
{
mWindow
=
new
BufferWindow
<
FlyData_WarningHistory
>(
mWarningService
.
NewestList
,
windowSize
);
return
mWindow
;
});
grid_window
.
DataContext
=
mWindow
;
}
...
...
Project.FLY.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml.cs
View file @
21640179
...
...
@@ -20,7 +20,8 @@ namespace FLY.Winder.UI.Server
public
partial
class
MainWindow
:
Window
{
FLY
.
AppHelper
.
WindowNotifyIconHelper
notifyiconhelper
;
FLY
.
Winder
.
Server
.
TDGage
mTDGage
;
FLY
.
Winder
.
Server
.
TDGage
gage
;
FLY
.
Winder
.
Server
.
OBJProxy
.
OBJProxy
oBJProxy
;
public
MainWindow
()
{
InitializeComponent
();
...
...
@@ -32,10 +33,11 @@ namespace FLY.Winder.UI.Server
this
.
Hide
();
FObjBase
.
PollModule
.
Current
.
Start
();
mTDGage
=
new
FLY
.
Winder
.
Server
.
TDGage
(
"Gage1"
);
gage
=
new
FLY
.
Winder
.
Server
.
TDGage
(
"Gage1"
);
oBJProxy
=
new
Winder
.
Server
.
OBJProxy
.
OBJProxy
(
0
,
gage
);
FLY
.
OBJComponents
.
Server
.
PLCProxySystem
plsos
=
mTDG
age
.
mData
.
PLCos
as
FLY
.
OBJComponents
.
Server
.
PLCProxySystem
;
g
age
.
mData
.
PLCos
as
FLY
.
OBJComponents
.
Server
.
PLCProxySystem
;
grid_plcos
.
DataContext
=
plsos
;
grid_plc
.
DataContext
=
plsos
.
PLCs
[
0
];
...
...
Project.FLY.Winder_20190413/FLY.Winder/FLY.Winder.csproj
View file @
21640179
...
...
@@ -55,7 +55,12 @@
<Compile
Include=
"OBJ_INTERFACE\WINDER_OBJ_INTERFACE.cs"
/>
<Compile
Include=
"OBJ_INTERFACE\OBJ_INTERFACE.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Server.OBJProxy\OBJProxy.cs"
/>
<Compile
Include=
"Server.OBJProxy\WinderSystem_OBJProxy.cs"
/>
<Compile
Include=
"Server\Model\DbModel.cs"
/>
<Compile
Include=
"Server\Model\DbTable.cs"
/>
<Compile
Include=
"Server\Model\HistoryDb.cs"
/>
<Compile
Include=
"Server\SysParam.cs"
/>
<Compile
Include=
"Server\TDGage.cs"
/>
<Compile
Include=
"Server\WinderSystem.cs"
/>
</ItemGroup>
...
...
@@ -79,6 +84,10 @@
<Project>
{a539505d-9ac0-426b-a9a0-197df50598b0}
</Project>
<Name>
OBJComponents
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\..\thick_public\Project.SQLiteHelper\SQLiteHelper\SQLiteHelper.csproj"
>
<Project>
{4CBABFAA-1C62-4510-AC63-A51EE5FD50FF}
</Project>
<Name>
SQLiteHelper
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference
Include=
"Newtonsoft.Json"
>
...
...
Project.FLY.Winder_20190413/FLY.Winder/OBJ_INTERFACE/OBJ_INTERFACE.cs
View file @
21640179
...
...
@@ -21,5 +21,8 @@ namespace FLY.Winder.OBJ_INTERFACE
/// 2个
/// </summary>
public
const
UInt32
WINDER_OBJ_PLCOS_ID
=
0x001f0210
;
public
const
UInt32
WINDER_OBJ_INFOLIST_ID
=
0x001f0220
;
}
}
Project.FLY.Winder_20190413/FLY.Winder/Server.OBJProxy/OBJProxy.cs
0 → 100644
View file @
21640179
using
FLY.OBJComponents.Server.OBJProxy
;
using
FLY.Winder.Server.Model
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
FLY.Winder.Server.OBJProxy
{
public
class
OBJProxy
{
WinderSystem_OBJProxy
winderSystemOBJProxy
;
Buffer_OBJProxy
<
Db_WinderInfo
>
mInfoListOBJProxy
;
WarningSystem_OBJProxy
mWarnSystemOBJProxy
;
public
OBJProxy
(
int
objsys_idx
,
TDGage
gage
)
{
TDGage
mGage
=
gage
;
winderSystemOBJProxy
=
new
WinderSystem_OBJProxy
(
objsys_idx
,
gage
.
mData
);
mInfoListOBJProxy
=
new
Buffer_OBJProxy
<
Db_WinderInfo
>(
objsys_idx
,
OBJ_INTERFACE
.
OBJ_INTERFACE
.
WINDER_OBJ_INFOLIST_ID
,
gage
.
mHistoryDb
.
WinderInfoBuffer
);
mWarnSystemOBJProxy
=
new
WarningSystem_OBJProxy
(
objsys_idx
,
OBJ_INTERFACE
.
OBJ_INTERFACE
.
WARNING_OBJ_ID
,
gage
.
mWarning
);
winderSystemOBJProxy
.
CurrObjSys
.
Start_Conn_Server
(
new
IPEndPoint
(
IPAddress
.
Any
,
gage
.
mSysParam
.
OBJ_Port
),
winderSystemOBJProxy
.
ID
);
}
}
}
Project.FLY.Winder_20190413/FLY.Winder/Server/Model/DbModel.cs
0 → 100644
View file @
21640179
using
FLY.OBJComponents.Server.Model
;
using
SQLite
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
FLY.Winder.Server.Model
{
/// <summary>
/// 数据库对象
/// </summary>
public
class
DbModel
:
SQLiteDbContext
,
IErrorDBModel
{
/// <summary>
/// Width表 对象
/// </summary>
public
DBTable
<
Db_WinderInfo
>
TbWinderInfo
{
get
;
}
=
new
DBTable
<
Db_WinderInfo
>();
/// <summary>
/// Error表 对象
/// </summary>
public
DBTable
<
DB_Error
>
TbError
{
get
;
}
=
new
DBTable
<
DB_Error
>();
/// <summary>
///
/// </summary>
/// <param name="dbpath">sqlite数据库路径</param>
public
DbModel
(
string
dbpath
)
:
base
(
dbpath
)
{
}
/// <summary>
///
/// </summary>
public
DbModel
()
:
this
(
@"D:\blowingdata\winder.sqlite3"
)
{
}
}
}
Project.FLY.Winder_20190413/FLY.Winder/Server/Model/DbTable.cs
0 → 100644
View file @
21640179
using
SQLite
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel.DataAnnotations
;
using
System.ComponentModel.DataAnnotations.Schema
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
FLY.Winder.Server.Model
{
/// <summary>
/// 收卷表
/// </summary>
[
Table
(
"WinderInfo"
)]
public
class
Db_WinderInfo
:
IDbBase
{
[
Key
]
[
PropertyIndex
(
0
)]
public
Int64
ID
{
get
;
set
;
}
/// <summary>
/// 时间
/// </summary>
[
PropertyIndex
(
1
)]
public
DateTime
Time
{
get
;
set
;
}
/// <summary>
/// 线速度 m/min
/// </summary>
[
PropertyIndex
(
2
)]
public
double
Velocity
{
get
;
set
;
}
/// <summary>
/// 上牵引电流 单位 A
/// </summary>
[
PropertyIndex
(
2
)]
public
double
Traction1Current
{
get
;
set
;
}
/// <summary>
/// 二牵引电流 单位 A
/// </summary>
[
PropertyIndex
(
3
)]
public
double
Traction2Current
{
get
;
set
;
}
/// <summary>
/// 内收卷电流 单位 A
/// </summary>
[
PropertyIndex
(
4
)]
public
double
Winder0Current
{
get
;
set
;
}
/// <summary>
/// 外收卷电流 单位 A
/// </summary>
[
PropertyIndex
(
5
)]
public
double
Winder1Current
{
get
;
set
;
}
/// <summary>
/// 二牵引实际张力 单位 Kg
/// </summary>
[
PropertyIndex
(
6
)]
public
double
Traction2TensionKg
{
get
;
set
;
}
/// <summary>
/// 内收卷实际张力 单位 Kg
/// </summary>
[
PropertyIndex
(
7
)]
public
double
Winder0TensionKg
{
get
;
set
;
}
/// <summary>
/// 外收卷实际张力 单位 Kg
/// </summary>
[
PropertyIndex
(
8
)]
public
double
Winder1TensionKg
{
get
;
set
;
}
/// <summary>
/// 旋转塔电流 单位 A
/// </summary>
[
PropertyIndex
(
9
)]
public
double
RotaryCurrent
{
get
;
set
;
}
/// <summary>
/// 旋转塔频率 单位 Hz
/// </summary>
[
PropertyIndex
(
10
)]
public
double
RotaryFreq
{
get
;
set
;
}
/// <summary>
/// 旋转塔正转
/// </summary>
[
PropertyIndex
(
11
)]
public
bool
IsRotaryForw
{
get
;
set
;
}
/// <summary>
/// 旋转塔反转
/// </summary>
[
PropertyIndex
(
12
)]
public
bool
IsRotaryBackw
{
get
;
set
;
}
}
}
Project.FLY.Winder_20190413/FLY.Winder/Server/Model/HistoryDb.cs
0 → 100644
View file @
21640179
using
FLY.OBJComponents.Server
;
using
FLY.OBJComponents.Server.Model
;
using
FObjBase
;
using
SQLite
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
FLY.Winder.Server.Model
{
/// <summary>
/// 数据库 写操作
/// </summary>
public
class
HistoryDb
{
DbModel
dbModel
;
public
BufferSQLite
<
Db_WinderInfo
>
WinderInfoBuffer
;
public
BufferError
ErrorBuffer
;
/// <summary>
///
/// </summary>
/// <param name="dBModel"></param>
public
void
Init
(
DbModel
dBModel
)
{
this
.
dbModel
=
dBModel
;
WinderInfoBuffer
=
new
BufferSQLite
<
Db_WinderInfo
>();
WinderInfoBuffer
.
Init
(
dBModel
.
TbWinderInfo
);
ErrorBuffer
=
new
BufferError
();
ErrorBuffer
.
Init
(
dBModel
.
TbError
);
}
/// <summary>
/// 按时间删除数据库
/// </summary>
/// <param name="month"></param>
public
void
KeepDBSize
(
int
month
)
{
if
(
month
<=
3
)
month
=
3
;
DateTime
del_time
=
DateTime
.
Now
-
TimeSpan
.
FromDays
(
month
*
30
);
string
det_time_str
=
del_time
.
ToStringOfSQLiteFieldType
();
List
<
string
>
sqls
=
new
List
<
string
>();
sqls
.
Add
(
$"DELETE FROM
{
dbModel
.
TbWinderInfo
.
TableName
}
"
+
$" WHERE EndTime <
{
det_time_str
}
"
);
sqls
.
Add
(
$"DELETE FROM
{
dbModel
.
TbError
.
TableName
}
"
+
$" WHERE Time <
{
det_time_str
}
"
);
dbModel
.
sqliteHelper
.
QueryTran
(
sqls
);
}
public
void
AddWinderInfo
(
Db_WinderInfo
winderInfo
)
{
WinderInfoBuffer
.
Add
(
winderInfo
);
}
public
void
AddWinderInfos
(
IEnumerable
<
Db_WinderInfo
>
winderInfos
)
{
WinderInfoBuffer
.
AddRange
(
winderInfos
);
}
}
}
Project.FLY.Winder_20190413/FLY.Winder/Server/SysParam.cs
0 → 100644
View file @
21640179
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
FLY.Winder.Server
{
public
class
SysParam
:
Misc
.
ISaveToXml
{
/// <summary>
/// OBJ服务端口
/// </summary>
public
int
OBJ_Port
{
get
;
set
;
}
=
20004
;
/// <summary>
/// 数据库保持时间 默认6个月
/// </summary>
public
int
DBKeepMonth
{
get
;
set
;
}
=
6
;
public
SysParam
()
{
Load
();
}
public
void
Save
()
{
Misc
.
SaveToXmlHepler
.
Save
(
"system.xml"
,
this
);
}
public
void
Load
()
{
Misc
.
SaveToXmlHepler
.
Load
(
"system.xml"
,
this
);
}
public
string
[]
GetSavePropertyNames
()
{
return
new
string
[]{
"OBJ_Port"
,
"DBKeepMonth"
};
}
}
}
Project.FLY.Winder_20190413/FLY.Winder/Server/TDGage.cs
View file @
21640179
...
...
@@ -7,27 +7,30 @@ using System.Linq;
using
System.Net
;
using
System.Text
;
using
System.Threading.Tasks
;
using
FLY.Winder.Server.Model
;
using
FLY.OBJComponents.Server
;
namespace
FLY.Winder.Server
{
public
class
TDGage
:
Misc
.
ISaveToXml
public
class
TDGage
{
#
region
初始化
------------------------------------------------------------------
public
string
mParamDirectory
;
//参数目录 m_path;//数据文件的 根目录默认是 Gage1
public
string
mName
;
//名字 如:gage0
#
endregion
#
region
服务器数据
--------------------------------------------------------------
public
SysParam
mSysParam
;
public
WinderSystem
mData
;
/// <summary>
///
OBJ服务端口
///
报警系统
/// </summary>
public
int
OBJ_Port
{
get
;
set
;
}
public
WinderSystem
mData
;
WinderSystem_OBJProxy
mServerOBJProxy
;
WarningSystem_OBJProxy
mWarnSystemOBJProxy
;
public
WarningSystem
mWarning
;
public
HistoryDb
mHistoryDb
;
DbModel
mDbModel
;
#
endregion
public
TDGage
(
string
nam
)
{
...
...
@@ -49,51 +52,27 @@ namespace FLY.Winder.Server
/// </summary>
public
void
Init1
()
{
OBJ_Port
=
20004
;
Load
();
#
region
提取保存的数据
mSysParam
=
new
SysParam
();
mData
=
new
WinderSystem
();
mServerOBJProxy
=
new
WinderSystem_OBJProxy
(
0
,
mData
);
mWarnSystemOBJProxy
=
new
WarningSystem_OBJProxy
(
0
,
OBJ_INTERFACE
.
OBJ_INTERFACE
.
WARNING_OBJ_ID
,
mData
.
mWarning
);
#
endregion
Init2
();
//---------------------------------------------------------------------------------------------------------------
//数据库
mDbModel
=
new
DbModel
();
mDbModel
.
Init
();
}
/// <summary>
/// 第2步, 连接到服务器,初始化参数 。由界面的 【登陆】 按钮触发
/// </summary>
private
void
Init2
()
{
#
region
网络初始化
FObjSys
.
Current
.
Start_Conn_Server
(
new
IPEndPoint
(
IPAddress
.
Any
,
OBJ_Port
),
mServerOBJProxy
.
ID
);
mHistoryDb
=
new
HistoryDb
();
mHistoryDb
.
Init
(
mDbModel
);
mHistoryDb
.
KeepDBSize
(
mSysParam
.
DBKeepMonth
);
#
endregion
}
mWarning
=
new
WarningSystem
(
mHistoryDb
.
ErrorBuffer
);
#
endregion
mData
.
Init
(
mHistoryDb
,
mWarning
);
public
void
Save
()
{
Misc
.
SaveToXmlHepler
.
Save
(
"system.xml"
,
this
);
}
public
void
Load
()
{
Misc
.
SaveToXmlHepler
.
Load
(
"system.xml"
,
this
);
}
#
region
ISaveToXml
成员
public
string
[]
GetSavePropertyNames
()
{
return
new
string
[]{
"OBJ_Port"
};
}
#
endregion
}
}
Project.FLY.Winder_20190413/FLY.Winder/Server/WinderSystem.cs
View file @
21640179
...
...
@@ -4,10 +4,12 @@ using FLY.OBJComponents.IService;
using
FLY.OBJComponents.Server
;
using
FLY.Winder.Common
;
using
FLY.Winder.IService
;
using
FLY.Winder.Server.Model
;
using
FObjBase
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -38,34 +40,34 @@ namespace FLY.Winder.Server
/// <summary>
/// 报警系统
/// </summary>
public
WarningSystem
mWarning
;
WarningSystem
mWarning
;
HistoryDb
mHistoryDb
;
static
WinderSystem
()
{
//Misc.SaveToXmlHepler.Regist(typeof(WinderSystemParams));
}
public
WinderSystem
()
{
Items
=
new
List
<
WinderInsideOutside
>();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Items
.
Add
(
new
WinderInsideOutside
());
}
Accessory
=
new
WinderAccessory
();
//加载PLC寄存器 文件
AddConfigFile
(
"WS.xml"
);
mWarning
=
new
WarningSystem
();
AddConfigFile
(
"WS.xml"
);
}
public
void
Init
(
HistoryDb
historyDb
,
WarningSystem
warning
)
{
mHistoryDb
=
historyDb
;
mWarning
=
warning
;
//--------------------------------------------------------------------------------
//报警配置
InitError
();
plcos
.
Init
();
FObjBase
.
PollModule
.
Current
.
Poll_Config
(
FObjBase
.
PollModule
.
POLL_CONFIG
.
ADD
,
OnPoll
,
TimeSpan
.
FromSeconds
(
1
));
plcos
.
Init
();
}
#
region
报警
class
ErrorAction
...
...
@@ -224,6 +226,13 @@ namespace FLY.Winder.Server
plcos
.
PLCs
.
Add
(
plc
);
}
Items
=
new
List
<
WinderInsideOutside
>();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Items
.
Add
(
new
WinderInsideOutside
());
}
Accessory
=
new
WinderAccessory
();
//objname 转 obj
PLCos
.
ObjNames
.
Add
(
"Accessory"
,
Accessory
);
for
(
int
i
=
0
;
i
<
Items
.
Count
();
i
++)
...
...
@@ -255,5 +264,77 @@ namespace FLY.Winder.Server
}
Stopwatch
stopwatch_infoInterval
=
new
Stopwatch
();
Stopwatch
stopwatch_1min
=
new
Stopwatch
();
List
<
Db_WinderInfo
>
dbInfo_1min
=
new
List
<
Db_WinderInfo
>();
void
OnPoll
()
{
if
(
stopwatch_1min
.
IsRunning
&&
stopwatch_1min
.
Elapsed
>=
TimeSpan
.
FromSeconds
(
60
))
{
//启动了1min 且到点了
if
(
dbInfo_1min
.
Count
>
0
)
{
mHistoryDb
.
AddWinderInfos
(
dbInfo_1min
);
dbInfo_1min
.
Clear
();
stopwatch_1min
.
Restart
();
}
else
{
stopwatch_1min
.
Reset
();
}
}
if
(!
stopwatch_infoInterval
.
IsRunning
)
{
stopwatch_infoInterval
.
Start
();
return
;
}
else
{
if
(
stopwatch_infoInterval
.
Elapsed
<
TimeSpan
.
FromSeconds
(
10
))
return
;
else
stopwatch_infoInterval
.
Restart
();
}
if
(!
PLCos
.
IsConnectedWithPLC
)
//连接断开
return
;
if
(
Accessory
.
Velocity
<
2
)
//没有生产
return
;
//记录数据
Db_WinderInfo
db_WinderInfo
=
new
Db_WinderInfo
{
Time
=
DateTime
.
Now
,
Velocity
=
Math
.
Round
(
Accessory
.
Velocity
,
1
),
Traction1Current
=
Math
.
Round
(
Accessory
.
Traction1Current
,
1
),
Traction2Current
=
Math
.
Round
(
Accessory
.
Traction2Current
,
1
),
Winder0Current
=
Math
.
Round
(
Items
[
0
].
Current
,
1
),
Winder1Current
=
Math
.
Round
(
Items
[
1
].
Current
,
1
),
Traction2TensionKg
=
Math
.
Round
(
Accessory
.
Traction2TensionKg
,
1
),
Winder0TensionKg
=
Math
.
Round
(
Items
[
0
].
TensionKg
,
1
),
Winder1TensionKg
=
Math
.
Round
(
Items
[
1
].
TensionKg
,
1
),
RotaryCurrent
=
Math
.
Round
(
Accessory
.
RotaryCurrent
,
1
),
RotaryFreq
=
Math
.
Round
(
Accessory
.
RotaryFreq
,
1
),
IsRotaryForw
=
Accessory
.
IsRotaryForw
,
IsRotaryBackw
=
Accessory
.
IsRotaryBackw
};
//写入数据库
if
(!
stopwatch_1min
.
IsRunning
)
{
//第1次立刻写入
mHistoryDb
.
AddWinderInfo
(
db_WinderInfo
);
stopwatch_1min
.
Start
();
}
else
{
//第2次,1分钟后才能保存
dbInfo_1min
.
Add
(
db_WinderInfo
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment