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

import java.util.List;
import java.util.logging.Logger;
import org.epics.pvmanager.ChannelWriteCallback;
import org.epics.pvmanager.MultiplexedChannelHandler;
import org.epics.pvmanager.util.FunctionParser;
import org.epics.vtype.ValueFactory;

/**
 *
 * @author carcassi
 */
class ConstantChannelHandler extends MultiplexedChannelHandler<Object, Object> {
    
    private static final Logger log = Logger.getLogger(ConstantChannelHandler.class.getName());

    public ConstantChannelHandler(String channelName) {
        super(channelName);
        List<Object> tokens = FunctionParser.parseFunctionWithScalarOrArrayArguments(channelName,
                "Wrong syntax. Correct examples: const(3.14), const(\"Bob\"), const(1,2,3), const(\"ON\", \"OFF\"");
        processMessage((Object) ValueFactory.wrapValue(tokens.get(1)));
    }

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

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

    @Override
    public void write(Object newValue, ChannelWriteCallback callback) {
        throw new UnsupportedOperationException("Can't write to simulation channel.");
    }
}
<commit_msg>sim: const lost value after disconnect.<commit_after>/**
 * Copyright (C) 2010-12 Brookhaven National Laboratory
 * All rights reserved. Use is subject to license terms.
 */
package org.epics.pvmanager.sim;

import java.util.List;
import java.util.logging.Logger;
import org.epics.pvmanager.ChannelWriteCallback;
import org.epics.pvmanager.MultiplexedChannelHandler;
import org.epics.pvmanager.util.FunctionParser;
import org.epics.vtype.ValueFactory;

/**
 *
 * @author carcassi
 */
class ConstantChannelHandler extends MultiplexedChannelHandler<Object, Object> {
    
    private static final Logger log = Logger.getLogger(ConstantChannelHandler.class.getName());

    public ConstantChannelHandler(String channelName) {
        super(channelName);
        List<Object> tokens = FunctionParser.parseFunctionWithScalarOrArrayArguments(channelName,
                "Wrong syntax. Correct examples: const(3.14), const(\"Bob\"), const(1,2,3), const(\"ON\", \"OFF\"");
        processMessage((Object) ValueFactory.wrapValue(tokens.get(1)));
    }

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

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

    @Override
    protected boolean saveMessageAfterDisconnect() {
        return true;
    }

    @Override
    public void write(Object newValue, ChannelWriteCallback callback) {
        throw new UnsupportedOperationException("Can't write to simulation channel.");
    }
}

{'fraction_non_alphanumeric': 0.10867293625914315, 'fraction_numerical': 0.009056078021595262, 'mean_word_length': 3.8677966101694916, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5566440', 'n_tokens_mistral': 806, 'n_tokens_neox': 763, 'n_words': 183}