"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Microscope = exports.ALL_POSITIONS = exports.ALL_CHANNELS = exports.Position = exports.Tuple3D = exports.Binning = exports.MAGNIFICATION_CHANGES = exports.MagnificationChanger = exports.LENSES = exports.Lens = exports.Channel = exports.LEDSetting = exports.LEDs = exports.LED = void 0;
class LED {
    constructor(wavelength) {
        this.WAVELENGTH = wavelength;
    }
}
exports.LED = LED;
LED.LED_385 = new LED(385);
LED.LED_470 = new LED(470);
LED.LED_567 = new LED(567);
LED.LED_625 = new LED(625);
exports.LEDs = [
    LED.LED_385,
    LED.LED_470,
    LED.LED_567,
    LED.LED_625
];
class LEDSetting {
    constructor(led, intensity) {
        this.led = led;
        this.intensity = intensity;
    }
    setIntensity(intensity) {
        this.intensity = intensity;
    }
    getIntensity() {
        return this.intensity;
    }
}
exports.LEDSetting = LEDSetting;
class Channel {
    constructor(name, first, remaining, exposureTime) {
        this.name = name;
        this.ledSettings = [first];
        this.ledSettings.push(...remaining);
        this.exposureTime = exposureTime;
    }
    getLEDSetting(led) {
        return this.ledSettings.find((value) => value.led.WAVELENGTH === led.WAVELENGTH);
    }
    getExposureTime() {
        return this.exposureTime;
    }
    setExposureTime(exposureTime) {
        this.exposureTime = exposureTime;
    }
}
exports.Channel = Channel;
class Lens {
    constructor(magnification, label) {
        this.magnification = magnification;
        this.label = label;
    }
    toString() {
        return this.label;
    }
}
exports.Lens = Lens;
Lens.FIVE = new Lens(5, "5x");
Lens.TWENTY = new Lens(20, "20x");
exports.LENSES = [
    Lens.FIVE,
    Lens.TWENTY
];
class MagnificationChanger {
    constructor(magnification, label) {
        this.magnification = magnification;
        this.label = label;
    }
    toString() {
        return this.label;
    }
}
exports.MagnificationChanger = MagnificationChanger;
MagnificationChanger.ZERO_FIVE = new MagnificationChanger(0.5, "0.5x");
MagnificationChanger.ONE_ZERO = new MagnificationChanger(1.0, "1.0x");
MagnificationChanger.TWO_ZERO = new MagnificationChanger(2.0, "2.0x");
exports.MAGNIFICATION_CHANGES = [
    MagnificationChanger.ZERO_FIVE,
    MagnificationChanger.ONE_ZERO,
    MagnificationChanger.TWO_ZERO
];
class Binning {
    constructor(binning, label) {
        this.binning = binning;
        this.label = label;
    }
    toString() {
        return this.label;
    }
}
exports.Binning = Binning;
Binning.ONE = new Binning(1, "1x1");
Binning.TWO = new Binning(2, "2x2");
Binning.THREE = new Binning(3, "3x3");
Binning.FOUR = new Binning(4, "4x4");
Binning.FIVE = new Binning(5, "5x5");
class Tuple3D {
    constructor(t) {
        this.x = t[0];
        this.y = t[1];
        this.z = t[2];
    }
    toString() {
        return "(" + this.x + ", " + this.y + ", " + this.z + ")";
    }
}
exports.Tuple3D = Tuple3D;
class Position {
    constructor(name, center, extent) {
        this.name = name;
        this.center = new Tuple3D(center);
        this.extent = new Tuple3D(extent);
    }
    toString() {
        return this.name + " " + this.center.toString();
    }
}
exports.Position = Position;
class Incubation {
    constructor() {
        this.temperature = 20;
        this.co2Concentration = 0;
    }
    setTemperature(temperature) {
        this.temperature = temperature;
    }
    setCO2Concentration(co2Concentration) {
        this.co2Concentration = co2Concentration;
    }
    reset() {
        this.temperature = 20;
        this.co2Concentration = 0;
    }
}
exports.ALL_CHANNELS = "ALL_CHANNELS";
exports.ALL_POSITIONS = "ALL_POSITIONS";
class Microscope {
    constructor() {
        this.channels = [];
        this.positions = [];
        this.lens = Lens.FIVE;
        this.magnificationChanger = MagnificationChanger.ONE_ZERO;
        this.binning = Binning.ONE;
        this.incubation = new Incubation();
        this.onAcquire = this.acquireSinglePositionAndChannel;
    }
    reset() {
        this.channels.length = 0;
        this.positions.length = 0;
        this.lens = Lens.FIVE;
        this.magnificationChanger = MagnificationChanger.ONE_ZERO;
        this.binning = Binning.ONE;
        this.incubation.reset();
    }
    setOnAcquire(func) {
        this.onAcquire = func;
    }
    addChannel(channel) {
        this.channels.push(channel);
    }
    getChannel(name) {
        return this.channels.find((value) => value.name === name);
    }
    clearChannels() {
        this.channels.length = 0;
    }
    addPosition(position) {
        this.positions.push(position);
    }
    getPosition(name) {
        return this.positions.find((value) => value.name === name);
    }
    clearPositions() {
        this.positions.length = 0;
    }
    getTemperature() {
        return this.incubation.temperature;
    }
    setTemperature(temperature) {
        this.incubation.setTemperature(temperature);
    }
    getCO2Concentration() {
        return this.incubation.co2Concentration;
    }
    setCO2Concentration(co2Concentration) {
        this.incubation.setCO2Concentration(co2Concentration);
    }
    getLens() {
        return this.lens;
    }
    setLens(lens) {
        this.lens = lens;
    }
    getMagnificationChanger() {
        return this.magnificationChanger;
    }
    setMagnificationChanger(mag) {
        this.magnificationChanger = mag;
    }
    setBinning(binning) {
        this.binning = binning;
    }
    acquire(positionNames, channelNames, dz) {
        const channels = channelNames.length > 0 && channelNames[0] === exports.ALL_CHANNELS
            ? this.channels
            : channelNames.map((value) => this.getChannel(value));
        const positions = positionNames.length > 0 && positionNames[0] === exports.ALL_POSITIONS
            ? this.positions
            : positionNames.map((value) => this.getPosition(value));
        this.acquirePositionsAndChannels(positions, channels, dz);
    }
    acquirePositionsAndChannels(positions, channels, _dz) {
        for (const position of positions) {
            for (const channel of channels) {
                this.onAcquire(position, channel);
            }
        }
    }
    acquireSinglePositionAndChannel(position, channel) {
        const timeStamp = new Date().toLocaleString('en-us', { year: 'numeric', month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric', second: 'numeric' });
        console.log(timeStamp);
        console.log("======================");
        console.log("Stage position: " + position.name);
        console.log("  - " + position.center.toString());
        console.log();
        console.log("Channel settings: " + channel.name);
        console.log("  - Exposure time: " + channel.getExposureTime() + "ms");
        for (const led of exports.LEDs) {
            const ledSetting = channel.getLEDSetting(led);
            if (ledSetting !== undefined)
                console.log("  - LED " + led.WAVELENGTH + ": " + ledSetting.getIntensity() + "%");
        }
        console.log();
        console.log("Optics:");
        console.log("  - Lens: " + this.lens);
        console.log("  - Mag.Changer: " + this.magnificationChanger);
        console.log("  - Binning: " + this.binning);
        console.log();
        console.log("Incubation:");
        console.log("  - Temperature: " + this.getTemperature() + "C");
        console.log("  - CO2 concentration: " + this.getCO2Concentration() + "%");
        console.log();
        console.log("Acquire stack");
        console.log();
        console.log();
    }
}
exports.Microscope = Microscope;
//# sourceMappingURL=Microscope.js.map