private void Export() { try { WriteCSV writeCSV = new WriteCSV(); writeCSV = _plcServices.FillCSV(plc, data); var param = _plcServices.GetCSVData((uint)writeCSV.Meters, (ushort)writeCSV.FabricationOrder, (uint)writeCSV.ActualRPM, (ushort)writeCSV.CreelPosition, (uint)writeCSV.ActualTPM, (ushort)writeCSV.Mmin, (uint)writeCSV.Hores, (uint)writeCSV.Minutes); _plcServices.SaveCSV(param, path); } catch (Exception) { ShowDialog(" PLC connection not found "); } }
//This function will save each connection to a .csv file on the runtime folder. If there is no connection in one of them private void SaveData(object state, EventArgs e) { Machines = _plcServices.GetMachines(Data); _avoidList = new List <int>(); plcs = _plcServices.GetPlcs(Machines); for (int i = 0; i < teufelbergerConnection.MachinePaths.Count; i++) { if (plcs[i].IsConnected) { _avoidList.Add(i); } } if (_avoidList.Count >= teufelbergerConnection.MachinePaths.Count) { for (int i = 0; i < teufelbergerConnection.MachinePaths.Count; i++) { if (_avoidList[i] != i) { _plcMethods.StartNewConnection(plcs[i]); teufelbergerConnection = _plcServices.GetPathList(); CSVModel.Add(_plcServices.FillCSV(plcs[i], data)); var param = _plcServices.GetCSVData((uint)CSVModel[i].Meters, (ushort)CSVModel[i].FabricationOrder, (uint)CSVModel[i].ActualRPM, (ushort)CSVModel[i].CreelPosition, (uint)CSVModel[i].ActualTPM, (ushort)CSVModel[i].Mmin, (uint)CSVModel[i].Hores, (uint)CSVModel[i].Minutes); _plcServices.SaveCSV(param, teufelbergerConnection.MachinePaths[i]); } else { ShowDialog("Machine " + teufelbergerConnection.IPCodes[i] + "is not available"); } } } else { ShowDialog("There are no machines available"); Timer.Stop(); } }