public void Close()
 {
     srcFileStreamWriter.Close();
     recFileStreamWriter.Close();
     dataFileStreamWriter.Close();
     mrefFileStreamWriter.Close();
     dxStreamWriter.Close();
     dzStreamWriter.Close();
     _streamWriterSet = null;
 }
 public static StreamWriterSet Builder(string folderName, PoleLocation[] poleLocations)
 {
     if (_streamWriterSet == null)
     {
         _streamWriterSet = new StreamWriterSet()
                            .SetPoleLocations(poleLocations)
                            .InitDataOutputFile(folderName);
     }
     return(_streamWriterSet);
 }
        public void ProduceOutputData()
        {
//            foreach (var poleLocation in _poleLocations)
//            {
//                if (poleLocation != null)
//                {
//                    Debug.WriteLine(poleLocation.ID + ":(" + poleLocation.xAxis + "," + poleLocation.zAxis + ")" +
//                                    poleLocation.Enabled);
//                }
//            }


            var streamWriterSet = StreamWriterSet.Builder(_dataJson.DateTime.ToString("yyyy-MM-dd_H-mm-ss"),
                                                          _poleLocations);
            var collectResult = _dataJson.PoleResult;

            collectResult.ForEach(item =>
            {
                if (_poleLocations[item.A] != null && _poleLocations[item.B] != null && _poleLocations[item.M] != null)
                {
                    var a = item.A;
                    var b = item.B;
                    var m = item.M;

                    item.Poles.ForEach(pole =>
                    {
                        if (_poleLocations[pole.Id] != null && pole.Id != a && pole.Id != b && pole.Id != m)
                        {
                            if (pole.Value < 0)
                            {
                                var anode   = pole.Id;
                                var cathode = m;
                                var value   = Math.Abs(pole.Value);
                                streamWriterSet.WriteData(a, b, anode, cathode, value);
                            }
                            else
                            {
                                var anode   = m;
                                var cathode = pole.Id;
                                var value   = Math.Abs(pole.Value);
                                streamWriterSet.WriteData(a, b, anode, cathode, value);
                            }
                        }
                    });
                }
            });
            streamWriterSet.WriteMrefFile();

            streamWriterSet.Close();
        }