Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Penguidom
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
domotika
Penguidom
Commits
8722afa4
Commit
8722afa4
authored
Jan 10, 2018
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autodetect board and start name mapping
parent
db47e3f7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
263 additions
and
249 deletions
+263
-249
mapping.py
penguidom/plugins/paradox/mapping.py
+197
-0
MG5050.py
penguidom/plugins/paradox/panels/MG5050.py
+13
-244
paradox.py
penguidom/plugins/paradox/paradox.py
+48
-5
paradox37b.py
penguidom/plugins/paradox/paradox37b.py
+5
-0
No files found.
penguidom/plugins/paradox/mapping.py
0 → 100644
View file @
8722afa4
###########################################################################
# Copyright (c) 2018- Franco (nextime) Lanza <franco@nexlab.it>
#
# Penguidom System client Daemon "penguidomd" [https://git.nexlab.net/domotika/Penguidom]
#
# This file is part of penguidom.
#
# penguidom is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from
nexlibs.singleton
import
Singleton
class
ParadoxEventMap
(
Singleton
):
eventMap
=
{}
def
__init__
(
self
,
*
args
,
**
kwargs
):
Singleton
.
__init__
(
self
)
def
loadEvents
(
self
,
eventmap
):
self
.
eventMap
=
eventmap
def
getEventGroupDescription
(
self
,
eg
):
try
:
return
self
.
eventMap
.
eventGroupMap
[
eg
]
except
KeyError
:
print
"No ParadoxMap for: eg=
%
d"
%
(
eg
)
return
"-"
def
getSubEventGroupDescription
(
self
,
eg
,
seg
):
try
:
return
self
.
eventMap
.
subEventGroupMap
[
eg
][
seg
]
except
KeyError
:
print
"No ParadoxMap for: eg=
%
d
\t
seg=
%
d"
%
(
eg
,
seg
)
return
"-"
def
getEventDescription
(
self
,
eg
,
seg
):
try
:
return
self
.
eventMap
.
eventGroupMap
[
eg
],
self
.
eventMap
.
subEventGroupMap
[
eg
][
seg
]
except
KeyError
:
print
"No ParadoxMap for: eg=
%
d
\t
seg=
%
d"
%
(
eg
,
seg
)
return
"-"
def
getLabelTypeDescription
(
self
,
lt
):
return
self
.
eventMap
.
labelTypeMap
[
lt
]
def
setzoneLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_zoneLabel
.
update
({
number
:
value
})
return
def
getzoneLabel
(
self
,
number
):
value
=
self
.
eventMap
.
_zoneLabel
[
number
]
return
value
def
getAllzoneLabel
(
self
):
return
self
.
eventMap
.
_zoneLabel
def
setuserLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_userLabel
.
update
({
number
:
value
})
return
def
getAlluserLabel
(
self
):
return
self
.
eventMap
.
_userLabel
def
setpartitionLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_partitionLabel
.
update
({
number
:
value
})
return
def
getAllpartitionLabel
(
self
):
return
self
.
eventMap
.
_partitionLabel
def
setbusModuleLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_busModuleLabel
.
update
({
number
:
value
})
return
def
getbusModuleLabel
(
self
,
number
):
value
=
self
.
eventMap
.
_busModuleLabel
[
number
]
return
value
def
getAllbusModuleLabel
(
self
):
return
self
.
eventMap
.
_busModuleLabel
def
setwirelessRepeaterLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_wirelessRepeater
.
update
({
number
:
value
})
return
def
getwirelessRepeaterLabel
(
self
,
number
):
value
=
self
.
eventMap
.
_wirelessRepeater
[
number
]
return
value
def
getAllwirelessRepeaterLabel
(
self
):
return
self
.
eventMap
.
_wirelessRepeater
def
setwirelessKeypadLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_wirelessKeypad
.
update
({
number
:
value
})
return
def
getwirelessKeypadLabel
(
self
,
number
):
value
=
self
.
eventMap
.
_wirelessKeypad
[
number
]
return
value
def
getAllwirelessKeypadLabel
(
self
):
return
self
.
eventMap
.
_wirelessKeypad
def
setsiteNameLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_siteNameLabel
.
update
({
number
:
value
})
return
def
setwirelessSirenLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_wirelessSiren
.
update
({
number
:
value
})
return
def
getwirelessSirenLabel
(
self
,
number
):
value
=
self
.
eventMap
.
_wirelessSiren
[
number
]
return
value
def
getAllwirelessSirenLabel
(
self
):
return
self
.
eventMap
.
_wirelessSiren
def
setoutputLabel
(
self
,
number
,
value
):
self
.
eventMap
.
_outputLabel
.
update
({
number
:
value
})
return
def
getoutputLabel
(
self
,
number
):
value
=
self
.
eventMap
.
_outputLabel
[
number
]
return
value
def
getAlloutputLabel
(
self
):
return
self
.
eventMap
.
_outputLabel
class
ParadoxRegisters
(
Singleton
):
registers
=
{}
def
__init__
(
self
,
*
args
,
**
kwargs
):
Singleton
.
__init__
(
self
)
def
loadRegisters
(
self
,
register
):
self
.
registers
=
register
def
getzoneLabelRegister
(
self
):
return
self
.
registers
.
zoneLabel
def
getpartitionLabelRegister
():
return
self
.
registers
.
partitionLabel
def
getuserLabelRegister
(
self
):
return
self
.
registers
.
userLabel
def
getbusModuleLabelRegister
(
self
):
return
self
.
registers
.
busModuleLabel
def
getwirelessRepeaterLabelRegister
(
self
):
return
self
.
registers
.
wirelessRepeaterLabel
def
getwirelessKeypadLabelRegister
(
self
):
return
self
.
registers
.
wirelessKeypadLabel
def
getsiteNameLabelRegister
(
self
):
return
self
.
registers
.
siteNameLabel
def
getwirelessSirenLabelRegister
(
self
):
return
self
.
registers
.
wirelessSirenLabel
def
getoutputLabelRegister
(
self
):
return
self
.
registers
.
outputLabel
def
getcontrolOutputRegister
(
self
):
return
self
.
registers
.
controlOutput
def
getsupportedItems
(
self
):
return
self
.
registers
.
supportedItems
def
getParadoxEventMap
():
return
ParadoxEventMap
.
getInstance
()
def
getParadoxRegisters
():
return
ParadoxRegisters
.
getInstance
()
EVENTMAP
=
getParadoxEventMap
()
REGISTERS
=
getParadoxRegisters
()
penguidom/plugins/paradox/panels/MG5050.py
View file @
8722afa4
"""
This package is statically programmed and dynamically refernce in from the main script.
Within the config.ini file your "Alarm_Registry_Map" and "Alarm_Event_Map" values are appended
with "Registers()" and "EventMap" respectively to load the correct classes for your alarm.
To enable the updating of label names to those configured in your alarm, update the "SupportedItems"
dictionary in the ..."Registers" Class below. The main script will iterate through this list and dynamically
build the relevant get and set functions from the Registers and EventMap classes to update the values
it publishes.
For this reason (dynamic build of function names) the function names listed in the "supportedItems" dictionary
must be an exact (case-sensitive) replica of the relevant functions to interact with its dictionaries.
"""
"""
"""
MG5050: This class maps all MG5050 V4.xx register to labels or output actions
MG5050: This class maps all MG5050 V4.xx register to labels or output actions
"""
"""
class
ParadoxMG5050Registers
(
):
class
Registers
(
object
):
# Link different registry mappings here to event label entries, note that functions to
# Link different registry mappings here to event label entries, note that functions to
# poll & retrieve these externally must be structure as get/set/getall in the respctive classes
# poll & retrieve these externally must be structure as get/set/getall in the respctive classes
...
@@ -37,7 +18,7 @@ class ParadoxMG5050Registers():
...
@@ -37,7 +18,7 @@ class ParadoxMG5050Registers():
"siteNameLabel"
"siteNameLabel"
}
}
zoneLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
zoneLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x00\x10
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
# I.e. get data from register \x50000010, extract text from posisiton 20 to 36
1
:
{
"Send"
:
"
\x50\x00\x00\x10
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
# I.e. get data from register \x50000010, extract text from posisiton 20 to 36
2
:
{
"Send"
:
"
\x50\x00\x00\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
2
:
{
"Send"
:
"
\x50\x00\x00\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
3
:
{
"Send"
:
"
\x50\x00\x00\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
3
:
{
"Send"
:
"
\x50\x00\x00\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
...
@@ -72,7 +53,7 @@ class ParadoxMG5050Registers():
...
@@ -72,7 +53,7 @@ class ParadoxMG5050Registers():
32
:
{
"Send"
:
"
\x50\x00\x01\xf0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
32
:
{
"Send"
:
"
\x50\x00\x01\xf0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
}
}
outputLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
outputLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x02\x10
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
1
:
{
"Send"
:
"
\x50\x00\x02\x10
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
2
:
{
"Send"
:
"
\x50\x00\x02\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
2
:
{
"Send"
:
"
\x50\x00\x02\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
3
:
{
"Send"
:
"
\x50\x00\x02\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
3
:
{
"Send"
:
"
\x50\x00\x02\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
...
@@ -91,13 +72,13 @@ class ParadoxMG5050Registers():
...
@@ -91,13 +72,13 @@ class ParadoxMG5050Registers():
16
:
{
"Send"
:
"
\x50\x00\x02\xf0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}}
16
:
{
"Send"
:
"
\x50\x00\x02\xf0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}}
}
}
partitionLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
partitionLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x03\x10
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
1
:
{
"Send"
:
"
\x50\x00\x03\x10
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
2
:
{
"Send"
:
"
\x50\x00\x03\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}}
2
:
{
"Send"
:
"
\x50\x00\x03\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}}
}
}
userLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
userLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x03\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
1
:
{
"Send"
:
"
\x50\x00\x03\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
2
:
{
"Send"
:
"
\x50\x00\x03\x30
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
2
:
{
"Send"
:
"
\x50\x00\x03\x30
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
3
:
{
"Send"
:
"
\x50\x00\x03\x50
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
3
:
{
"Send"
:
"
\x50\x00\x03\x50
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
...
@@ -132,7 +113,7 @@ class ParadoxMG5050Registers():
...
@@ -132,7 +113,7 @@ class ParadoxMG5050Registers():
32
:
{
"Send"
:
"
\x50\x00\x05\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
32
:
{
"Send"
:
"
\x50\x00\x05\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
}
}
busModuleLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
busModuleLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x05\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
1
:
{
"Send"
:
"
\x50\x00\x05\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
2
:
{
"Send"
:
"
\x50\x00\x05\x30
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
2
:
{
"Send"
:
"
\x50\x00\x05\x30
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
3
:
{
"Send"
:
"
\x50\x00\x05\x50
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
3
:
{
"Send"
:
"
\x50\x00\x05\x50
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
...
@@ -150,12 +131,12 @@ class ParadoxMG5050Registers():
...
@@ -150,12 +131,12 @@ class ParadoxMG5050Registers():
15
:
{
"Send"
:
"
\x50\x00\x06\x10
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
15
:
{
"Send"
:
"
\x50\x00\x06\x10
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
}
}
wirelessRepeaterLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
wirelessRepeaterLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x06\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
1
:
{
"Send"
:
"
\x50\x00\x06\x10
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
2
:
{
"Send"
:
"
\x50\x00\x06\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}}
2
:
{
"Send"
:
"
\x50\x00\x06\x30
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}}
}
}
wirelessKeypadLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
wirelessKeypadLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x06\x30
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
1
:
{
"Send"
:
"
\x50\x00\x06\x30
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
2
:
{
"Send"
:
"
\x50\x00\x06\x50
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
2
:
{
"Send"
:
"
\x50\x00\x06\x50
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
3
:
{
"Send"
:
"
\x50\x00\x06\x50
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
3
:
{
"Send"
:
"
\x50\x00\x06\x50
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
...
@@ -166,18 +147,18 @@ class ParadoxMG5050Registers():
...
@@ -166,18 +147,18 @@ class ParadoxMG5050Registers():
8
:
{
"Send"
:
"
\x50\x00\x06\xb0
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}}
8
:
{
"Send"
:
"
\x50\x00\x06\xb0
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}}
}
}
siteNameLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
siteNameLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x06\xb0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}}
1
:
{
"Send"
:
"
\x50\x00\x06\xb0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}}
}
}
wirelessSirenLabel
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
wirelessSirenLabel
=
{
1
:
{
"Send"
:
"
\x50\x00\x06\xd0
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
1
:
{
"Send"
:
"
\x50\x00\x06\xd0
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
2
:
{
"Send"
:
"
\x50\x00\x06\xd0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
2
:
{
"Send"
:
"
\x50\x00\x06\xd0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}},
3
:
{
"Send"
:
"
\x50\x00\x06\xf0
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
3
:
{
"Send"
:
"
\x50\x00\x06\xf0
"
,
"Receive"
:
{
"Start"
:
20
,
"Finish"
:
36
}},
4
:
{
"Send"
:
"
\x50\x00\x06\xf0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}}
4
:
{
"Send"
:
"
\x50\x00\x06\xf0
"
,
"Receive"
:
{
"Start"
:
36
,
"Finish"
:
52
}}
}
}
controlOutput
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
controlOutput
=
{
1
:
{
"ON"
:
"
\x40\x00\x30\x00
"
,
"OFF"
:
"
\x40\x00\x31\x00
"
},
1
:
{
"ON"
:
"
\x40\x00\x30\x00
"
,
"OFF"
:
"
\x40\x00\x31\x00
"
},
2
:
{
"ON"
:
"
\x40\x00\x30\x01
"
,
"OFF"
:
"
\x40\x00\x31\x01
"
},
2
:
{
"ON"
:
"
\x40\x00\x30\x01
"
,
"OFF"
:
"
\x40\x00\x31\x01
"
},
3
:
{
"ON"
:
"
\x40\x00\x30\x02
"
,
"OFF"
:
"
\x40\x00\x31\x02
"
},
3
:
{
"ON"
:
"
\x40\x00\x30\x02
"
,
"OFF"
:
"
\x40\x00\x31\x02
"
},
...
@@ -196,74 +177,12 @@ class ParadoxMG5050Registers():
...
@@ -196,74 +177,12 @@ class ParadoxMG5050Registers():
16
:
{
"ON"
:
"
\x40\x00\x30\x0f
"
,
"OFF"
:
"
\x40\x00\x31\x0f
"
},
16
:
{
"ON"
:
"
\x40\x00\x30\x0f
"
,
"OFF"
:
"
\x40\x00\x31\x0f
"
},
}
}
controlAlarm
=
{
"Header"
:
"
\xaa\x25\x00\x04\x08\x00\x00\x14\xee\xee\xee\xee\xee\xee\xee\xee
"
,
controlAlarm
=
{
1
:
{
"ARM"
:
"
\x40\x00\x04\x00
"
,
"DISARM"
:
"
\x40\x00\x05\x00
"
,
"SLEEP"
:
"
\x40\x00\x03\x00
"
,
"STAY"
:
"
\x40\x00\x01\x00
"
},
1
:
{
"ARM"
:
"
\x40\x00\x04\x00
"
,
"DISARM"
:
"
\x40\x00\x05\x00
"
,
"SLEEP"
:
"
\x40\x00\x03\x00
"
,
"STAY"
:
"
\x40\x00\x01\x00
"
},
2
:
{
"ARM"
:
"
\x40\x00\x04\x01
"
,
"DISARM"
:
"
\x40\x00\x05\x01
"
,
"SLEEP"
:
"
\x40\x00\x03\x01
"
,
"STAY"
:
"
\x40\x00\x01\x01
"
}}
2
:
{
"ARM"
:
"
\x40\x00\x04\x01
"
,
"DISARM"
:
"
\x40\x00\x05\x01
"
,
"SLEEP"
:
"
\x40\x00\x03\x01
"
,
"STAY"
:
"
\x40\x00\x01\x01
"
}}
@
staticmethod
class
EventMap
(
object
):
def
getzoneLabelRegister
():
return
ParadoxMG5050Registers
.
zoneLabel
@
staticmethod
def
getpartitionLabelRegister
():
return
ParadoxMG5050Registers
.
partitionLabel
@
staticmethod
def
getuserLabelRegister
():
return
ParadoxMG5050Registers
.
userLabel
@
staticmethod
def
getbusModuleLabelRegister
():
return
ParadoxMG5050Registers
.
busModuleLabel
@
staticmethod
def
getwirelessRepeaterLabelRegister
():
return
ParadoxMG5050Registers
.
wirelessRepeaterLabel
@
staticmethod
def
getwirelessKeypadLabelRegister
():
return
ParadoxMG5050Registers
.
wirelessKeypadLabel
@
staticmethod
def
getsiteNameLabelRegister
():
return
ParadoxMG5050Registers
.
siteNameLabel
@
staticmethod
def
getwirelessSirenLabelRegister
():
return
ParadoxMG5050Registers
.
wirelessSirenLabel
@
staticmethod
def
getoutputLabelRegister
():
# try:
return
ParadoxMG5050Registers
.
outputLabel
@
staticmethod
def
getcontrolOutputRegister
():
# try:
return
ParadoxMG5050Registers
.
controlOutput
@
staticmethod
def
getcontrolAlarmRegister
():
# try:
return
ParadoxMG5050Registers
.
controlAlarm
@
staticmethod
def
getsupportedItems
():
# try:
return
ParadoxMG5050Registers
.
supportedItems
"""
MG5050: This class is used for reporting events. The generic names for grouped items will be
updated if a corresponding register location is given in the Registers class
See: E.g. the mappings for an MG5050: http://www.imotionsecurite.com/pdf/paradox/MGSP-EP20.pdf
"""
class
ParadoxMG5050EventMap
():
def
__init__
(
self
):
print
'init'
'''mapping of event and subevent groups here'''
'''mapping of event and subevent groups here'''
eventGroupMap
=
{
0
:
'Zone OK'
,
eventGroupMap
=
{
0
:
'Zone OK'
,
...
@@ -776,153 +695,3 @@ class ParadoxMG5050EventMap():
...
@@ -776,153 +695,3 @@ class ParadoxMG5050EventMap():
5
:
'Wireless Repeater Label'
,
5
:
'Wireless Repeater Label'
,
6
:
'Wireless Keypad Label'
}
6
:
'Wireless Keypad Label'
}
@
staticmethod
def
getEventGroupDescription
(
eg
):
try
:
return
ParadoxMG5050EventMap
.
eventGroupMap
[
eg
]
except
KeyError
:
print
"No ParadoxMap for: eg=
%
d"
%
(
eg
)
return
"-"
@
staticmethod
def
getSubEventGroupDescription
(
eg
,
seg
):
try
:
return
ParadoxMG5050EventMap
.
subEventGroupMap
[
eg
][
seg
]
except
KeyError
:
print
"No ParadoxMap for: eg=
%
d
\t
seg=
%
d"
%
(
eg
,
seg
)
return
"-"
@
staticmethod
def
getEventDescription
(
eg
,
seg
):
try
:
return
ParadoxMG5050EventMap
.
eventGroupMap
[
eg
],
ParadoxMG5050EventMap
.
subEventGroupMap
[
eg
][
seg
]
except
KeyError
:
print
"No ParadoxMap for: eg=
%
d
\t
seg=
%
d"
%
(
eg
,
seg
)
return
"-"
@
staticmethod
def
getLabelTypeDescription
(
lt
):
return
ParadoxMG5050EventMap
.
labelTypeMap
[
lt
]
@
staticmethod
def
setzoneLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_zoneLabel
.
update
({
number
:
value
})
return
@
staticmethod
def
getzoneLabel
(
number
):
value
=
ParadoxMG5050EventMap
.
_zoneLabel
[
number
]
return
value
@
staticmethod
def
getAllzoneLabel
():
return
ParadoxMG5050EventMap
.
_zoneLabel
@
staticmethod
def
setuserLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_userLabel
.
update
({
number
:
value
})
return
@
staticmethod
def
getAlluserLabel
():
return
ParadoxMG5050EventMap
.
_userLabel
@
staticmethod
def
setpartitionLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_partitionLabel
.
update
({
number
:
value
})
return
@
staticmethod
def
getAllpartitionLabel
():
return
ParadoxMG5050EventMap
.
_partitionLabel
@
staticmethod
def
setbusModuleLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_busModuleLabel
.
update
({
number
:
value
})
return
@
staticmethod
def
getbusModuleLabel
(
number
):
value
=
ParadoxMG5050EventMap
.
_busModuleLabel
[
number
]
return
value
@
staticmethod
def
getAllbusModuleLabel
():
return
ParadoxMG5050EventMap
.
_busModuleLabel
@
staticmethod
def
setwirelessRepeaterLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_wirelessRepeater
.
update
({
number
:
value
})
return
@
staticmethod
def
getwirelessRepeaterLabel
(
number
):
value
=
ParadoxMG5050EventMap
.
_wirelessRepeater
[
number
]
return
value
@
staticmethod
def
getAllwirelessRepeaterLabel
():
return
ParadoxMG5050EventMap
.
_wirelessRepeater
@
staticmethod
def
setwirelessKeypadLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_wirelessKeypad
.
update
({
number
:
value
})
return
@
staticmethod
def
getwirelessKeypadLabel
(
number
):
value
=
ParadoxMG5050EventMap
.
_wirelessKeypad
[
number
]
return
value
@
staticmethod
def
getAllwirelessKeypadLabel
():
return
ParadoxMG5050EventMap
.
_wirelessKeypad
@
staticmethod
def
setsiteNameLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_siteNameLabel
.
update
({
number
:
value
})
return
@
staticmethod
def
getsiteNameLabel
(
number
):
value
=
ParadoxMG5050EventMap
.
_siteNameLabel
[
number
]
return
value
@
staticmethod
def
getAllsiteNameLabel
():
return
ParadoxMG5050EventMap
.
_siteNameLabel
@
staticmethod
def
setwirelessSirenLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_wirelessSiren
.
update
({
number
:
value
})
return
@
staticmethod
def
getwirelessSirenLabel
(
number
):
value
=
ParadoxMG5050EventMap
.
_wirelessSiren
[
number
]
return
value
@
staticmethod
def
getAllwirelessSirenLabel
():
return
ParadoxMG5050EventMap
.
_wirelessSiren
@
staticmethod
def
setoutputLabel
(
number
,
value
):
ParadoxMG5050EventMap
.
_outputLabel
.
update
({
number
:
value
})
return
@
staticmethod
def
getoutputLabel
(
number
):
value
=
ParadoxMG5050EventMap
.
_outputLabel
[
number
]
return
value
@
staticmethod
def
getAlloutputLabel
():
return
ParadoxMG5050EventMap
.
_outputLabel
if
__name__
==
'__main__'
:
print
"Loaded Paradox Mapping"
#print ParadoxEventMap.getEventGroupDescription(0)
#print ParadoxEventMap.getSubEventGroupDescription(1,22)
#print ParadoxEventMap.getEventDescription(34,2)
penguidom/plugins/paradox/paradox.py
View file @
8722afa4
...
@@ -29,15 +29,20 @@ from twisted.internet.protocol import BaseProtocol, Protocol, Factory
...
@@ -29,15 +29,20 @@ from twisted.internet.protocol import BaseProtocol, Protocol, Factory
from
twisted.internet
import
reactor
,
tcp
from
twisted.internet
import
reactor
,
tcp
from
nexlibs.utils
import
genutils
from
nexlibs.utils
import
genutils
from
importlib
import
import_module
import
serial
import
serial
import
time
import
time
import
paradox37b
as
p37b
import
paradox37b
as
p37b
from
mapping
import
EVENTMAP
,
REGISTERS
SERIAL_PORT
=
"/dev/ttyS0"
SERIAL_PORT
=
"/dev/ttyS0"
BAUDRATE
=
9600
BAUDRATE
=
9600
PKTTIMEOUT
=
2
# Seconds
PKTTIMEOUT
=
2
# Seconds
REPLYTIMEOUT
=
1
# Seconds
REPLYTIMEOUT
=
1
# Seconds
BOARDTYPE
=
"MG5050"
# Just a default
class
ParadoxProtocol
(
BaseProtocol
):
class
ParadoxProtocol
(
BaseProtocol
):
...
@@ -48,12 +53,21 @@ class ParadoxProtocol(BaseProtocol):
...
@@ -48,12 +53,21 @@ class ParadoxProtocol(BaseProtocol):
replyqueue
=
[]
replyqueue
=
[]
packettimeout
=
0
packettimeout
=
0
proxy
=
False
proxy
=
False
zonemap
=
False
def
__init__
(
self
,
logger
,
core
,
cfg
):
def
__init__
(
self
,
logger
,
core
,
cfg
):
self
.
log
=
logger
self
.
log
=
logger
self
.
core
=
core
self
.
core
=
core
self
.
cfg
=
cfg
self
.
cfg
=
cfg
self
.
log
.
debug
(
str
(
self
.
cfg
))
self
.
log
.
debug
(
str
(
self
.
cfg
))
try
:
self
.
proxyonly
=
genutils
.
isTrue
(
self
.
cfg
.
get
(
'connection'
,
'proxyonly'
))
self
.
mapnames
=
genutils
.
isTrue
(
self
.
cfg
.
get
(
'panel'
,
'mapNames'
))
self
.
autodetect
=
genutils
.
isTrue
(
self
.
cfg
.
get
(
'panel'
,
'autodetect'
))
except
:
self
.
proxyonly
=
False
self
.
mapnames
=
False
self
.
autodetect
=
False
reactor
.
addSystemEventTrigger
(
'before'
,
'shutdown'
,
self
.
_terminating
)
reactor
.
addSystemEventTrigger
(
'before'
,
'shutdown'
,
self
.
_terminating
)
def
_queueData
(
self
):
def
_queueData
(
self
):
...
@@ -161,8 +175,8 @@ class ParadoxProtocol(BaseProtocol):
...
@@ -161,8 +175,8 @@ class ParadoxProtocol(BaseProtocol):
self
.
log
.
debug
(
"Connection lost for "
+
str
(
reason
))
self
.
log
.
debug
(
"Connection lost for "
+
str
(
reason
))
def
connect
(
self
):
def
connect
(
self
):
if
not
genutils
.
isTrue
(
self
.
cfg
.
get
(
'connection'
,
'proxyonly'
))
:
if
not
self
.
proxyonly
:
self
.
write
(
p37b
.
MSG_CONNECT
,
expected_reply
=
p37b
.
REPLY_CONNECT
)
self
.
write
(
p37b
.
MSG_CONNECT
,
self
.
_detectBoard
,
expected_reply
=
p37b
.
REPLY_CONNECT
)
self
.
write
(
p37b
.
MSG_GETSTATUS
,
expected_reply
=
p37b
.
REPLY_GETSTATUS
)
self
.
write
(
p37b
.
MSG_GETSTATUS
,
expected_reply
=
p37b
.
REPLY_GETSTATUS
)
self
.
write
(
p37b
.
MSG_SYNC
,
self
.
_replySync
,
expected_reply
=
p37b
.
REPLY_SYNC
)
self
.
write
(
p37b
.
MSG_SYNC
,
self
.
_replySync
,
expected_reply
=
p37b
.
REPLY_SYNC
)
...
@@ -182,17 +196,36 @@ class ParadoxProtocol(BaseProtocol):
...
@@ -182,17 +196,36 @@ class ParadoxProtocol(BaseProtocol):
# but they seems to be needed for the initial handshake
# but they seems to be needed for the initial handshake
# when connecting. So, we just send both, hope
# when connecting. So, we just send both, hope
# sometime i will fully understand what they do exactly.
# sometime i will fully understand what they do exactly.
#
# After the end of the handshake we proceed to map zone names,
# so, callback for last message drive the runflow in that direction.
self
.
write
(
p37b
.
MSG_UNKWNOWN_HS1
)
self
.
write
(
p37b
.
MSG_UNKWNOWN_HS1
)
self
.
write
(
p37b
.
MSG_UNKWNOWN_HS2
,
self
.
mapNames
)
self
.
write
(
p37b
.
MSG_UNKWNOWN_HS2
,
self
.
mapNames
)
def
_detectBoard
(
self
,
reply
):
board
=
p37b
.
getPanelName
(
reply
)
self
.
log
.
info
(
'Detected Panel Board as '
+
board
)
if
self
.
autodetect
:
try
:
self
.
log
.
info
(
"Autoload panel board mapping for "
+
str
(
board
))
maps
=
import_module
(
"penguidom.plugins.paradox.panels."
+
str
(
board
))
EVENTMAP
.
loadEvents
(
maps
.
EventMap
())
REGISTERS
.
loadRegisters
(
maps
.
Registers
())
self
.
log
.
info
(
"Panel board mapping for "
+
str
(
board
)
+
" loaded successfully"
)
except
:
self
.
log
.
error
(
"Cannot autoload board mapping for "
+
str
(
board
))
def
_processEvent
(
self
,
event
):
def
_processEvent
(
self
,
event
):
pass
pass
def
mapNames
(
self
,
reply
=
None
):
def
mapNames
(
self
,
reply
=
None
):
if
genutils
.
isTrue
(
self
.
cfg
.
get
(
'connection'
,
'mapNames'
)):
if
self
.
mapnames
:
pass
self
.
log
.
info
(
"Start Mapping names..."
)
self
.
log
.
info
(
"Supported Items:"
)
for
i
in
REGISTERS
.
getsupportedItems
():
self
.
log
.
info
(
" "
+
i
)
...
@@ -271,7 +304,17 @@ class Paradox(object):
...
@@ -271,7 +304,17 @@ class Paradox(object):
self
.
log
.
debug
(
"TCP Port "
+
str
(
tcpport
)
+
" OPEN"
)
self
.
log
.
debug
(
"TCP Port "
+
str
(
tcpport
)
+
" OPEN"
)
port
=
tcp
.
Port
(
int
(
tcpport
),
self
.
proxy
,
50
,
self
.
cfg
.
get
(
"connection"
,
"tcpaddr"
),
reactor
)
port
=
tcp
.
Port
(
int
(
tcpport
),
self
.
proxy
,
50
,
self
.
cfg
.
get
(
"connection"
,
"tcpaddr"
),
reactor
)
port
.
startListening
()
port
.
startListening
()
try
:
defboard
=
self
.
cfg
.
get
(
"panel"
,
"paneltype"
)
except
:
defboard
=
BOARDTYPE
try
:
maps
=
import_module
(
"penguidom.plugins.paradox.panels."
+
str
(
defboard
))
EVENTMAP
.
loadEvents
(
maps
.
EventMap
())
REGISTERS
.
loadRegisters
(
maps
.
Registers
())
self
.
log
.
info
(
"Loaded registers and event mapping for default panel type "
+
str
(
defboard
))
except
:
self
.
log
.
error
(
"Cannot import panel mapping for panel type "
+
str
(
defboard
))
logger
.
info
(
"Plugin initialized"
)
logger
.
info
(
"Plugin initialized"
)
...
...
penguidom/plugins/paradox/paradox37b.py
View file @
8722afa4
...
@@ -145,3 +145,8 @@ def format37ByteMessage(message):
...
@@ -145,3 +145,8 @@ def format37ByteMessage(message):
message
+=
checkSumCalc
(
message
)
# Add check to end of message
message
+=
checkSumCalc
(
message
)
# Add check to end of message
return
message
return
message
def
getPanelName
(
message
):
return
str
(
message
[
28
:
36
])
.
strip
(
'
\x00
'
)
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