Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
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
潘栩锋
Thick-Common
Commits
5fb77f45
Commit
5fb77f45
authored
May 19, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 flyad7 在电脑端保存的数据,由flyad7自己保存
parent
61d4d781
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
62 deletions
+88
-62
FlyAD7.cs
Project.FLY.FlyADBase/FlyADBase/FlyAD7.cs
+77
-11
FlyADClientAdv.cs
Project.FLY.FlyADBase/FlyADBase/FlyADClientAdv.cs
+1
-1
PgFlyAd.xaml.cs
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgFlyAd.xaml.cs
+3
-0
FlyADServiceClient.cs
...LY.Thick.Base/FLY.Thick.Base/Client/FlyADServiceClient.cs
+2
-2
IFlyADService.cs
...t.FLY.Thick.Base/FLY.Thick.Base/IService/IFlyADService.cs
+1
-0
SysParam.cs
Project.FLY.Thick.Base/FLY.Thick.Base/Server/SysParam.cs
+4
-48
No files found.
Project.FLY.FlyADBase/FlyADBase/FlyAD7.cs
View file @
5fb77f45
...
...
@@ -25,6 +25,7 @@ namespace FlyADBase
const
int
MARKNO_SET_VELOCITY
=
1
;
const
int
MARKNO_SET_ZEROPOS
=
2
;
const
int
MARKNO_SET_SYSPARAM
=
3
;
const
int
MARKNO_SET_SAVE
=
4
;
#
endregion
#
region
成员变量
...
...
@@ -814,7 +815,7 @@ namespace FlyADBase
}
break
;
}
_end_push_info
:
_end_push_info
:
bShieldSetValueEx
=
false
;
}
...
...
@@ -941,7 +942,7 @@ namespace FlyADBase
/// <summary>
/// AD盒版本号 版本1 没有systick;版本2 有systick;
/// </summary>
public
int
Version
public
int
Version
{
get
{
if
(
pos1_version
==
2
...
...
@@ -1087,17 +1088,17 @@ namespace FlyADBase
/// <summary>
/// 脉冲/grid, 最大1000个grid
/// </summary>
public
UInt16
PosOfGrid
public
UInt16
PosOfGrid
{
get
{
return
posofgrid
;
}
set
{
if
(
value
<
1
)
value
=
1
;
if
(
posofgrid
!=
value
)
posofgrid
=
value
;
}
}
...
...
@@ -1335,7 +1336,7 @@ namespace FlyADBase
/// <summary>
/// 之前运行动作的状态
/// </summary>
public
DRIVE_MAN_STATUS
DriveStatus
{
get
;
set
;
}
=
DRIVE_MAN_STATUS
.
STOP
;
public
DRIVE_MAN_STATUS
DriveStatus
{
get
;
set
;
}
=
DRIVE_MAN_STATUS
.
STOP
;
#
endregion
...
...
@@ -1343,7 +1344,7 @@ namespace FlyADBase
void
Drive
(
DRIVE_MAN_ORDER
order
,
object
param
)
{
switch
(
order
)
{
case
DRIVE_MAN_ORDER
.
RUNTO
:
...
...
@@ -1443,7 +1444,7 @@ namespace FlyADBase
/// <summary>
/// 纵向偏移
/// </summary>
public
void
SetPos2Offset
(
int
offset
)
public
void
SetPos2Offset
(
int
offset
)
{
CurrObjSys
.
CallFunctionEx
(
conn
,
...
...
@@ -1466,7 +1467,7 @@ namespace FlyADBase
/// </summary>
/// <param name="pos2"></param>
/// <param name="immediately">只要是 01,就立刻修正</param>
public
void
SetPos2At01
(
int
pos2
,
bool
immediately
)
public
void
SetPos2At01
(
int
pos2
,
bool
immediately
)
{
CurrObjSys
.
CallFunctionEx
(
conn
,
...
...
@@ -1524,7 +1525,7 @@ namespace FlyADBase
ID
,
FLYAD7_OBJ_INTERFACE
.
DRIVE_MAN_INTERFACE
.
CALL_PXX
,
new
FLYAD7_OBJ_INTERFACE
.
DRIVE_MAN_INTERFACE
.
Pack_SyncClear
().
ToBytes
());
SyncOrders
.
Clear
();
}
...
...
@@ -1634,7 +1635,7 @@ namespace FlyADBase
});
}
/// <summary>
/// <summary>
/// 位于队列头时运行,以速度运行至逻辑位置;
/// D+0xE3+横向脉冲位置(4B:int32,逻辑位置)+速度(4B:int32)+脉冲开关(1B)+命令识标号(4B)
/// </summary>
...
...
@@ -1693,14 +1694,79 @@ namespace FlyADBase
#
endregion
#
endregion
private
static
string
[]
propertyName_save
=
new
string
[]
{
"LocalEP"
,
"HasCRC"
,
"GridSmooth"
,
"IsCalSpeed"
};
string
defaultPath
=
"flyad.json"
;
private
string
jsonDbPath
;
public
bool
Load
()
{
return
this
.
Load
(
defaultPath
);
}
public
bool
Load
(
string
jsonDbPath
)
{
this
.
jsonDbPath
=
jsonDbPath
;
this
.
PropertyChanged
-=
FlyAD7_PropertyChanged2
;
bool
ret
=
Load2
();
this
.
PropertyChanged
+=
FlyAD7_PropertyChanged2
;
return
ret
;
}
bool
Load2
()
{
if
(!
File
.
Exists
(
jsonDbPath
))
return
false
;
string
json
=
File
.
ReadAllText
(
jsonDbPath
);
try
{
var
db
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
FlyAD7JsonDb
>(
json
);
this
.
LocalEP
=
Misc
.
StringConverter
.
ToIPEndPoint
(
db
.
LocalEP
);
this
.
GridSmooth
=
db
.
GridSmooth
;
this
.
HasCRC
=
db
.
HasCRC
;
this
.
IsCalSpeed
=
db
.
IsCalSpeed
;
}
catch
(
Exception
e
)
{
return
false
;
}
return
true
;
}
private
void
FlyAD7_PropertyChanged2
(
object
sender
,
PropertyChangedEventArgs
e
)
{
if
(
propertyName_save
.
Contains
(
e
.
PropertyName
))
{
PollModule
.
Current
.
Poll_JustOnce
(()
=>
{
Save
();
},
this
,
MARKNO_SET_SAVE
);
}
}
void
Save
()
{
if
(
string
.
IsNullOrEmpty
(
jsonDbPath
))
return
;
FlyAD7JsonDb
db
=
new
FlyAD7JsonDb
()
{
LocalEP
=
LocalEP
.
ToString
(),
GridSmooth
=
GridSmooth
,
HasCRC
=
HasCRC
,
IsCalSpeed
=
IsCalSpeed
};
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
db
);
File
.
WriteAllText
(
jsonDbPath
,
json
);
}
}
public
class
FlyAD7JsonDb
{
public
string
LocalEP
=
"192.168.251.10:20006"
;
public
bool
HasCRC
=
false
;
public
int
GridSmooth
=
0
;
public
bool
IsCalSpeed
=
true
;
}
}
Project.FLY.FlyADBase/FlyADBase/FlyADClientAdv.cs
View file @
5fb77f45
...
...
@@ -18,7 +18,7 @@ namespace FlyADBase
/// <summary>
/// 通过脉冲计算速度,不使用AD盒的输出
/// </summary>
public
bool
IsCalSpeed
{
get
;
set
;
}
//
= true;
public
bool
IsCalSpeed
{
get
;
set
;
}
=
true
;
private
int
gridsmooth
=
0
;
/// <summary>
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgFlyAd.xaml.cs
View file @
5fb77f45
...
...
@@ -61,6 +61,7 @@ namespace FLY.Thick.Base.UI
public
Int16
PosOffset
{
set
;
get
;
}
//脉冲平移
public
UInt32
JogVelocity
{
set
;
get
;
}
public
int
GridSmooth
{
get
;
set
;
}
public
bool
IsCalSpeed
{
get
;
set
;
}
#
endregion
public
int
TargetPos
{
get
;
set
;
}
...
...
@@ -103,6 +104,7 @@ namespace FLY.Thick.Base.UI
Misc
.
BindingOperations
.
SetBinding
(
this
.
flyAdService
,
"PosOffset"
,
this
,
"PosOffset"
);
Misc
.
BindingOperations
.
SetBinding
(
this
.
flyAdService
,
"JogVelocity"
,
this
,
"JogVelocity"
);
Misc
.
BindingOperations
.
SetBinding
(
this
.
flyAdService
,
"GridSmooth"
,
this
,
"GridSmooth"
);
Misc
.
BindingOperations
.
SetBinding
(
this
.
flyAdService
,
"IsCalSpeed"
,
this
,
"IsCalSpeed"
);
}
private
void
Apply
()
{
...
...
@@ -118,6 +120,7 @@ namespace FLY.Thick.Base.UI
flyAdService
.
PosOffset
=
this
.
PosOffset
;
flyAdService
.
JogVelocity
=
this
.
JogVelocity
;
flyAdService
.
GridSmooth
=
this
.
GridSmooth
;
flyAdService
.
IsCalSpeed
=
this
.
IsCalSpeed
;
flyAdService
.
Apply
();
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"应用成功"
,
null
,
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Client/FlyADServiceClient.cs
View file @
5fb77f45
...
...
@@ -45,11 +45,11 @@ namespace FLY.Thick.Base.Client
/// <summary>
/// 通过脉冲计算速度,不使用AD盒的输出
/// </summary>
public
bool
IsCalSpeed
{
get
;
set
;
}
=
true
;
public
bool
IsCalSpeed
{
get
;
set
;
}
public
int
PosLen
{
get
;
set
;
}
public
MOTORTYPE
MotorType
{
get
;
set
;
}
=
MOTORTYPE
.
SERVO
;
public
MOTORTYPE
MotorType
{
get
;
set
;
}
/// <summary>
/// // 单位 pulse/grid
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/IService/IFlyADService.cs
View file @
5fb77f45
...
...
@@ -23,6 +23,7 @@ namespace FLY.Thick.Base.IService
Int16
PosOffset
{
set
;
get
;
}
//脉冲平移
UInt32
JogVelocity
{
set
;
get
;
}
int
GridSmooth
{
get
;
set
;
}
bool
IsCalSpeed
{
get
;
set
;
}
/// <summary>
/// 参数应用
/// </summary>
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Server/SysParam.cs
View file @
5fb77f45
...
...
@@ -22,68 +22,28 @@ namespace FLY.Thick.Base.Server
[
PropertyChanged
.
DoNotCheckEquality
]
public
IPEndPoint
LocalEP
{
get
;
set
;
}
=
Misc
.
StringConverter
.
ToIPEndPoint
(
"127.0.0.1:20006"
);
/// <summary>
/// AD盒地址
/// </summary>
[
PropertyChanged
.
DoNotCheckEquality
]
public
IPEndPoint
FLYAD7EP
{
get
;
set
;
}
=
Misc
.
StringConverter
.
ToIPEndPoint
(
"192.168.250.10:20006"
);
/// <summary>
/// AD盒通讯使用 CRC校验
/// </summary>
public
bool
FLYAD7_HasCRC
{
get
;
set
;
}
=
false
;
/// <summary>
/// grid 平滑
/// </summary>
public
int
FLYAD7_GridSmooth
{
get
;
set
;
}
=
0
;
/// <summary>
/// 电脑计算速度,不通过AD盒获取
/// </summary>
public
bool
FLYAD7_IsCalSpeed
{
get
;
set
;
}
=
true
;
#
endregion
private
string
param_path
=
"sysparam.xml"
;
public
SysParam
()
{
this
.
PropertyChanged
+=
new
PropertyChangedEventHandler
(
SysParam_PropertyChanged
);
}
public
SysParam
(
string
param_path
)
{
if
(!
string
.
IsNullOrEmpty
(
param_path
))
this
.
param_path
=
param_path
;
Load
();
this
.
PropertyChanged
+=
new
PropertyChangedEventHandler
(
SysParam_PropertyChanged
);
}
void
SysParam_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
if
(
isLoading
)
return
;
if
((
e
.
PropertyName
==
"FLYAD7EP"
)||
(
e
.
PropertyName
==
"FLYAD7_HasCRC"
)||
(
e
.
PropertyName
==
"FLYAD7_GridSmooth"
)||
(
e
.
PropertyName
==
"FLYAD7_IsCalSpeed"
)
)
{
Save
();
}
}
bool
isLoading
=
false
;
public
bool
Load
()
{
isLoading
=
true
;
bool
ret
=
Misc
.
SaveToXmlHepler
.
Load
(
param_path
,
this
);
isLoading
=
false
;
return
ret
;
}
public
void
Save
()
{
Misc
.
SaveToXmlHepler
.
Save
(
param_path
,
this
);
}
#
region
INotifyPropertyChanged
成员
public
event
PropertyChangedEventHandler
PropertyChanged
;
...
...
@@ -93,11 +53,7 @@ namespace FLY.Thick.Base.Server
public
string
[]
GetSavePropertyNames
()
{
return
new
string
[]{
"LocalEP"
,
"FLYAD7EP"
,
"FLYAD7_HasCRC"
,
"FLYAD7_GridSmooth"
,
"FLYAD7_IsCalSpeed"
"LocalEP"
};
}
}
...
...
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