BMATrainer Simulationsprogramm für Brandmeldeanlagen
Die GUI
Die GUI
Die GUI
Die GUI wxFormBuilder im Einsatz...
 
GUI
Plugins
Plugins I Löst den “Alarm” aus
Einfache Arduino-Anwendung
Anschluss an USB-Port
Device::SerialPort zum Auslesen der Arduino-Daten
Einfacher Sketch für Arduino
Plugins I
Plugins I use Win32::SerialPort; my $port  = 'COM3'; my $baud  = 9600; my $parity  = 'none'; my $data  = 2; my $stop  = 1; my $handshake = 'none'; sub new { bless {}, shift; }
Plugins I my $conn = Win32::SerialPort->new( $port ) or die $^E; $conn->databits( $data ); $conn->baudrate( $baud ); $conn->parity( $parity ); $conn->stopbits( $stop ); while ( 1 ) { my $char = $conn->lookfor; no warnings 'numeric'; # read input from usb port # if “1” is returned, start alarm $conn->lookclear; }
Plugins II Soll “Hausalarm” simulieren
Steuerung mit Win32::Sound
Win32-only im Moment
Plugins II sub start_sound { my ($self) = @_; Win32::Sound::Volume( '100%' ); Win32::Sound::Play( $self->sound_file, SND_ASYNC ); } sub stop_sound { Win32::Sound::Stop(); }
Plugins threads + wxPerl -> “use threads” vor “use Wx”
Kommunikation zwischen den Plugins und der Anwendung muss möglich sein Ein “Eventsystem” musste her Einbinden muss einfach sein
Plugins einbinden my $config_file = Path::Class::File->new( $args{directory}, 'plugins.yml', ); my $config = BMA::Config->new( $config_file->absolute.'' ); my $plugins = $config->get( 'plugins' ); for my $plugin ( @{$plugins} ) { $plugin->{package} = 'BMA::Plugins::'.$plugin->{module}; my $file = $plugin->{package} . '.pm'; $file =~ s{ :: }{/}gxms; $plugin->{file} = $file; push @{ $self->{ $plugin->{type} } }, $plugin; }
Plugins einbinden --- plugins: - type: input module: Feuermelder active: 0 label: Feuermelder - type: output module: Sirene event: AlarmStart active: 0 label: Sirene
Kommunikation
Kommunikation GUI muss von Plugins Befehle empfangen können Einfach Methodenaufrufe des GUI-Objekts GUI muss Befehle an Plugins senden können Nicht so einfach, da GUI die Methoden der Plugins nicht kennt Plugin ↔ Plugin müssen über GUI-Methoden kommunizieren, da diese voneinander nichts wissen

Fr os con2010_bmatrainer

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
    Die GUI wxFormBuilderim Einsatz...
  • 10.
  • 11.
  • 12.
  • 13.
    Plugins I Löstden “Alarm” aus
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
    Plugins I useWin32::SerialPort; my $port = 'COM3'; my $baud = 9600; my $parity = 'none'; my $data = 2; my $stop = 1; my $handshake = 'none'; sub new { bless {}, shift; }
  • 20.
    Plugins I my$conn = Win32::SerialPort->new( $port ) or die $^E; $conn->databits( $data ); $conn->baudrate( $baud ); $conn->parity( $parity ); $conn->stopbits( $stop ); while ( 1 ) { my $char = $conn->lookfor; no warnings 'numeric'; # read input from usb port # if “1” is returned, start alarm $conn->lookclear; }
  • 21.
    Plugins II Soll“Hausalarm” simulieren
  • 22.
  • 23.
  • 24.
    Plugins II substart_sound { my ($self) = @_; Win32::Sound::Volume( '100%' ); Win32::Sound::Play( $self->sound_file, SND_ASYNC ); } sub stop_sound { Win32::Sound::Stop(); }
  • 25.
    Plugins threads +wxPerl -> “use threads” vor “use Wx”
  • 26.
    Kommunikation zwischen denPlugins und der Anwendung muss möglich sein Ein “Eventsystem” musste her Einbinden muss einfach sein
  • 27.
    Plugins einbinden my$config_file = Path::Class::File->new( $args{directory}, 'plugins.yml', ); my $config = BMA::Config->new( $config_file->absolute.'' ); my $plugins = $config->get( 'plugins' ); for my $plugin ( @{$plugins} ) { $plugin->{package} = 'BMA::Plugins::'.$plugin->{module}; my $file = $plugin->{package} . '.pm'; $file =~ s{ :: }{/}gxms; $plugin->{file} = $file; push @{ $self->{ $plugin->{type} } }, $plugin; }
  • 28.
    Plugins einbinden ---plugins: - type: input module: Feuermelder active: 0 label: Feuermelder - type: output module: Sirene event: AlarmStart active: 0 label: Sirene
  • 29.
  • 30.
    Kommunikation GUI mussvon Plugins Befehle empfangen können Einfach Methodenaufrufe des GUI-Objekts GUI muss Befehle an Plugins senden können Nicht so einfach, da GUI die Methoden der Plugins nicht kennt Plugin ↔ Plugin müssen über GUI-Methoden kommunizieren, da diese voneinander nichts wissen