-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[zoneminder] Added image channel, changed to jetty, Optimized performance #3583
Conversation
Signed-off-by: Martin Eskildsen <[email protected]> (github: Mr-Eskildsen)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the big update.
I added some comments, note that quite a few of them should be applied in a general way. I did not yet review the complete code but I think that I have a good view of what changed and hope that you can improve the pull request given the pointers I gave you.
If you have any questions or if you finished please ping me.
@@ -3,6 +3,6 @@ | |||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | |||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | |||
<classpathentry kind="src" path="src/main/java"/> | |||
<classpathentry kind="lib" path="lib/zoneminder4j-0.9.7.jar"/> | |||
<classpathentry kind="lib" path="lib/zoneminder4j-0.9.8.jar" sourcepath="D:/Development/Java/workspace/zoneminder4j"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path looks very local to me?
<description>This binding interfaces a ZoneMinder Server</description> | ||
<author>Martin S. Eskildsen</author> | ||
|
||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XML files should be formatted with tabs, like it was
@@ -0,0 +1,137 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be formatted using tabs
@@ -0,0 +1,39 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should formatted with tabs, note that the default openHAB setup using Eclipse should be able to do that for you , by just reformatting the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply to all
@@ -1,20 +1,15 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- | |||
Copyright (c) 2010-2018 by the respective copyright holders. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just remove this whole file and use DS annotations as I've done in https://github.com/openhab/openhab2-addons/pull/3382.
updateStatus(newStatus, statusDetail, statusDescription); | ||
|
||
logger.error("{}: context='{}' state='{}' check='FAILED' - {}", getLogIdentifier(), context, | ||
newStatus.toString(), statusDescription); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to call toString
it will be called automatically, but only when the logging-level actually applies.
Please apply everywhere.
Note that this does not have to be error logging anymore because you already configured the thing status, it more likely that he will see that than that he will the error log.
return status; | ||
|
||
} else if (config.getHost() == null) { | ||
newStatus = ThingStatus.OFFLINE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method looks to have a lot of repetition, can you implement this in smarter way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "problem" is that I need to check every parameter, to be able to log a precise error.
All the repetetive assignments removed.
|
||
return; | ||
} | ||
newStatus = ThingStatus.OFFLINE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why OFFLINE, you are even connecting, maybe UNKNOW would be more suitable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, at that specific place I have verified that config in openHAB looks good, Now I have to verify the configuration in the ZoneMidner Server, which could also be wrong (eg. impossible to establish connection). The only way to find out is trial and error .... :-(. I will add a few comments in the code :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but OFFLINE should not purely be about the connection but more about the state of the Thing to which you are connecting, so we don't know yet, but stating OFFLINE is premature.
forcedPriority = RefreshPriority.UNKNOWN; | ||
if (updateConnection) { | ||
try { | ||
setConnected(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this method is not a setter, which is suggested by the number of exceptions it throws, it might be better to call it disconnect
. Because now it confuse me as the reader
private boolean isDirty; | ||
private String logIdentifier = ""; | ||
|
||
private IZoneMinderEventData activeEvent = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These values would also be assigned here, if you left out the null
@@ -0,0 +1,300 @@ | |||
[INFO] Scanning for projects... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file.
| streamingUser | X | If 'useSpecificUserStreaming' is true, username must be specified here | | ||
| streamingPassword | X | If 'useSpecificUserStreaming' is true, password must be specified here | | ||
|
||
#### Monitor Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line after each header.
|
||
### Things configuration | ||
|
||
#### Bridge Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line after each header.
| imageScale | X | Size (scale) of image. Default: 100 | | ||
|
||
|
||
### Things file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line after each header.
@@ -7,3 +7,4 @@ bin.includes = META-INF/,\ | |||
lib/,\ | |||
about.html | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this unnecessary change.
logger.error( | ||
"{}: context='fetchMonitorDaemonStatus' error in call to 'getAnalysisDaemonStatus' - Exception='{}' ", | ||
getLogIdentifier(), zme.getClass().getCanonicalName(), zme.getCause()); | ||
} catch (Exception ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please catch specific exceptions instead of catching all exceptions. That way it is more clear what exceptions need to be handled and how this is done.
logger.error( | ||
"{}: context='fetchMonitorDaemonStatus' error in call to 'getFrameDaemonStatus' - Exception='{}'", | ||
getLogIdentifier(), zme.getClass().getCanonicalName(), zme.getCause()); | ||
} catch (Exception ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please catch specific exceptions instead of catching all exceptions. That way it is more clear what exceptions need to be handled and how this is done.
@@ -893,14 +1194,28 @@ public String getLogIdentifier() { | |||
|
|||
try { | |||
if (config != null) { | |||
|
|||
result = String.format("[MONITOR-%s]", config.getZoneMinderId().toString()); | |||
} | |||
|
|||
} catch (Exception ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please catch specific exceptions instead of catching all exceptions. That way it is more clear what exceptions need to be handled and how this is done.
if (getChannelStateHandler(channelUID) != null) { | ||
getChannelStateHandler(channelUID).subscribe(); | ||
} | ||
} catch (Exception ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please catch specific exceptions instead of catching all exceptions. That way it is more clear what exceptions need to be handled and how this is done.
logger.debug("{}: Monitor Id: {}", getLogIdentifier(), config.getZoneMinderId()); | ||
|
||
super.initialize(); | ||
logger.info("{}: context='initialize' Monitor Handler Initialized", getLogIdentifier()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduce to debug.
import org.eclipse.smarthome.core.types.State; | ||
|
||
/** | ||
* The {@link GenericThingState} is responsible for handling commands, which are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenericThingState? Please add an appropriate JavaDoc.
import org.eclipse.smarthome.core.types.UnDefType; | ||
|
||
/** | ||
* The {@link GenericThingState} is responsible for handling commands, which are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenericThingState? Please add an appropriate JavaDoc.
import org.eclipse.smarthome.core.types.UnDefType; | ||
|
||
/** | ||
* The {@link GenericThingState} is responsible for handling commands, which are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenericThingState? Please add an appropriate JavaDoc.
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/zoneminder-binding-in-marketplace-beta/39697/31 |
@Mr-Eskildsen thanks for your contribution, do you expect to be able to wrap up this PR? Thanks for keeping us updated! |
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/zoneminder-binding-in-marketplace-beta/39697/48 |
Any plans for addressing the review comments @Mr-Eskildsen ? We've got several PRs waiting on this PR. Or is it OK with you that we merge #3382 and #4037? |
Sorry, I am little bit stucked with this. I think we should just reject the
PR.
/Martin
Den fre. 25. jan. 2019 kl. 21.55 skrev Wouter Born <[email protected]
…:
Any plans for addressing the review comments @Mr-Eskildsen
<https://github.com/Mr-Eskildsen> ? We've got several PRs waiting on this
PR. Or is it OK with you that we merge #3382
<https://github.com/openhab/openhab2-addons/pull/3382> and #4037
<https://github.com/openhab/openhab2-addons/pull/4037>?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/openhab/openhab2-addons/pull/3583#issuecomment-457724707>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFTMexVn9jJ8iQ2oE6ViNufRCaiDWUBNks5vG28zgaJpZM4UG8b2>
.
|
Thanks for the update! 👍 We'll then merge the other two PRs. It would be awesome if you can still find some time at a later moment to continue your great work on this PR! |
Any progress here? We would like to move the binding to the bnd build system. |
I'd say we close this for now. @Mr-Eskildsen maybe you can copy paste part of the this PR back to master later on and provide smaller pull requests that result in faster merges :) |
Signed-off-by: Martin Eskildsen [email protected] (github:
Mr-Eskildsen)
ZoneMinder Binding
[zoneminder] Added Image channel to monitor
[zoneminder] Changed http client to jetty
[zoneminder] Optimized performance
JAR is available in the Eclipse IoT Marketplace, as well as here:
http://www.eskildsen.name/openHAB/zoneminder/org.openhab.binding.zoneminder-2.3.0-SNAPSHOT.jar