1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
| using Siemens.Engineering; using Siemens.Engineering.Connection; using Siemens.Engineering.HW; using Siemens.Engineering.Upload; using Siemens.Engineering.Upload.Configurations; using System; using System.Collections; using System.Collections.Generic; using System.Data.SqlTypes; using System.Diagnostics; using System.IO; using System.Linq; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace openness_tt { internal class openess_func { TiaPortal my_Ti; Project my_proj = null; List<Device> my_devicelist = new List<Device>();
public int runTiaportal(bool tiaMode) { if (tiaMode) { my_Ti = new TiaPortal(TiaPortalMode.WithUserInterface); } else { my_Ti = new TiaPortal(TiaPortalMode.WithoutUserInterface); } return my_Ti.GetCurrentProcess().Id; }
public void stopTiaportal() { Process[] my_process = Process.GetProcesses(); foreach (Process item in my_process) { if (item.Id == my_Ti.GetCurrentProcess().Id) { item.Kill(); break; } } }
public void newProject(string my_projectname) { ProjectComposition proCom = my_Ti.Projects; FolderBrowserDialog my_browserDialog = new FolderBrowserDialog(); string my_path = string.Empty; if (my_browserDialog.ShowDialog() == DialogResult.OK) { my_path = my_browserDialog.SelectedPath; DirectoryInfo my_targetDir = new DirectoryInfo(my_path); my_proj = proCom.Create(my_targetDir, my_projectname); } }
public void runProject() { ProjectComposition proCom = my_Ti.Projects; OpenFileDialog my_opendialog = new OpenFileDialog(); my_opendialog.Multiselect = false; my_opendialog.Title = "choic Tia Project"; my_opendialog.Filter = "All files(*.*)|*.*"; my_opendialog.InitialDirectory = @"D:\"; if (my_opendialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string my_projectfile = my_opendialog.FileName; FileInfo my_path = new FileInfo(my_projectfile); my_proj = proCom.Open(my_path); } }
public void openHWView(int choic_params) { switch (choic_params) { case 0: my_proj.ShowHwEditor(Siemens.Engineering.HW.View.Network); break; case 1: my_proj.ShowHwEditor(Siemens.Engineering.HW.View.Topology); break; case 2: my_proj.ShowHwEditor(Siemens.Engineering.HW.View.Device); break; default: break; } }
public void createDevice(string deviceitemtypeid, string deviceitemname, string devicename) { DeviceComposition my_devicecompos = my_proj.Devices; Device my_device = my_devicecompos.CreateWithItem(deviceitemtypeid, deviceitemname, devicename); } public void createDevice(string devicetypeid, string devicename) { DeviceComposition my_devicecompos = my_proj.Devices; Device my_device = my_devicecompos.Create(devicetypeid, devicename); }
public List<Device> enumDevice() { DeviceComposition my_devicecompos = my_proj.Devices; foreach (Device dev in my_devicecompos) { my_devicelist.Add(dev); } return my_devicelist; }
public void deleteDevice(string deletedevicename) { Device my_deleteDevice = my_proj.UngroupedDevicesGroup.Devices.Find(deletedevicename); my_deleteDevice.Delete(); }
public Device findDevice(string devicename) { Device my_device = my_proj.Devices.Find("devicename"); return my_device; }
public void plugNewdevice(string typeidentifier, string name, int positionnumber) { HardwareObject my_hwobject = my_proj.Devices[0].DeviceItems[1]; if (my_hwobject.CanPlugNew(typeidentifier, name, positionnumber)) { DeviceItem my_plugnewdeviceitem = my_hwobject.PlugNew(typeidentifier, name, positionnumber); } }
public void saveProject() { my_proj.Save(); }
public void closeProject() { my_proj.Close(); }
public void UploadPLCprogram() { StationUploadProvider my_canbeuploadproj = my_proj.GetService<StationUploadProvider>(); StationUploadProvider my_upload_proj = my_canbeuploadproj; ConnectionConfiguration my_conf = my_upload_proj.Configuration; ConfigurationMode my_confmode = my_conf.Modes.Find("PN/IE"); ConfigurationPcInterface my_pcinterface = my_confmode.PcInterfaces.Find("Intel(R) I210 Gigabit Network Connection <2>", 1); ConfigurationAddress my_uploadaddress = my_pcinterface.Addresses.Create("192.168.0.1"); Device my_uploadedobj = null; UploadConfigurationDelegate my_uploaddelegate = PreConfigureUpload; UploadResult my_uploadresult = my_upload_proj.StationUpload(my_uploadaddress, PreConfigureUpload); my_uploadedobj = my_uploadresult.UploadedStation; void PreConfigureUpload(UploadConfiguration my_uploadconf) { ModuleReadAccessPassword my_module_readpsw = my_uploadconf as ModuleReadAccessPassword; if (my_module_readpsw != null) { Console.WriteLine("psw error!"); return; } ModuleWriteAccessPassword my_module_writepsw = my_uploadconf as ModuleWriteAccessPassword; if (my_module_writepsw != null) { Console.WriteLine("psw error!"); return; } throw new NotSupportedException(); } } } }
|