package sft

import org.lsst.ccs.subsystems.fcs.*
import org.lsst.ccs.subsystems.fcs.testbench.*
import org.lsst.ccs.subsystems.fcs.common.*
import org.lsst.ccs.subsystems.fcs.drivers.*
import org.lsst.ccs.description.groovy.CCSBuilder


import static org.lsst.gruth.jutils.MapArgs.*

CCSBuilder builder = ["testbenchAPC"]

builder.
        main ( APCTestBenchMainModule,
                argMap(
                        ref("bridge"),
                        ref("thermometer"),
                        ref("led"),
                        ref("fakeLed"),
                        ref("fakeSensor")))
                 


            //begin description of Main submodules
            {       

                // Bridge
                bridge (BridgeForAPCTestBench,
                        argMap(
                            ref("tcpProxy"),
                            ref("ai814"),
                            ref("ao412")))

                {//begin description of bridge's children          

                        // tcp Proxy
                        tcpProxy (CanOpenProxy,
                                argMap(
                                    anInt("portNumber", 50000,[static:true, constraints:1024..99000]),
                                    a("fieldBusTimeout", 2000),
                                    aString("myClientName","TestBench",[static:true]),
                                    anInt("expectedNodesNB", 2),                                   
                                    anInt("hardwareBootTimeout",2000, [description:"A timeout for the harwdare booting process",constraints:1000..10000])))



                        // can open devices
                        ai814 (CanOpenADC, 
                                argMap(
                                    aString("nodeID","1"),
                                    aString("serialNB","c7c50331"),
                                    aString("transmissionType","1")))

                        ao412 (CanOpenDAC, 
                                argMap(
                                    aString("nodeID","2"),
                                    aString("serialNB","c7c40227")))

                            
                }//end description of bridge's children


                // thermometer description 
                thermometer (CanOpenThermometer,
                        argMap( 
                                aString("adcName","ai814",[description:"The name of the ADC where this thermometer is plugged."]),
                                anInt("numOfAnalogInput","1", [description:"The numero of the input of ADC where this thermometer is plugged",constraints:1..8])))

                // fake Sensor description 
                fakeSensor (CanOpenThermometer,
                        argMap( 
                                aString("adcName","ai814",[description:"The name of the ADC where this thermometer is plugged."]),
                                anInt("numOfAnalogInput","3",[description:"The numero of the input of ADC where this thermometer is plugged",constraints:1..8]))) 
    
                // led description 
                led (CanOpenLED,
                        argMap( 
                                a("name", "led"),
                                anInt("tickMillis",1000),
                                aString("dacName","ao412",[description:"The name of the DAC where this led is plugged."]),
                                anInt("outputNumero","1",[description:"The numero of the output of DAC where this led is plugged",constraints:1..4]))) 

                // fake led description 
                fakeLed (CanOpenLED,
                        argMap( a("name", "fakeLed"),
                                anInt("tickMillis",1000),
                                aString("dacName","ao412",[description:"The name of the DAC where this led is plugged."]),
                                anInt("outputNumero","2",[description:"The numero of the output of DAC where this led is plugged",constraints:1..4]))) 
                         

                
                

            }//end description of Main submodules

                


