Java Device Server example with multiple devices?

Greetings,
I am very new to Tango.. working through the manuals and some examples in Java. I have so far been able to create devices and have them run through their inherent main methods, and test using the Jive test device functionality. I have had success combining the device with the software drivers that I will use to control my physical devices, so this is encouraging.

However, I am having some difficulty in initializing a device server which contains more than one device - specifically, I'm having a hard time understanding how to configure this type of device in the database (using Jive) prior to instantiating my device server. The examples I have access to seem to concentrate on single devices being run through their main methods. I will eventually require many devices to be instantiate through a single device server. If anyone can point me to an example in Java that works, which I can study from, it would be very appreciated.

Thanks in advance!
dave

Dave Del Rizzo
Instrumentation Software Developer
Herzberg Astronomy & Astrophysics
National Research Council Canada
Edited 8 years ago
Hi,

Hope this is still relevant. Here is an example on how we handle such case at HZG:

In jive you just define several devices of a same class (DataFormatAdapter):



Look then at the source code - init method:


    public final void initDevice() throws Exception {
        //…

        //note here we get full device name and split it, i.e. p05/IBL/status_server
        String[] thisDeviceNameParts = deviceManager.getName().split("/");

        String devName = thisDeviceNameParts[2];//= status_server
        //do smth specific to the device basing on its name 
        if (devName.contains("status_server")) {
                //…
        } else if (devName.contains("predator")) {
                //…
        } else if (devName.contains("camera")) {
                //…
        } else if (settings.containsKey(devName)) {
                //… 
        } else {
            //throw some error
        }

        //…
        /*—– PROTECTED REGION END —–*/    //	AbstractAdapter.initDevice
    }


You can also split log messages into different files for each device:



<!– logback.xml –>
<!– … –>
    <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
        <discriminator>
            <Key>deviceName</Key>
            <DefaultValue>UNKNOWN_DEVICE_NAME</DefaultValue>
        </discriminator>
        <sift>
            <appender name="FILE-${deviceName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
                <file>${XENV_ROOT}/var/log/${NAME}/${deviceName}.log</file>
                <Append>true</Append>
                <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
                    <fileNamePattern>${deviceName}%i.log</fileNamePattern>
                    <minIndex>1</minIndex>
                    <maxIndex>3</maxIndex>
                </rollingPolicy>
                <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
                    <MaxFileSize>10MB</MaxFileSize>
                </triggeringPolicy>
                <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
                    <layout class="ch.qos.logback.classic.PatternLayout">
                        <pattern>%-5level %d{HH:mm:ss.SSS} [%thread - %X{deviceName} - %C{1} ] %logger{36}.%M:%L - %msg%n</pattern>
                    </layout>
                </encoder>
            </appender>
        </sift>
    </appender>

    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        <!–appender-ref ref="FILE"/–>
        <appender-ref ref="SIFT"/>
    </appender>
<!– … –>


Edited 8 years ago
 
Register or login to create to post a reply.