<commit_before>import Emitter from 'pattern-emitter2';
import util from 'util';
import MainBoard from './mainboard'

const defaultMsg = {
  path : []
};
class Probe {
  constructor({container, equipment, packet}, event) {
    this.packet = packet;
    this.results = [];
    this.database = container.database;
    this.session = container.session;
    this.event = event;
    this.equipment = equipment.__ID__;
  }

  send({event, equipment=this.equipment, data},isOut=false) {
    if (event){
      const result = this.event.result.find(result => result.event === event);
      if (result) {
        this.results.push(Object.assign({},
          {equipment},
          result,
          {data,isOut},
        ))
      }
    }else{
      this.event.result.map(result => {
        this.results.push(Object.assign({},
          {equipment},
          result,
          {data,isOut},
        ))
      });
    }
  }
}

class Event {
  constructor(container) {
    this.event = new Emitter();
    this.container = container;
    this.index = 1;
  }

  add(event) {
    const code = this.index++;
    this.event.on(event.event, async (obj, ...params) => {
      const {equipment} = obj;
      if (util.isArray(event.result)) {
        event.result = [event.result];
      }
      const probe = new Probe(obj, event);
      await event.invoke(probe, ...params);
      if (probe.changeId){
        this.container.change(equipment, probe.changeId);
      }
      probe.results.map(result=>{
        this.container.send(event,result);
      });
      //
      // const previous = obj.previous ? obj.previous : defaultMsg;
      // const packet = obj.packet;
      //
      // packet.path = previous.path.slice();
      //
      // if (packet.path.indexOf(code) == -1) {
      //   packet.path.push(code);
      //   await event.invoke(obj, ...params);
      // }
    });
  }

  // addEvent(item, eventName, code) {
  //   this.event.on(eventName, (obj, ...params) => {
  //     const previous = obj.previous ? obj.previous : defaultMsg;
  //     const packet = obj.packet;
  //
  //     packet.path = previous.path.slice();<commit_msg>修改框架结构<commit_after>import Emitter from 'pattern-emitter2';
import util from 'util';
import MainBoard from './mainboard'

const defaultMsg = {
  path : []
};
class Probe {
  constructor({container, equipment, packet}, event) {
    this.packet = packet;
    this.results = [];
    this.database = container.database;
    this.session = container.session;
    this.event = event;
    this.equipment = equipment.__ID__;
  }

  send({event, equipment=this.equipment, data},isOut=false) {
    if (event){
      const result = this.event.result.find(result => result.event === event);
      if (result) {
        this.results.push(Object.assign({},
          {equipment},
          result,
          {data,isOut},
        ))
      }
    }else{
      this.event.result.map(result => {
        this.results.push(Object.assign({},
          {equipment},
          result,
          {data,isOut},
        ))
      });
    }
  }
}

class Event {
  constructor(container) {
    this.event = new Emitter();
    this.container = container;
    this.index = 1;
  }

  add(event) {
    const code = this.index++;
    this.event.on(event.event, async (obj, ...params) => {
      const {equipment} = obj;
      if (!util.isArray(event.result)) {
        event.result = [event.result];
      }
      const probe = new Probe(obj, event);
      await event.invoke(probe, ...params);
      if (probe.changeId){
        this.container.change(equipment, probe.changeId);
      }
      probe.results.map(result=>{
        this.container.send(event,result);
      });
      //
      // const previous = obj.previous ? obj.previous : defaultMsg;
      // const packet = obj.packet;
      //
      // packet.path = previous.path.slice();
      //
      // if (packet.path.indexOf(code) == -1) {
      //   packet.path.push(code);
      //   await event.invoke(obj, ...params);
      // }
    });
  }

  // addEvent(item, eventName, code) {
  //   this.event.on(eventName, (obj, ...params) => {
  //     const previous = obj.previous ? obj.previous : defaultMsg;
  //     const packet = obj.packet;
  //
  //     packet.path = previous.path.slice();
{'fraction_non_alphanumeric': 0.16132830899670278, 'fraction_numerical': 0.001413094677343382, 'mean_word_length': 2.084241103848947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '7349241', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1329, 'n_words': 251}