class AmplNetworkWriter {

    private void writeDanglingLines(AmplExportContext context, TableFormatter formatter) throws IOException {
        for (DanglingLine dl : network.getDanglingLines()) {
            Terminal t = dl.getTerminal();
            Bus bus1 = AmplUtil.getBus(t);
            String bus1Id = getBusId(bus1);
            int bus1Num = getBusNum(bus1);
            String middleBusId = getDanglingLineMiddleBusId(dl);
            int middleBusNum = mapper.getInt(AmplSubset.BUS, middleBusId);
            if (isOnlyMainCc() && !(isBusExported(context, bus1Id) || isBusExported(context, middleBusId))) {
                continue;
            }
            VoltageLevel vl = t.getVoltageLevel();
            String middleVlId = getDanglingLineMiddleVoltageLevelId(dl);
            context.voltageLevelIdsToExport.add(vl.getId());
            context.voltageLevelIdsToExport.add(middleVlId);
            String id = dl.getId();
            int num = mapper.getInt(AmplSubset.BRANCH, id);
            int vl1Num = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, vl.getId());
            int middleVlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, middleVlId);
            double vb = vl.getNominalV();
            double zb = vb * vb / AmplConstants.SB;
            double p1 = t.getP();
            double q1 = t.getQ();
            SV sv = new SV(p1, q1, bus1 != null ? bus1.getV() : Double.NaN, bus1 != null ? bus1.getAngle() : Double.NaN).otherSide(dl);
            double p2 = sv.getP();
            double q2 = sv.getQ();
            double patl = getPermanentLimit(dl.getCurrentLimits());
            formatter.writeCell(variantIndex)
                    .writeCell(num)
                    .writeCell(bus1Num)
                    .writeCell(middleBusNum)
                    .writeCell(-1)
                    .writeCell(vl1Num)
                    .writeCell(middleVlNum)
                    .writeCell(dl.getR() / zb)
                    .writeCell(dl.getX() / zb)
                    .writeCell(dl.getG() / 2 * zb)
                    .writeCell(dl.getG() / 2 * zb)
                    .writeCell(dl.getB() / 2 * zb)
                    .writeCell(dl.getB() / 2 * zb)
                    .writeCell(1f)  // constant ratio
                    .writeCell(-1) // no ratio tap changer
                    .writeCell(-1) // no phase tap changer
                    .writeCell(p1)
                    .writeCell(p2)
                    .writeCell(q1)
                    .writeCell(q2)
                    .writeCell(patl)
                    .writeCell(patl)
                    .writeCell(false)
                    .writeCell(faultNum)
                    .writeCell(actionNum)
                    .writeCell(id)
                    .writeCell(dl.getNameOrId());
            addExtensions(num, dl);
        }
    }

    public  AmplNetworkWriter(Network network, int variantIndex, DataSource dataSource, int faultNum, int actionNum,
                             boolean append, StringToIntMapper<AmplSubset> mapper, AmplExportConfig config);
    public  AmplNetworkWriter(Network network, DataSource dataSource, int faultNum, int actionNum,
                             boolean append, StringToIntMapper<AmplSubset> mapper, AmplExportConfig config);
    public  AmplNetworkWriter(Network network, DataSource dataSource, StringToIntMapper<AmplSubset> mapper,
                             AmplExportConfig config);
    public  AmplNetworkWriter(Network network, DataSource dataSource, AmplExportConfig config);

}