public string ExtractMachineName(TeufelbergerConnection connectionData, string IP) { string machineName; if (IP == connectionData.IP1) { machineName = connectionData.name1; } else if (IP == connectionData.IP2) { machineName = connectionData.name2; } else if (IP == connectionData.IP3) { machineName = connectionData.name3; } else if (IP == connectionData.IP4) { machineName = connectionData.name4; } else { machineName = connectionData.name5; } return(machineName); }
public TeufelbergerConnection GetPathList() { TeufelbergerConnection connection = new TeufelbergerConnection(); connection.MachinePaths.Add(connection.url + connection.name1 + connection.FileType); connection.MachinePaths.Add(connection.url + connection.name2 + connection.FileType); connection.MachinePaths.Add(connection.url + connection.name3 + connection.FileType); connection.MachinePaths.Add(connection.url + connection.name4 + connection.FileType); connection.MachinePaths.Add(connection.url + connection.name5 + connection.FileType); return(connection); }
public List <PLConnection> GetMachines(TeufelbergerConnection data) { List <PLConnection> result = new List <PLConnection>(); var Length = Enum.GetNames(typeof(CpuType)).Length; for (int i = 0; i < Length - 1; i++) { result.Add(new PLConnection(CpuType.S71200, data.IPCodes[i])); } return(result); }
//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(); } }
private void View() { PLConnection connection = new PLConnection(_selectedCPU, _selectedMachine) { Rack = 2, Slot = 0, }; teufelbergerConnection = _plcServices.GetPathList(); _viewPLCViewModel = new ViewPLCViewModel(_csvWritter, _csvReader, _plcMethods, connection, _plcServices) { path = teufelbergerConnection.MachinePaths[MachineIndex], }; var view = new ViewPLC { DataContext = _viewPLCViewModel, }; _viewPLCViewModel.IP = _selectedMachine; plcConnection.CurrentIp = _selectedMachine; view.Show(); }