Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosConnectRoot
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
station
YeeAmosConnectRoot
Commits
4de510b1
Commit
4de510b1
authored
May 22, 2020
by
高东东
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
104bug修改
parent
7250c178
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
281 additions
and
207 deletions
+281
-207
ClientHandler.java
...ava/com/yeejoin/amos/iec104/tcp/client/ClientHandler.java
+4
-1
IEC104NewHandler.java
.../com/yeejoin/amos/iec104/tcp/client/IEC104NewHandler.java
+5
-1
ApduQueue.java
.../com/yeejoin/amos/iec104/tcp/client/invoke/ApduQueue.java
+224
-204
IeShort.java
...main/java/com/yeejoin/amos/iec104/tcp/entity/IeShort.java
+37
-0
InformationObject.java
...com/yeejoin/amos/iec104/tcp/entity/InformationObject.java
+11
-1
No files found.
YeeAmosIec104IntfServer/src/main/java/com/yeejoin/amos/iec104/tcp/client/ClientHandler.java
View file @
4de510b1
...
...
@@ -87,7 +87,10 @@ public class ClientHandler extends SimpleChannelInboundHandler<Apdu>{
connetOk
=
false
;
}
else
if
(
apdu
.
getApciType
()
==
Apdu
.
ApciType
.
TESTFR_ACT
)
{
ctx
.
channel
().
writeAndFlush
(
"680483000000"
,
promise
);
if
(
startZZ
)
{
startZZ
=
false
;
sendZzCommand
();
}
Logger
.
getLogger
(
this
.
getClass
()).
debug
(
"确认测试消息,U类型"
);
}
else
if
(
apdu
.
getApciType
()
==
Apdu
.
ApciType
.
STARTDT_CON
)
{
Logger
.
getLogger
(
this
.
getClass
()).
debug
(
"启动确认帧回复,U类型"
);
...
...
YeeAmosIec104IntfServer/src/main/java/com/yeejoin/amos/iec104/tcp/client/IEC104NewHandler.java
View file @
4de510b1
...
...
@@ -70,7 +70,11 @@ public class IEC104NewHandler extends SimpleChannelInboundHandler<Apdu>{
close
();
}
else
if
(
apdu
.
getApciType
()
==
Apdu
.
ApciType
.
TESTFR_ACT
)
{
handleBlockingSendQueue
.
add
(
"680483000000"
);
Logger
.
getLogger
(
this
.
getClass
()).
debug
(
"确认测试消息,U类型"
);
if
(
eecruiting_Communication
==
null
)
{
eecruiting_Communication
=
Executors
.
newSingleThreadScheduledExecutor
();
eecruiting_Communication
.
scheduleAtFixedRate
(
Recruiting_runnable
,
Constant
.
Z_Z_INITIALDELAY
,
Constant
.
Z_Z_PREIOD
,
TimeUnit
.
SECONDS
);
}
Logger
.
getLogger
(
this
.
getClass
()).
debug
(
"确认测试消息,U类型"
);
}
else
if
(
apdu
.
getApciType
()
==
Apdu
.
ApciType
.
STARTDT_CON
)
{
Logger
.
getLogger
(
this
.
getClass
()).
debug
(
"启动确认帧回复,U类型"
);
if
(
startService
!=
null
)
{
...
...
YeeAmosIec104IntfServer/src/main/java/com/yeejoin/amos/iec104/tcp/client/invoke/ApduQueue.java
View file @
4de510b1
...
...
@@ -6,226 +6,246 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ScheduledExecutorService
;
import
com.yeejoin.amos.iec104.tcp.entity.*
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.BeanUtils
;
import
com.yeejoin.amos.iec104.business.entity.mybatis.RecData
;
import
com.yeejoin.amos.iec104.tcp.entity.Apdu
;
import
com.yeejoin.amos.iec104.tcp.entity.Asdu
;
import
com.yeejoin.amos.iec104.tcp.entity.IeCP56Time2a
;
import
com.yeejoin.amos.iec104.tcp.entity.IeQuality
;
import
com.yeejoin.amos.iec104.tcp.entity.IeShortFloat
;
import
com.yeejoin.amos.iec104.tcp.entity.IeSinglePointWithQuality
;
import
com.yeejoin.amos.iec104.tcp.entity.InformationElement
;
import
com.yeejoin.amos.iec104.tcp.entity.InformationObject
;
import
com.yeejoin.amos.iec104.tcp.entity.ServerData
;
public
class
ApduQueue
{
private
static
final
BlockingQueue
<
ServerData
>
blockingQueue
=
new
LinkedBlockingQueue
<
ServerData
>();
ScheduledExecutorService
service_apdu
=
null
;
private
volatile
static
ApduQueue
instance
=
null
;
private
ApduQueue
()
{}
public
static
ApduQueue
getInstance
(){
//先检查实例是否存在,如果不存在才进入下面的同步块
if
(
instance
==
null
){
//同步块,线程安全的创建实例
synchronized
(
ApduQueue
.
class
){
//再次检查实例是否存在,如果不存在才真的创建实例
if
(
instance
==
null
){
instance
=
new
ApduQueue
();
}
}
}
return
instance
;
private
static
final
BlockingQueue
<
ServerData
>
blockingQueue
=
new
LinkedBlockingQueue
<
ServerData
>();
ScheduledExecutorService
service_apdu
=
null
;
private
volatile
static
ApduQueue
instance
=
null
;
private
ApduQueue
()
{
}
public
static
ApduQueue
getInstance
()
{
//先检查实例是否存在,如果不存在才进入下面的同步块
if
(
instance
==
null
)
{
//同步块,线程安全的创建实例
synchronized
(
ApduQueue
.
class
)
{
//再次检查实例是否存在,如果不存在才真的创建实例
if
(
instance
==
null
)
{
instance
=
new
ApduQueue
();
}
}
}
return
instance
;
}
/**
* 启动apdu数据消费任务
*/
public
void
start
()
{
service_apdu
=
Executors
.
newSingleThreadScheduledExecutor
();
service_apdu
=
Executors
.
newSingleThreadScheduledExecutor
();
// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间
service_apdu
.
execute
(
task_runnable
);
service_apdu
.
execute
(
task_runnable
);
}
public
void
add
(
ServerData
apdu
)
{
blockingQueue
.
add
(
apdu
);
}
public
void
add
(
ServerData
apdu
)
{
blockingQueue
.
add
(
apdu
);
}
Runnable
task_runnable
=
new
Runnable
()
{
Runnable
task_runnable
=
new
Runnable
()
{
public
void
run
()
{
while
(
true
)
{
try
{
ServerData
serverData
=
blockingQueue
.
take
();
String
serverId
=
serverData
.
getServerId
();
Apdu
apdu
=
serverData
.
getApdu
();
if
(
apdu
.
getApciType
()
==
Apdu
.
ApciType
.
I_FORMAT
)
{
Asdu
asdu
=
apdu
.
getAsdu
();
int
numberOfSequenceElements
=
0
;
switch
(
asdu
.
getTypeId
())
{
// 1 单点遥信
case
1
:
InformationObject
[]
informationObjects
=
asdu
.
getInformationObjects
();
for
(
InformationObject
obj
:
informationObjects
)
{
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
asdu
.
isSequenceOfElements
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
1
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeSinglePointWithQuality
singlePoint
=
(
IeSinglePointWithQuality
)
informationElement
[
i
][
0
];
data
.
setIsBlocked
(
singlePoint
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
singlePoint
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
singlePoint
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
singlePoint
.
isInvalid
()
?
0
:
1
);
data
.
setValue
(
singlePoint
.
isOn
()
+
""
);
informationObjectAddress
++;
data
.
setQuality
(
singlePoint
.
toJson
().
toString
());
RecDataQueue
.
getInstance
().
add
(
data
);
}
}
break
;
// 13 浮点型遥测
case
13
:
InformationObject
[]
floatInformationObjects
=
asdu
.
getInformationObjects
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
floatInformationObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
while
(
true
)
{
try
{
ServerData
serverData
=
blockingQueue
.
take
();
String
serverId
=
serverData
.
getServerId
();
Apdu
apdu
=
serverData
.
getApdu
();
if
(
apdu
.
getApciType
()
==
Apdu
.
ApciType
.
I_FORMAT
)
{
Asdu
asdu
=
apdu
.
getAsdu
();
int
numberOfSequenceElements
=
0
;
switch
(
asdu
.
getTypeId
())
{
// 1 单点遥信
case
1
:
InformationObject
[]
informationObjects
=
asdu
.
getInformationObjects
();
for
(
InformationObject
obj
:
informationObjects
)
{
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
asdu
.
isSequenceOfElements
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
1
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeSinglePointWithQuality
singlePoint
=
(
IeSinglePointWithQuality
)
informationElement
[
i
][
0
];
data
.
setIsBlocked
(
singlePoint
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
singlePoint
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
singlePoint
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
singlePoint
.
isInvalid
()
?
0
:
1
);
data
.
setValue
(
singlePoint
.
isOn
()
+
""
);
informationObjectAddress
++;
data
.
setQuality
(
singlePoint
.
toJson
().
toString
());
RecDataQueue
.
getInstance
().
add
(
data
);
}
}
break
;
// 13 浮点型遥测
case
9
:
InformationObject
[]
shortfloatInformationObjects
=
asdu
.
getInformationObjects
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
shortfloatInformationObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
2
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeShort
shortFloat
=
(
IeShort
)
informationElement
[
0
][
0
];
IeQuality
ieQuality
=
(
IeQuality
)
informationElement
[
0
][
1
];
data
.
setValue
(
String
.
format
(
"%.2f"
,
shortFloat
.
getValue
()));
data
.
setQuality
(
ieQuality
.
toJson
().
toString
());
data
.
setIsBlocked
(
ieQuality
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
ieQuality
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
ieQuality
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
ieQuality
.
isInvalid
()
?
0
:
1
);
data
.
setIsOverflow
(
ieQuality
.
isOverflow
()
?
0
:
1
);
informationObjectAddress
++;
RecDataQueue
.
getInstance
().
add
(
data
);
// }
}
case
13
:
InformationObject
[]
floatInformationObjects
=
asdu
.
getInformationObjects
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
floatInformationObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
// for (int i = 0; i < numberOfSequenceElements; i++) {
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
2
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeShortFloat
shortFloat
=
(
IeShortFloat
)
informationElement
[
0
][
0
];
IeQuality
ieQuality
=
(
IeQuality
)
informationElement
[
0
][
1
];
data
.
setValue
(
shortFloat
.
getValue
()
+
""
);
data
.
setQuality
(
ieQuality
.
toJson
().
toString
());
data
.
setIsBlocked
(
ieQuality
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
ieQuality
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
ieQuality
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
ieQuality
.
isInvalid
()
?
0
:
1
);
data
.
setIsOverflow
(
ieQuality
.
isOverflow
()
?
0
:
1
);
informationObjectAddress
++;
RecDataQueue
.
getInstance
().
add
(
data
);
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
2
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeShortFloat
shortFloat
=
(
IeShortFloat
)
informationElement
[
0
][
0
];
IeQuality
ieQuality
=
(
IeQuality
)
informationElement
[
0
][
1
];
data
.
setValue
(
String
.
format
(
"%.2f"
,
shortFloat
.
getValue
())
);
data
.
setQuality
(
ieQuality
.
toJson
().
toString
());
data
.
setIsBlocked
(
ieQuality
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
ieQuality
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
ieQuality
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
ieQuality
.
isInvalid
()
?
0
:
1
);
data
.
setIsOverflow
(
ieQuality
.
isOverflow
()
?
0
:
1
);
informationObjectAddress
++;
RecDataQueue
.
getInstance
().
add
(
data
);
// }
}
break
;
// 21 浮点型遥测
case
21
:
InformationObject
[]
normalizedObjects
=
asdu
.
getInformationObjects
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
normalizedObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
2
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeShortFloat
shortFloat
=
(
IeShortFloat
)
informationElement
[
0
][
0
];
data
.
setValue
(
shortFloat
.
getValue
()
+
""
);
informationObjectAddress
++;
RecDataQueue
.
getInstance
().
add
(
data
);
}
break
;
// 30 带 CP56Time2a 时标的单点信息
case
30
:
InformationObject
[]
informationCP56Time2aObjects
=
asdu
.
getInformationObjects
();
// for (InformationObject obj : informationCP56Time2aObjects) {
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
informationCP56Time2aObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
// asdu.isSequenceOfElements();
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
1
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeSinglePointWithQuality
singlePoint
=
(
IeSinglePointWithQuality
)
informationElement
[
0
][
0
];
IeCP56Time2a
ieCP56Time2a
=
(
IeCP56Time2a
)
informationElement
[
0
][
1
];
data
.
setValue
(
singlePoint
.
isOn
()
+
""
);
data
.
setOccurTime
(
ieCP56Time2a
.
getDate
());
data
.
setSoe
(
1
);
data
.
setQuality
(
singlePoint
.
toJson
().
toString
());
data
.
setIsBlocked
(
singlePoint
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
singlePoint
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
singlePoint
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
singlePoint
.
isInvalid
()
?
0
:
1
);
Logger
.
getLogger
(
this
.
getClass
()).
debug
(
"31类型 I帧: "
+
data
.
toString
());
RecDataQueue
.
getInstance
().
add
(
data
);
// }
}
break
;
// 31 带 CP56Time2a 时标的双点信息
case
31
:
InformationObject
[]
twoInformationCP56Time2aObjects
=
asdu
.
getInformationObjects
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
//for (InformationObject obj : twoInformationCP56Time2aObjects) {
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
twoInformationCP56Time2aObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
asdu
.
isSequenceOfElements
();
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
1
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeSinglePointWithQuality
singlePoint
=
(
IeSinglePointWithQuality
)
informationElement
[
0
][
0
];
IeCP56Time2a
ieCP56Time2a
=
(
IeCP56Time2a
)
informationElement
[
0
][
2
];
data
.
setValue
(
singlePoint
.
isOn
()
+
""
);
data
.
setOccurTime
(
ieCP56Time2a
.
getDate
());
data
.
setQuality
(
singlePoint
.
toJson
().
toString
());
data
.
setIsBlocked
(
singlePoint
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
singlePoint
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
singlePoint
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
singlePoint
.
isInvalid
()
?
0
:
1
);
data
.
setSoe
(
1
);
RecDataQueue
.
getInstance
().
add
(
data
);
informationObjectAddress
++;
RecData
data1
=
new
RecData
();
BeanUtils
.
copyProperties
(
data
,
data1
);
data1
.
setInformationAddress
(
informationObjectAddress
);
IeSinglePointWithQuality
singlePoint1
=
(
IeSinglePointWithQuality
)
informationElement
[
0
][
1
];
data1
.
setQuality
(
singlePoint1
.
toJson
().
toString
());
RecDataQueue
.
getInstance
().
add
(
data1
);
//}
}
break
;
default
:
Logger
.
getLogger
(
this
.
getClass
()).
error
(
"其他类型 I帧: "
+
asdu
.
getTypeId
());
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Logger
.
getLogger
(
this
.
getClass
()).
error
(
e
.
getMessage
());
}
}
break
;
// 21 浮点型遥测
case
21
:
InformationObject
[]
normalizedObjects
=
asdu
.
getInformationObjects
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
normalizedObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
2
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeShortFloat
shortFloat
=
(
IeShortFloat
)
informationElement
[
0
][
0
];
data
.
setValue
(
String
.
format
(
"%.2f"
,
shortFloat
.
getValue
())
);
informationObjectAddress
++;
RecDataQueue
.
getInstance
().
add
(
data
);
}
break
;
// 30 带 CP56Time2a 时标的单点信息
case
30
:
InformationObject
[]
informationCP56Time2aObjects
=
asdu
.
getInformationObjects
();
// for (InformationObject obj : informationCP56Time2aObjects) {
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
informationCP56Time2aObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
// asdu.isSequenceOfElements();
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
1
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeSinglePointWithQuality
singlePoint
=
(
IeSinglePointWithQuality
)
informationElement
[
0
][
0
];
IeCP56Time2a
ieCP56Time2a
=
(
IeCP56Time2a
)
informationElement
[
0
][
1
];
data
.
setValue
(
singlePoint
.
isOn
()
+
""
);
data
.
setOccurTime
(
ieCP56Time2a
.
getDate
());
data
.
setSoe
(
1
);
data
.
setQuality
(
singlePoint
.
toJson
().
toString
());
data
.
setIsBlocked
(
singlePoint
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
singlePoint
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
singlePoint
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
singlePoint
.
isInvalid
()
?
0
:
1
);
Logger
.
getLogger
(
this
.
getClass
()).
debug
(
"31类型 I帧: "
+
data
.
toString
());
RecDataQueue
.
getInstance
().
add
(
data
);
// }
}
break
;
// 31 带 CP56Time2a 时标的双点信息
case
31
:
InformationObject
[]
twoInformationCP56Time2aObjects
=
asdu
.
getInformationObjects
();
numberOfSequenceElements
=
asdu
.
getSequenceLength
();
//for (InformationObject obj : twoInformationCP56Time2aObjects) {
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
InformationObject
obj
=
twoInformationCP56Time2aObjects
[
i
];
InformationElement
[][]
informationElement
=
obj
.
getInformationElements
();
int
informationObjectAddress
=
obj
.
getInformationObjectAddress
();
asdu
.
isSequenceOfElements
();
RecData
data
=
new
RecData
(
serverId
);
data
.
setCommonAddress
(
asdu
.
getCommonAddress
());
data
.
setCreatedTime
(
new
Date
());
data
.
setDataType
(
1
);
data
.
setInformationAddress
(
informationObjectAddress
);
IeSinglePointWithQuality
singlePoint
=
(
IeSinglePointWithQuality
)
informationElement
[
0
][
0
];
IeCP56Time2a
ieCP56Time2a
=
(
IeCP56Time2a
)
informationElement
[
0
][
2
];
data
.
setValue
(
singlePoint
.
isOn
()
+
""
);
data
.
setOccurTime
(
ieCP56Time2a
.
getDate
());
data
.
setQuality
(
singlePoint
.
toJson
().
toString
());
data
.
setIsBlocked
(
singlePoint
.
isBlocked
()
?
0
:
1
);
data
.
setIsSubstituted
(
singlePoint
.
isSubstituted
()
?
0
:
1
);
data
.
setIsNotTopical
(
singlePoint
.
isNotTopical
()
?
0
:
1
);
data
.
setIsInvalid
(
singlePoint
.
isInvalid
()
?
0
:
1
);
data
.
setSoe
(
1
);
RecDataQueue
.
getInstance
().
add
(
data
);
informationObjectAddress
++;
RecData
data1
=
new
RecData
();
BeanUtils
.
copyProperties
(
data
,
data1
);
data1
.
setInformationAddress
(
informationObjectAddress
);
IeSinglePointWithQuality
singlePoint1
=
(
IeSinglePointWithQuality
)
informationElement
[
0
][
1
];
data1
.
setQuality
(
singlePoint1
.
toJson
().
toString
());
RecDataQueue
.
getInstance
().
add
(
data1
);
//}
}
break
;
default
:
Logger
.
getLogger
(
this
.
getClass
()).
error
(
"其他类型 I帧: "
+
asdu
.
getTypeId
());
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Logger
.
getLogger
(
this
.
getClass
()).
error
(
e
.
getMessage
());
}
}
}
};
...
...
YeeAmosIec104IntfServer/src/main/java/com/yeejoin/amos/iec104/tcp/entity/IeShort.java
0 → 100644
View file @
4de510b1
package
com
.
yeejoin
.
amos
.
iec104
.
tcp
.
entity
;
import
io.netty.buffer.ByteBuf
;
import
java.io.IOException
;
public
class
IeShort
extends
InformationElement
{
private
final
float
value
;
public
IeShort
(
float
value
)
{
this
.
value
=
value
;
}
public
IeShort
(
ByteBuf
is
)
throws
IOException
{
value
=
Float
.
intBitsToFloat
((
is
.
readByte
()
&
0xff
)
|
((
is
.
readByte
()
&
0xff
)
<<
8
));
}
@Override
public
int
encode
(
byte
[]
buffer
,
int
i
)
{
int
tempVal
=
Float
.
floatToIntBits
(
value
);
buffer
[
i
++]
=
(
byte
)
tempVal
;
buffer
[
i
]
=
(
byte
)
(
tempVal
>>
8
);
return
2
;
}
public
float
getValue
()
{
return
value
;
}
@Override
public
String
toString
()
{
return
"短浮点数值: "
+
value
;
}
}
YeeAmosIec104IntfServer/src/main/java/com/yeejoin/amos/iec104/tcp/entity/InformationObject.java
View file @
4de510b1
...
...
@@ -40,6 +40,16 @@ public class InformationObject {
}
break
;
// 9 测量值, 规一化值
case
9
:
informationElements
=
new
InformationElement
[
numberOfSequenceElements
][
2
];
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
informationElements
[
i
][
0
]
=
new
IeShort
(
is
);
informationElements
[
i
][
1
]
=
new
IeQuality
(
is
);
log
.
debug
(
"9 浮点型遥测1: "
+
i
+
"--->"
+
informationElements
[
i
][
0
].
toString
());
log
.
debug
(
"9 浮点型遥测2: "
+
i
+
"--->"
+
informationElements
[
i
][
1
].
toString
());
}
break
;
// 13 浮点型遥测
case
13
:
informationElements
=
new
InformationElement
[
numberOfSequenceElements
][
2
];
...
...
@@ -54,7 +64,7 @@ public class InformationObject {
case
21
:
informationElements
=
new
InformationElement
[
numberOfSequenceElements
][
1
];
for
(
int
i
=
0
;
i
<
numberOfSequenceElements
;
i
++)
{
informationElements
[
i
][
0
]
=
new
IeShort
Float
(
is
);
informationElements
[
i
][
0
]
=
new
IeShort
(
is
);
log
.
debug
(
"21 浮点型遥测, 不带品质描述词的规一化值: "
+
i
+
"--->"
+
informationElements
[
i
][
0
].
toString
());
}
break
;
...
...
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