All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.epics.pvmanager.test.NormalChannel Maven / Gradle / Ivy

/**
 * Copyright (C) 2010-12 Brookhaven National Laboratory
 * All rights reserved. Use is subject to license terms.
 */
package org.epics.pvmanager.test;

import org.epics.pvmanager.ChannelWriteCallback;
import org.epics.pvmanager.MultiplexedChannelHandler;
import org.epics.pvmanager.*;

/**
 * Implementation for channels of a {@link TestDataSource}.
 *
 * @author carcassi
 */
class NormalChannel extends MultiplexedChannelHandler {

    NormalChannel(String channelName) {
        super(channelName);
    }

    @Override
    public void connect() {
        processConnection(new Object());
    }

    @Override
    public void disconnect() {
        processConnection(null);
    }

    @Override
    public void write(Object newValue, ChannelWriteCallback callback) {
        if ("Fail".equals(newValue)) {
            callback.channelWritten(new RuntimeException("Total failure"));
        } else {
            callback.channelWritten(null);
        }
    }

    @Override
    protected boolean isWriteConnected(Object payload) {
        return super.isConnected(payload);
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy