Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 36x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Component, ViewChild, ElementRef, OnInit, Input } from '@angular/core';
import { PetriNetwork } from '../../models/petri';
import { Canvas } from '../../models/canvas';
import { TwinpadApiService } from '../../services/twinpad-api.service';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-petri',
imports: [],
templateUrl: './petri.component.html',
styleUrl: './petri.component.css'
})
export class PetriComponent implements OnInit{
petriNetwork: PetriNetwork;
@ViewChild('petriCanvas', { static: true }) pidCanvas!: ElementRef<HTMLCanvasElement>;
private context!: CanvasRenderingContext2D;
canvas: Canvas;
device_id: string;
@Input() deviceId: string;
constructor(private twinpadApiService: TwinpadApiService,
private route: ActivatedRoute){
}
ngOnInit(){
this.device_id = this.route.snapshot.params['device_id'] || this.deviceId;
this.twinpadApiService.getDevice(this.device_id).subscribe(data => {
this.petriNetwork = PetriNetwork.deserialize(data['petri_network']);
this.pidCanvas.nativeElement.addEventListener('wheel', this.preventScroll, { passive: false });
this.context = this.pidCanvas.nativeElement.getContext('2d')!;
this.canvas = new Canvas(this.context, this.petriNetwork);
this.canvas.draw();
});
}
preventScroll(event: WheelEvent) {
event.preventDefault();
}
}
|