#!/usr/bin/perl -w
use warnings;
use strict;

package camera_set
{

    sub new
    {
        my $class = shift;
        my $self = {};
        bless($self, $class);
        return $self;
    }

    sub command
    {
        return "Camera Set";
    }

    sub do($)
    {
        my $args = $_[1];
        my @setting = split(/=/, $args);
        my ($key, $value) = ($setting[0], $setting[1]);
        my %settings = %{$main::settings{'camera'}};
        $settings{$key} = $value;
        $main::settings{'camera'} = \%settings;
        print $main::socket "{ \"success\":true }\n";
    }


    sub doupstart
    {
        return 1;
    }

    sub upstart
    {
        print "Setting Default Camera Settings...\n";
        my %settings;
        $settings{'focus'} = 10;
        $settings{'brightness'} = 156;
        $settings{'exposure'} = 39;
        $main::settings{'camera'} = \%settings;
        print "Set Camera Defaults successfully\n";
    }   

    sub help
    {
        my %settings = %{$main::settings{'camera'}};
        my $focus = $settings{'focus'};
        return "set Global Camera Settings.\nValid camera settings are 'focus', 'brightness', 'exposure'\nEg. 'camera set: focus=$focus'";
    }

    sub defaultsettings
    {
        return undef;
    }

1;
}
