
package htm.channel.output;

import htm.Input;
import htm.InputSet;
import htm.OutputProvider;
import java.util.Collection;
import java.util.concurrent.TimeUnit;

/**
 *
 * @author zygon
 */
public class PrintOutputChannel extends OutputChannel<InputSet<?>> {

    private static Settings createSettings() {
        Settings settings = new Settings();
        
        settings.setPeriod(5);
        settings.setTimeUnit(TimeUnit.SECONDS);
        
        return settings;
    }
    
    public PrintOutputChannel() {
        super(createSettings());
    }

    @Override
    protected void doWrite(InputSet<?> values) {
//        Collection<?> inputs = values.getInputs();
//        for (Input<?> value : values.getInputs()) {
//            
//        }
    }

    @Override
    protected InputSet getOutput(Collection<OutputProvider> outputProviders) {
        
        for (OutputProvider val : outputProviders) {
            
            System.out.print("(");
            System.out.print(val.getId());
            
            if (val.isOutputActive()) {
                Input value = val.getOutput();
                if (value != null && value.isActive()) {
                    System.out.print("[ X ]");
                } else {
                    System.out.print("[ _ ]");
                }
            } else {
                System.out.print("[   ]");
            }
            
            System.out.print(") ");
        }
        
        System.out.println();
        
        return null;
    }
}

@@ -851,32 +851,89 @@
 ers) %7B%0A        %0A
+        StringBuilder sb = new StringBuilder();%0A        %0A
         for (Out
@@ -994,32 +994,25 @@
         
-System.out.print
+sb.append
 (%22(%22);%0A 
@@ -1026,36 +1026,49 @@
     
-System.out.print(val.getId()
+sb.append(val);%0A            sb.append(%22 %22
 );%0A 
@@ -1243,32 +1243,25 @@
         
-System.out.print
+sb.append
 (%22%5B X %5D%22
@@ -1308,32 +1308,25 @@
         
-System.out.print
+sb.append
 (%22%5B _ %5D%22
@@ -1383,32 +1383,25 @@
         
-System.out.print
+sb.append
 (%22%5B   %5D%22
@@ -1446,28 +1446,22 @@
     
-System.out.print(%22) 
+sb.append(%22)%5Cn
 %22);%0A
@@ -1506,16 +1506,29 @@
 println(
+sb.toString()
 );%0A     

use StringBuilder for output