<commit_before>/*! resol-vbus | Copyright (c) 2013-2014, <NAME> | MIT license */
'use strict';



var _ = require('lodash');


var configurationData = require('./resol-deltasol-bx-plus-xxx-data');

var BaseConfigurationOptimizer = require('../base-configuration-optimizer');



var ResolDeltaSolBxPlusXxxConfigurationOptimizer = BaseConfigurationOptimizer.extend({

    optimizeConfiguration: function($) {
        this.optimizeModuleConfiguration($);
        this.optimizeSolarConfiguration($);
        this.optimizeSolarWfConfiguration($);
        this.optimizeAnlageWfConfiguration($);
        this.optimizeHeizungWfConfiguration($);
        this.optimizeHeizungHeizkreisConfiguration($);
        this.optimizeWmzConfiguration($);
    },

    optimizeModuleConfiguration: function($) {
        $(/^Modul([0-9]+)_Aktiviert$/).isFalse(function(value) {
            $('^(Sensor|Relais)[^_]*_Modul' + value.md [1] + '_.*$').ignore();
        });
    },

    optimizeSolarConfiguration: function($) {
        var value = $('Solar_SystemId');

        value.isChanged(function() {
            $(/^Solar_.*/).invalidate();
            $(/^Anlage_.*/).invalidate();
            $(/^Heizung_.*/).invalidate();
        });

        var hasSecondKollektor = function(solarSystemId) {
            return (((solarSystemId / 10) % 2) !== 0);
        };

        value.lt(10, function() {
            $(/^Solar_Kol1_.*/).ignore();
            $(/^Solar_Wf1_(Roehrenkollektor|Bypass|Frostschutz)_.*/).ignore();
        });
        value.check(hasSecondKollektor, function() {
            $(/^Solar_Kol2_.*/).ignore();
            $(/^Solar_Wf2_(Roehrenkollektor|Bypass|Frostschutz)_.*/).ignore();
        });
        $('Solar_OKollektor3').isFalse(function() {
            $(/^Solar_Kol3_.*/).ignore();
            $(/^Solar_Wf3_(Roehrenkollektor|Bypass|Frostschutz)_.*/).ignore();
        });

        value.lt(10, function() {
            $(/^Solar_Sp1_.*/).ignore();
            $(/^Solar_Wf1_(ExtWT)_.*/).ignore();
        });
        value.lt(30, function() {
            $(/^Solar_Sp2_.*/).ignore();
            // TODO: Ladelogik
            $(/^Solar_Wf2_(ExtWT)_.*/).ignore();
        });
        value.lt(50, function() {
            $(/^Solar_Sp3_.*/).ignore();
            $(/^Solar_Wf3_(ExtWT)_.*/).ignore();
        });
        value.lt(70, function() {
            $(/^Solar_Sp4_.*/).ignore();
            $(/^Solar_Wf4_(ExtWT)_.*/).ignore();
        });
        value.lt(90, function() {
            $(/^Solar_Sp5_.*/).ignore();
            $(/^Solar_Wf5_(ExtWT)_.*/).ignore();
        });

        value.lt(1, function() {
            $(/^Solar_Wf1_(Zieltemperatur|Bereitschaft|DrainBack)_.*/).ignore();
        });
    },

    optimizeSolarWfConfiguration: function($) {
        $(/^Solar_Wf([0-9]+)_Type$/).forEach(function(value) {
            var prefix = '^Solar_Wf' + value.md [1] + '_';

            value.in([ 0, '#Frei' ], function() {
                $(prefix + '(?!Type).*').ignore();
            });

            var wfTypes = [
                'NhUnterdrueckung',
                'Parallelrelais',
                'Zwillingspumpe',
                'Ueberwaerme',
                'Volumenstromueberwachung',
            ];

            _.forEach(wfTypes, function(wfType) {
                value.notEql('#' + wfType, function() {
                    $(prefix + wfType + '_.*').ignore();<commit_msg>Fix errors in RESOL DeltaSol BX Plus config optimizer.<commit_after>/*! resol-vbus | Copyright (c) 2013-2014, <NAME> | MIT license */
'use strict';



var _ = require('lodash');


var configurationData = require('./resol-deltasol-bx-plus-xxx-data');

var BaseConfigurationOptimizer = require('../base-configuration-optimizer');



var ResolDeltaSolBxPlusXxxConfigurationOptimizer = BaseConfigurationOptimizer.extend({

    optimizeConfiguration: function($) {
        this.optimizeModuleConfiguration($);
        this.optimizeSolarConfiguration($);
        this.optimizeSolarWfConfiguration($);
        this.optimizeAnlageWfConfiguration($);
        this.optimizeHeizungWfConfiguration($);
        this.optimizeHeizungHeizkreisConfiguration($);
        this.optimizeWmzConfiguration($);
    },

    optimizeModuleConfiguration: function($) {
        $(/^Modul([0-9]+)_Aktiviert$/).isFalse(function(value) {
            $('^(Sensor|Relais)[^_]*_Modul' + value.md [1] + '_.*$').ignore();
        });
    },

    optimizeSolarConfiguration: function($) {
        var value = $('Solar_SystemId');

        value.isChanged(function() {
            $(/^Solar_.*/).invalidate();
            $(/^Anlage_.*/).invalidate();
            $(/^Heizung_.*/).invalidate();
        });

        var hasSecondKollektor = function(solarSystemId) {
            return (((solarSystemId / 10) & 1) !== 0);
        };

        value.lt(10, function() {
            $(/^Solar_Kol1_.*/).ignore();
            $(/^Solar_Wf1_(Roehrenkollektor|Bypass|Frostschutz)_.*/).ignore();
        });
        value.check(hasSecondKollektor, function() {
            $(/^Solar_Kol2_.*/).ignore();
            $(/^Solar_Wf2_(Roehrenkollektor|Bypass|Frostschutz)_.*/).ignore();
        });
        $('^Solar_OKollektor3$').isFalse(function() {
            $(/^Solar_Kol3_.*/).ignore();
            $(/^Solar_Wf3_(Roehrenkollektor|Bypass|Frostschutz)_.*/).ignore();
        });

        value.lt(10, function() {
            $(/^Solar_Sp1_.*/).ignore();
            $(/^Solar_Wf1_(ExtWT)_.*/).ignore();
        });
        value.lt(30, function() {
            $(/^Solar_Sp2_.*/).ignore();
            // TODO: Ladelogik
            $(/^Solar_Wf2_(ExtWT)_.*/).ignore();
        });
        value.lt(50, function() {
            $(/^Solar_Sp3_.*/).ignore();
            $(/^Solar_Wf3_(ExtWT)_.*/).ignore();
        });
        value.lt(70, function() {
            $(/^Solar_Sp4_.*/).ignore();
            $(/^Solar_Wf4_(ExtWT)_.*/).ignore();
        });
        value.lt(90, function() {
            $(/^Solar_Sp5_.*/).ignore();
            $(/^Solar_Wf5_(ExtWT)_.*/).ignore();
        });

        value.lt(10, function() {
            $(/^Solar_Wf1_(Zieltemperatur|Bereitschaft|DrainBack)_.*/).ignore();
        });
    },

    optimizeSolarWfConfiguration: function($) {
        $(/^Solar_Wf([0-9]+)_Type$/).forEach(function(value) {
            var prefix = '^Solar_Wf' + value.md [1] + '_';

            value.in([ 0, '#Frei' ], function() {
                $(prefix + '(?!(Type|(Roehrenkollektor|Bypass|Frostschutz|ExtWT|Zieltemperatur|Bereitschaft|DrainBack)_)).*').ignore();
            });

            var wfTypes = [
                'NhUnterdrueckung',
                'Parallelrelais',
                'Zwillingspumpe',
                'Ueberwaerme',
                'Volumenstromueberwachung',
            ];

            _.forEach(wfTypes, function(wfType) {
                value.notEql('#' + wfType, function() {
                    $(prefix + wfType + '_.*').ignore();
{'fraction_non_alphanumeric': 0.19146183699870634, 'fraction_numerical': 0.014517751904556562, 'mean_word_length': 2.117383512544803, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3960289', 'n_tokens_mistral': 2383, 'n_tokens_neox': 2320, 'n_words': 245}