/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package de.theves.denon4j;

import de.theves.denon4j.controls.*;

public class AVR1912Demo {

    public static void main(String[] args) throws Exception {
        if (null == args || args.length != 2) {
            System.err.println("Try java -jar $/path/to/jar $host $port");
            System.exit(1);
        }
        System.out.println(String.format("Starting demo... AVR1912: %s:%s",
                args[0], args[1]));
        AVR1912Demo test = new AVR1912Demo();
        test.demo(args[0], Integer.parseInt(args[1]));
    }

    private void demo(String host, int port) throws Exception {
        System.out.println("------------DEMO START------------");
        try (AVR1912 avr = new AVR1912(host, port)) {
            // show all available commands
            avr.printHelp(System.out);

            // establish connection
            avr.connect(1000);

            // power control
            Toggle power = avr.power();
            System.out.println("PWON: " + power.state().get());
//            if (power.state() != SwitchState.ON) {
//                // powering on
//                power.toggle();
//            }
//
//            Toggle mute = avr.mute();
//            mute.toggle();
//            System.out.println("MUTE ON: " + mute.state().get());
//
//            Thread.sleep(200);
//            mute.switchOff();
//            System.out.println("MUTE OFF: " + mute.state().get());
//
//            Slider masterVolume = avr.masterVolume();
//            masterVolume.slideUp();
//            System.out.println("MASTER VOL: " + masterVolume.getValue());
//            masterVolume.set("25");
//            System.out.println("MASTER VOL: " + masterVolume.getValue());
//
//            Thread.sleep(200);
//            avr.video().source(VideoSource.SOURCE);
//
//            Thread.sleep(200);
//            avr.input().source(InputSource.NET_UBS);
//
            Thread.sleep(200);
            avr.networkControl().control(NetworkControls.CURSOR_RIGHT);
            System.out.println("Display: " + avr.networkControl().getOnscreenInfo());
//
//            Thread.sleep(200);
//            avr.menu().control(MenuControls.MENU_ON);
//
//            Thread.sleep(200);
//            avr.menu().control(MenuControls.CURSOR_DOWN);
//
//            Thread.sleep(200);
//            avr.menu().control(MenuControls.MENU_OFF);
        }
        System.out.println("------------DEMO END------------");
    }
}

@@ -1804,26 +1804,24 @@
 e().get());%0A
-//
             
@@ -1859,18 +1859,16 @@
 e.ON) %7B%0A
-//
         
@@ -1890,18 +1890,16 @@
 ring on%0A
-//
         
@@ -1914,34 +1914,32 @@
 power.toggle();%0A
-//
             %7D%0A//
@@ -1936,21 +1936,17 @@
       %7D%0A
-//%0A//
+%0A
         
@@ -1971,26 +1971,24 @@
 avr.mute();%0A
-//
             
@@ -1998,26 +1998,24 @@
 e.toggle();%0A
-//
             
@@ -2060,37 +2060,33 @@
 state().get());%0A
-//%0A//
+%0A
             Thre
@@ -2092,34 +2092,32 @@
 ead.sleep(200);%0A
-//
             mute
@@ -2126,26 +2126,24 @@
 witchOff();%0A
-//
             
@@ -2193,29 +2193,25 @@
 e().get());%0A
-//%0A//
+%0A
             
@@ -2248,26 +2248,24 @@
 erVolume();%0A
-//
             
@@ -2288,18 +2288,16 @@
 deUp();%0A
-//
         
@@ -2362,18 +2362,16 @@
 lue());%0A
-//
         
@@ -2398,18 +2398,16 @@
 (%2225%22);%0A
-//
         
@@ -2468,29 +2468,25 @@
 etValue());%0A
-//%0A//
+%0A
             
@@ -2496,34 +2496,32 @@
 ead.sleep(200);%0A
-//
             avr.
@@ -2556,21 +2556,17 @@
 OURCE);%0A
-//%0A//
+%0A
         
@@ -2580,34 +2580,32 @@
 ead.sleep(200);%0A
-//
             avr.
@@ -2641,18 +2641,16 @@
 T_UBS);%0A
-//
 %0A       
@@ -2831,21 +2831,17 @@
 nfo());%0A
-//%0A//
+%0A
         
@@ -2855,34 +2855,32 @@
 ead.sleep(200);%0A
-//
             avr.
@@ -2913,29 +2913,25 @@
 s.MENU_ON);%0A
-//%0A//
+%0A
             
@@ -2941,34 +2941,32 @@
 ead.sleep(200);%0A
-//
             avr.
@@ -3011,13 +3011,9 @@
 N);%0A
-//%0A//
+%0A
     
@@ -3039,18 +3039,16 @@
 p(200);%0A
-//
         

enable demo again