digraph wfb_ng {
    size = "a4";
    compound=true;
    splines=ortho;

    subgraph cluster_uav {
            label = "UAV";

            camera;

            subgraph cluster_pizero {
                    label = "PI Zero";
                    color = "blue";

                    raspivid[shape=box];
                    gstreamer[shape=box];

                    raspivid -> gstreamer[label="pipe", style=dotted];
            }

            camera -> raspivid[label="CSI bus", style=dotted];

            pixhawk;
            sik_radio1 [label="3DR radio",];

            subgraph cluster_companion {
                    label = "NanoPI NEO2";
                    color = "green";

                    wfb_tx_1[shape=box];
                    wfb_tx_2[shape=box];
                    mavproxy1[label="mavlink router", shape=box];
            }
            wifi_tx;
            ant_tx;

            wifi_tx -> ant_tx;

            gstreamer -> wfb_tx_1[label="USB", ltail=cluster_pizero, lhead=cluster_companion];
            pixhawk -> mavproxy1[label="UART"];
            gstreamer -> wfb_tx_1[label="UDP 5060", style=dotted];
            mavproxy1 -> wfb_tx_2[label="UDP 14550", style=dotted];
            mavproxy1 -> sik_radio1[label="UART"];
            wfb_tx_1 -> wifi_tx [label="radio_port 1", style=dotted];
            wfb_tx_2 -> wifi_tx [label="radio_port 2", style=dotted];
            wfb_tx_2 -> wifi_tx [label="USB", ltail=cluster_companion];
    }

    subgraph cluster_GS {
            label = "Ground station";

            ant_1_1;
            ant_1_2;
            ant_2_1;
            ant_2_2;
            ant_3_1;
            ant_3_2;
            
            wifi_rx1;
            wifi_rx2;
            wifi_rx3;

            ant_1_1 -> wifi_rx1;
            ant_1_2 -> wifi_rx1;

            ant_2_1 -> wifi_rx2;
            ant_2_2 -> wifi_rx2;

            ant_3_1 -> wifi_rx3;
            ant_3_2 -> wifi_rx3;

            subgraph cluster_rx1{
                    label = "Host RX1";
                    color="red";                    
                    eth_rx1[label="eth0"];
                    wfb_rx_1_1[shape=box];
                    wfb_rx_1_2[shape=box];
            }
            subgraph cluster_rx2{
                    label = "Host RX2";
                    color="red";                    
                    eth_rx2[label="eth0"];
                    wfb_rx_2_1[shape=box];
                    wfb_rx_2_2[shape=box];
            }
            subgraph cluster_rx3{
                    label = "Host RX3";
                    color="red";                    
                    eth_rx3[label="eth0"];
                    wfb_rx_3_1[shape=box];
                    wfb_rx_3_2[shape=box];
            }
            sik_radio2[label="3DR radio"];
            subgraph cluster_rx4{
                    label = "Host RX4";
                    color="red";                    
                    eth_rx4[label="eth0"];
                    mavproxy2[label="mavlink router", shape=box];
            }
            wifi_rx1 -> wfb_rx_1_1[label="radio port 1",style=dotted];
            wifi_rx1 -> wfb_rx_1_2[label="radio port 2",style=dotted];
            wifi_rx2 -> wfb_rx_2_1[label="radio port 1",style=dotted];
            wifi_rx2 -> wfb_rx_2_2[label="radio port 2",style=dotted];
            wifi_rx3 -> wfb_rx_3_1[label="radio port 1",style=dotted];
            wifi_rx3 -> wfb_rx_3_2[label="radio port 2",style=dotted];
            sik_radio2 -> mavproxy2;
            subgraph cluster_laptop {
                    label = "Linux laptop";
                    color="green";                    
                    eth_linux[label="eth0"];
                    wfb_agg1[shape=box];
                    wfb_agg2[shape=box];
                    qgroundcontrol[shape=box];
            }
            wfb_rx_1_1 -> wfb_agg1[label="UDP 5601", style=dotted];
            wfb_rx_1_2 -> wfb_agg2[label="UDP 14551", style=dotted];
            wfb_rx_2_1 -> wfb_agg1[label="UDP 5601", style=dotted];
            wfb_rx_2_2 -> wfb_agg2[label="UDP 14551",style=dotted];
            wfb_rx_3_1 -> wfb_agg1[label="UDP 5601" style=dotted];
            wfb_rx_3_2 -> wfb_agg2[label="UDP 14551",style=dotted];

            ethernet_switch[label="switch"];
            eth_rx1 -> ethernet_switch[dir=both];
            eth_rx2 -> ethernet_switch[dir=both];
            eth_rx3 -> ethernet_switch[dir=both];
            eth_rx4 -> ethernet_switch[dir=both];
            eth_linux -> ethernet_switch[dir=both];
            
            subgraph cluster_video_goggles{
                    label = "FPV goggles"
                    style=dotted;
            subgraph cluster_fpv_pi_zero{
                    label = "PI Zero";
                    color="blue";
                    style=solid;
                    wfb_osd[shape=box];
                    gstreamer_fpv[shape=box];
                    
            }
            video_display[label="Display"];
            }
            wfb_agg1 -> gstreamer_fpv[label="UDP 5600", style=dotted];
            wfb_agg2 -> wfb_osd[label="UDP 14550", style=dotted];
            wfb_agg2 -> wfb_osd[label="USB", ltail=cluster_laptop, lhead=cluster_fpv_pi_zero];
            mavproxy2 -> qgroundcontrol[style=dotted];
            wfb_osd -> video_display[label="HDMI or AV",ltail=cluster_fpv_pi_zero];
            
            
    }
}
