from QNS.components import *
from QNS.channels import *
from QNS.StateEvaluation import *
import numpy as np

tl = Timeline()
sm = StateManager('StateManager')

L1 = Laser("L1", tl.env, sm, prr=125e6, wl=1.55e-6, lwidth=1, mu_photons=0.1)
BS1 = BeamSplitter("BS1", tl.env, sm, efficiency=1, transmittance=50)
BS2 = BeamSplitter("BS2", tl.env, sm, efficiency=1, transmittance=50)
D1 = Detector("D1", tl.env, sm, dead_time = 1e-8, jitter = 5.5e-11, mean_response_time = 1e-9, coupling_eff = 1, dark_count_rate = 0, det_eff = 1)
D2 = Detector("D2", tl.env, sm, dead_time = 1e-8, jitter = 5.5e-11, mean_response_time = 1e-9, coupling_eff = 1, dark_count_rate = 0, det_eff = 1)

QF1 = QuantumOpticalChannel('QC1', tl.env, length=1, alpha=0.2, n_core=1.5)
QF1.connect_channel([BS2, 0], [D1, 0])
QF2 = QuantumOpticalChannel('QC2', tl.env, length=1, alpha=0.2, n_core=1.5)
QF2.connect_channel([BS2, 1], [D2, 0])
QF3 = QuantumOpticalChannel('QC3', tl.env, length=1, alpha=0.2, n_core=1.5)
QF3.connect_channel([BS1, 0], [BS2, 0])
QF4 = QuantumOpticalChannel('QC4', tl.env, length=1, alpha=0.2, n_core=1.5)
QF4.connect_channel([BS1, 1], [BS2, 1])
QF5 = QuantumOpticalChannel('QC5', tl.env, length=1, alpha=0.2, n_core=1.5)
QF5.connect_channel([L1, 0], [BS1, 0])

all_lasers = [L1]
all_detectors = [D1, D2]

result = tl.run(runtime=0.00001,laser_list=all_lasers,detector_list=all_detectors)
print(result)
