<commit_before>//  Copyright 2016 The goscope Authors
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.

package dummy

import (
	"github.com/zagrodzki/goscope/scope"
)

type dum struct{}

func (dum) String() string                     { return "dummy device" }
func (dum) GetSampleRate() scope.SampleRate    { return 1000 }
func (dum) GetSampleRates() []scope.SampleRate { return []scope.SampleRate{1000} }
func (dum) SetSampleRate() error               { return nil }

func (dum) Channels() []scope.ChanID {
	return []scope.ChanID{"sin", "square", "triangle", "zero"}
}

func (dum) Channel(ch scope.ChanID) scope.Channel {
	return map[scope.ChanID]scope.Channel{
		"zero":     zeroChan{},
		"sin":      sinChan{},
		"square":   squareChan{},
		"triangle": triangleChan{},
	}[ch]
}

func (dum) StartSampling() (<-chan scope.Data, func(), error) {
	stop := make(chan struct{}, 1)
	data := make(chan scope.Data)
	go func() {
		for {
			select {
			case <-stop:
				return
			case data <- scope.Data{<commit_msg>* replace an in-place map with a switch * remove unused time import<commit_after>//  Copyright 2016 The goscope Authors
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.

package dummy

import (
	"github.com/zagrodzki/goscope/scope"
)

type dum struct{}

func (dum) String() string                     { return "dummy device" }
func (dum) GetSampleRate() scope.SampleRate    { return 1000 }
func (dum) GetSampleRates() []scope.SampleRate { return []scope.SampleRate{1000} }
func (dum) SetSampleRate() error               { return nil }

func (dum) Channels() []scope.ChanID {
	return []scope.ChanID{"sin", "square", "triangle", "zero"}
}

func (dum) Channel(ch scope.ChanID) scope.Channel {
	switch ch {
	case "zero":
		return zeroChan{}
	case "sin":
		return sinChan{}
	case "square":
		return squareChan{}
	case "triangle":
		return triangleChan{}
	}
	return nil
}

func (dum) StartSampling() (<-chan scope.Data, func(), error) {
	stop := make(chan struct{}, 1)
	data := make(chan scope.Data)
	go func() {
		for {
			select {
			case <-stop:
				return
			case data <- scope.Data{
{'fraction_non_alphanumeric': 0.12635956493921946, 'fraction_numerical': 0.010876519513755598, 'mean_word_length': 3.3250345781466115, 'pattern_counts': {'":': 8, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3548698', 'n_tokens_mistral': 1024, 'n_tokens_neox': 942, 'n_words': 349}