ZoneMinder / zmNinja

High performance, cross platform ionic app for Home/Commerical Security Surveillance using ZoneMinder
http://zmninja.zoneminder.com
Other
1.02k stars 270 forks source link

Add Wake/Sleep/Reset to PTZ functions (credit: @sctt) #306

Closed sctt closed 8 years ago

sctt commented 8 years ago

Hello,

i can't find anywhere the control functions named "Wake", "Sleep" and "Reset" that are present in the classic zoneminder web interface.

are they actually missing or am i missing something?

thank you.

pliablepixels commented 8 years ago

You mean PTZ functions? They are not implemented yet in zmNinja

sctt commented 8 years ago

Yes, i mean PTZ functions.

You say that they are not implemented yet, but that confuses me because i can see a PTZ panel which i can use to control movement functions.

I use Wake and Sleep functions to control my IR LEDs, but i can temporarily use movement functions for that aim, even if it is quite counterintuitive.

While waiting for those Wake and Sleep functions to be implemented, can you please confirm that PTZ movement functions on zmninja have already been coded?

thank you a lot.

pliablepixels commented 8 years ago

not sure which PTZ panel you are referring to - that of ZM or zmNinja. zmNinja has a PTZ panel, but I haven't added buttons beyond movement and presets. I don't have a camera to test wake/sleep

PTZ movement has been implemented in zmNinja. You can always download the desktop version which is free and test for yourself to make sure it works for you.

sctt commented 8 years ago

I was referring to zmNinja panel.

Thank you for your answer, i see that only movement functions have been implemented on zmNinja, and i can use those to control my IR LEDs right now.

Anyway, you don't need special cameras to test wake/sleep/reset or anything. Since camera control in zoneminder is achieved by custom perl scripts, you can just modify your own in order to move your camera on wake, sleep or reset commands. That will assure you that the integration with APIs is working, i don't think you need anything else for this task.

That was just a suggestion if you really intend to implement those new buttons, i think that they will be useful to many users.

Thank you again for your support.

pliablepixels commented 8 years ago

No, that won't help. All that does is simply add a button called wake that just moves the camera which really doesn't help in testing if zmNinja got the wake command right.

sctt commented 8 years ago

Sorry, i don't really want to insist, but i took a look at your code...

on the click event of your zmNinja PTZ panel buttons you just call a ControlPTZ function with the proper cmd name.

controlPTZ($scope.monitorId, $scope.ptzMoveCommand + 'DownLeft');

that function just posts HTTP data to zoneminder in this simple format:

request=control&user=bla&passwd=bla&id=4&control=moveConLeft

i see that your code doesn't really care what the control command actually does, it just invoke it by posting the command name to ZM.

to implement a wake function you just need to do something like this:

controlPTZ($scope.monitorId, $scope.ptzWakeCommand);

posting those data:

request=control&user=bla&passwd=bla&id=4&control=wake

for what concerns to you, that wake function could do anything, from turning on IR LEDs to moving your camera orientation, from echoing an 'hello world' on a /tmp/test file to activating your house self exploding bombs... the effect is not important at all, it depends on the custom perl script which is a user responsability.

i don't want to sound like imposing this implementation to you, i will be happy to code it by myself in the next future, when i will manage to overcome those deathlines which i'm currently on.

if i'll find the time to code and test this enhancement, i hope you will consider it for your next release.

thank you.

pliablepixels commented 8 years ago

Happy to accept a PR, here are the things you need to do:

  1. Before you add the button for wake and sleep, make sure you check for CanWake and CanSleep in the controlDB - the buttons should show up only if this is 1
  2. I'd really prefer you test it with the wake and sleep functions of a camera that supports it. I know you are suggesting one can easily fake it with a different backend routine for sub wake() for a control script, but the problem is the moment I introduce it, people will expect it to work - I Don't want to add a feature I've stubbed in the backend with some other command. So if you have a ZM instance with wake and sleep working via a control script, please test it against that camera
sctt commented 8 years ago

Got it, thanks a lot. Sure i'll let you know about this. see ya!

pliablepixels commented 8 years ago

thanks for contributing - looks good!

pliablepixels commented 8 years ago

@sctt - merged your changes with some UI tweaks. Can you pull latest master and test it works as required?

sctt commented 8 years ago

Thank you for merging!

i tested this latest master version and unfortunately those tweaks broke the w/s/r on my environment.

you see, handling w/s/r as "presets" binds those control functions to the hasPresets flag :

www/js/MonitorModalCtrl.js:1146 :

                     if (data.control.Control.HasPresets == '1')
                     {
[..]
                          // lets add these to the end
                          // strictly speaking, they aren't really presets, but meh for now

                          if (data.control.Control.CanWake == '1')
                          {
[...]

but in fact my cameras don't have presets, and i didn't check HasPresets in my ZM Control Settings because i simply didn't need to. a lot of cameras support w/s/r but not p/t/z, and being forced to enable presets may be misleading to users.

i like your "list approach" and the nice icons you chose, but i think we have better to find a way to unbind w/s/r to presets, maybe adding another button near the presets one or something.

i'm sorry if i can't give you nice suggestions about this, but i'm not very good in graphics, UIs and UX.

pliablepixels commented 8 years ago

ah I see. How about now?

sctt commented 8 years ago

I did a brief test... but unfortunately i'm experimenting severe bandwidth problems right now and sockets keep crashing on me (grrrrr), but w/r/s seems to work well now. hopefully tomorrow my connection will be all right, i'll give you a real feedback when i'll be able to perform deeper tests.

i just wanted to say that, even thought functionality seems to work just fine, UI doesn't feel right to me.

i like the new icons a lot, i just find strange that i have to click on "pan/tilt/zoom", then on "more" or "presets" and then on an "opened eye icon" in order to access the wake function.

the interface doesn't give any clue about what those nice icons are for, not even how to reach w/s/r functions from the monitor view. I have to perform 3 "weird" clicks in order to access those functions:

i don't know, maybe it would be better to add another button to the bottom-right menu named "wake/sleep/reset" and pushing those icons to the bottom center, taking them away from p/t/z panel in a cleaner and intuitive fashion.

don't take me wrong, i don't actually care that much about UI, i'm happy that those functions are working now and if it was up to me i'll release everything how it is. i'm saying all this just because i think that the app is very user friendly right now, i just don't like the idea of spoiling part of it.

let me know if you want to code what i proposed (or want me to code it, i have some free-coffee nights), if you have another idea, or if you want to leave everything how it is.

pliablepixels commented 8 years ago

I agree. I need to re-look at this screen. I don't want to keep adding new sets of buttons at arbitrary locations on the screens as it causes layout hell in different modes/devices. I started with the arbitrary location approach and then changed to lists, and now have both :-) I plan to move Zoom as well into this list.

I've made some more tweaks. Let me know if its going in the right direction.

sctt commented 8 years ago

i finally managed to solve my connection problem, i did a deeper test and i confirm that w/s/r works pretty well on my cameras.

i pulled last master and i see that UI is totally better now! now i can easily access w/s/r from "control" panel and rapidly recognize its buttons.

maybe the controlToggle button shoud not appear if in the end $scope.ptzPresets.length == 0 , but that's a minor detail.

i did a little code clean: i removed w/s/r conditions starting from line 1099 and added command names on those starting from line 1203, like this:

                    if (data.control.Control.CanWake == '1')
                    {
                        $scope.ptzWakeCommand = 'wake';
                        $scope.ptzPresets.push({name:'W', icon:"ion-eye", cmd:'wake', style:'button-royal '+buttonAccent});
                    }

i tested and it works.

UI satisfies me now, let me know if you are still considering other improvements.

pliablepixels commented 8 years ago

thanks. I don't think we need the ptzWake/Reset/Sleep Commands any more of 1099 do we ? Since they were moved to the list, the list already has the command cmd:'xxxx'

sctt commented 8 years ago

yes you are right, if the list approach is final those variables like $scope.ptzWakeCommand are not useful anymore and they can be removed from MontageCtrl and MonitorCtrl too.

i take this opportunity for asking you if you have already planned a release date for this w/s/r thing. in september i'm finally going production, and i have to inform my customers if they have to perform an update trough their play store or to ask me about a custom apk in order to get the new functions.

pliablepixels commented 8 years ago

I'll be uploading it to the beta channel http://pliablepixels.github.io/2016/08/12/android-open-beta.html

I'd like to wait a month in beta before I push to release - I have a habit of breaking stuff in Android

sctt commented 8 years ago

that makes sense, beta will be just fine, i've already applied to become a tester. thank you! and let me know if you need something else about w/s/r.

pliablepixels commented 8 years ago

sounds good - let's close this issue for now and I can upload a new release to beta. If something breaks, we can always re-open