diff --git a/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.Designer.cs b/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.Designer.cs index 647306ea..100ac78b 100644 --- a/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.Designer.cs +++ b/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.Designer.cs @@ -98,24 +98,21 @@ private void InitializeComponent() // // lstConnectionList // - resources.ApplyResources(this.lstConnectionList, "lstConnectionList"); this.lstConnectionList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.lstConnectionList.FormattingEnabled = true; + resources.ApplyResources(this.lstConnectionList, "lstConnectionList"); this.lstConnectionList.Name = "lstConnectionList"; - this.toolTip.SetToolTip(this.lstConnectionList, resources.GetString("lstConnectionList.ToolTip")); this.lstConnectionList.SelectedIndexChanged += new System.EventHandler(this.lstConnectionList_SelectedIndexChanged); // // label1 // resources.ApplyResources(this.label1, "label1"); this.label1.Name = "label1"; - this.toolTip.SetToolTip(this.label1, resources.GetString("label1.ToolTip")); // // cmdConnectionAdd // resources.ApplyResources(this.cmdConnectionAdd, "cmdConnectionAdd"); this.cmdConnectionAdd.Name = "cmdConnectionAdd"; - this.toolTip.SetToolTip(this.cmdConnectionAdd, resources.GetString("cmdConnectionAdd.ToolTip")); this.cmdConnectionAdd.UseVisualStyleBackColor = true; this.cmdConnectionAdd.Click += new System.EventHandler(this.cmdConnectionAdd_Click); // @@ -123,118 +120,101 @@ private void InitializeComponent() // resources.ApplyResources(this.cmdConnectionDelete, "cmdConnectionDelete"); this.cmdConnectionDelete.Name = "cmdConnectionDelete"; - this.toolTip.SetToolTip(this.cmdConnectionDelete, resources.GetString("cmdConnectionDelete.ToolTip")); this.cmdConnectionDelete.UseVisualStyleBackColor = true; this.cmdConnectionDelete.Click += new System.EventHandler(this.cmdConnectionDelete_Click); // // lstLIBNODAVEConnectionType // - resources.ApplyResources(this.lstLIBNODAVEConnectionType, "lstLIBNODAVEConnectionType"); this.lstLIBNODAVEConnectionType.BackColor = System.Drawing.Color.White; this.lstLIBNODAVEConnectionType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.lstLIBNODAVEConnectionType, "lstLIBNODAVEConnectionType"); this.lstLIBNODAVEConnectionType.FormattingEnabled = true; this.lstLIBNODAVEConnectionType.Name = "lstLIBNODAVEConnectionType"; - this.toolTip.SetToolTip(this.lstLIBNODAVEConnectionType, resources.GetString("lstLIBNODAVEConnectionType.ToolTip")); this.lstLIBNODAVEConnectionType.SelectedIndexChanged += new System.EventHandler(this.lstLIBNODAVEConnectionType_SelectedIndexChanged); // // label2 // resources.ApplyResources(this.label2, "label2"); this.label2.Name = "label2"; - this.toolTip.SetToolTip(this.label2, resources.GetString("label2.ToolTip")); // // lblLIBNODAVEEntryPoint // resources.ApplyResources(this.lblLIBNODAVEEntryPoint, "lblLIBNODAVEEntryPoint"); this.lblLIBNODAVEEntryPoint.Name = "lblLIBNODAVEEntryPoint"; - this.toolTip.SetToolTip(this.lblLIBNODAVEEntryPoint, resources.GetString("lblLIBNODAVEEntryPoint.ToolTip")); // // txtLIBNODAVECPURack // resources.ApplyResources(this.txtLIBNODAVECPURack, "txtLIBNODAVECPURack"); this.txtLIBNODAVECPURack.Name = "txtLIBNODAVECPURack"; - this.toolTip.SetToolTip(this.txtLIBNODAVECPURack, resources.GetString("txtLIBNODAVECPURack.ToolTip")); this.txtLIBNODAVECPURack.TextChanged += new System.EventHandler(this.ValueChanged); // // lblLIBNODAVECPURack // resources.ApplyResources(this.lblLIBNODAVECPURack, "lblLIBNODAVECPURack"); this.lblLIBNODAVECPURack.Name = "lblLIBNODAVECPURack"; - this.toolTip.SetToolTip(this.lblLIBNODAVECPURack, resources.GetString("lblLIBNODAVECPURack.ToolTip")); // // txtLIBNODAVECPUSlot // resources.ApplyResources(this.txtLIBNODAVECPUSlot, "txtLIBNODAVECPUSlot"); this.txtLIBNODAVECPUSlot.Name = "txtLIBNODAVECPUSlot"; - this.toolTip.SetToolTip(this.txtLIBNODAVECPUSlot, resources.GetString("txtLIBNODAVECPUSlot.ToolTip")); this.txtLIBNODAVECPUSlot.TextChanged += new System.EventHandler(this.ValueChanged); // // lblLIBNODAVECPUSlot // resources.ApplyResources(this.lblLIBNODAVECPUSlot, "lblLIBNODAVECPUSlot"); this.lblLIBNODAVECPUSlot.Name = "lblLIBNODAVECPUSlot"; - this.toolTip.SetToolTip(this.lblLIBNODAVECPUSlot, resources.GetString("lblLIBNODAVECPUSlot.ToolTip")); // // txtLIBNODAVECPUIP // resources.ApplyResources(this.txtLIBNODAVECPUIP, "txtLIBNODAVECPUIP"); this.txtLIBNODAVECPUIP.Name = "txtLIBNODAVECPUIP"; - this.toolTip.SetToolTip(this.txtLIBNODAVECPUIP, resources.GetString("txtLIBNODAVECPUIP.ToolTip")); this.txtLIBNODAVECPUIP.TextChanged += new System.EventHandler(this.ValueChanged); // // lblLIBNODAVECPUIP // resources.ApplyResources(this.lblLIBNODAVECPUIP, "lblLIBNODAVECPUIP"); this.lblLIBNODAVECPUIP.Name = "lblLIBNODAVECPUIP"; - this.toolTip.SetToolTip(this.lblLIBNODAVECPUIP, resources.GetString("lblLIBNODAVECPUIP.ToolTip")); // // lblLIBNODAVELokalCOMPort // resources.ApplyResources(this.lblLIBNODAVELokalCOMPort, "lblLIBNODAVELokalCOMPort"); this.lblLIBNODAVELokalCOMPort.Name = "lblLIBNODAVELokalCOMPort"; - this.toolTip.SetToolTip(this.lblLIBNODAVELokalCOMPort, resources.GetString("lblLIBNODAVELokalCOMPort.ToolTip")); this.lblLIBNODAVELokalCOMPort.Click += new System.EventHandler(this.lblLIBNODAVELokalCOMPort_Click); // // txtLIBNODAVELokalMPI // resources.ApplyResources(this.txtLIBNODAVELokalMPI, "txtLIBNODAVELokalMPI"); this.txtLIBNODAVELokalMPI.Name = "txtLIBNODAVELokalMPI"; - this.toolTip.SetToolTip(this.txtLIBNODAVELokalMPI, resources.GetString("txtLIBNODAVELokalMPI.ToolTip")); this.txtLIBNODAVELokalMPI.TextChanged += new System.EventHandler(this.ValueChanged); // // lblLIBNODAVELokalMPI // resources.ApplyResources(this.lblLIBNODAVELokalMPI, "lblLIBNODAVELokalMPI"); this.lblLIBNODAVELokalMPI.Name = "lblLIBNODAVELokalMPI"; - this.toolTip.SetToolTip(this.lblLIBNODAVELokalMPI, resources.GetString("lblLIBNODAVELokalMPI.ToolTip")); // // txtLIBNODAVECPUMPI // resources.ApplyResources(this.txtLIBNODAVECPUMPI, "txtLIBNODAVECPUMPI"); this.txtLIBNODAVECPUMPI.Name = "txtLIBNODAVECPUMPI"; - this.toolTip.SetToolTip(this.txtLIBNODAVECPUMPI, resources.GetString("txtLIBNODAVECPUMPI.ToolTip")); this.txtLIBNODAVECPUMPI.TextChanged += new System.EventHandler(this.ValueChanged); // // lblLIBNODAVECPUMPI // resources.ApplyResources(this.lblLIBNODAVECPUMPI, "lblLIBNODAVECPUMPI"); this.lblLIBNODAVECPUMPI.Name = "lblLIBNODAVECPUMPI"; - this.toolTip.SetToolTip(this.lblLIBNODAVECPUMPI, resources.GetString("lblLIBNODAVECPUMPI.ToolTip")); // // lstLIBNODAVEBusSpeed // - resources.ApplyResources(this.lstLIBNODAVEBusSpeed, "lstLIBNODAVEBusSpeed"); this.lstLIBNODAVEBusSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.lstLIBNODAVEBusSpeed, "lstLIBNODAVEBusSpeed"); this.lstLIBNODAVEBusSpeed.FormattingEnabled = true; this.lstLIBNODAVEBusSpeed.Name = "lstLIBNODAVEBusSpeed"; - this.toolTip.SetToolTip(this.lstLIBNODAVEBusSpeed, resources.GetString("lstLIBNODAVEBusSpeed.ToolTip")); this.lstLIBNODAVEBusSpeed.SelectedIndexChanged += new System.EventHandler(this.ValueChanged); // // cmdOK // resources.ApplyResources(this.cmdOK, "cmdOK"); this.cmdOK.Name = "cmdOK"; - this.toolTip.SetToolTip(this.cmdOK, resources.GetString("cmdOK.ToolTip")); this.cmdOK.UseVisualStyleBackColor = true; this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click); // @@ -242,39 +222,34 @@ private void InitializeComponent() // resources.ApplyResources(this.cmdSave, "cmdSave"); this.cmdSave.Name = "cmdSave"; - this.toolTip.SetToolTip(this.cmdSave, resources.GetString("cmdSave.ToolTip")); this.cmdSave.UseVisualStyleBackColor = true; this.cmdSave.Click += new System.EventHandler(this.cmdSave_Click); // // lblConnectionName // - resources.ApplyResources(this.lblConnectionName, "lblConnectionName"); this.lblConnectionName.BackColor = System.Drawing.Color.White; this.lblConnectionName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + resources.ApplyResources(this.lblConnectionName, "lblConnectionName"); this.lblConnectionName.Name = "lblConnectionName"; - this.toolTip.SetToolTip(this.lblConnectionName, resources.GetString("lblConnectionName.ToolTip")); this.lblConnectionName.Click += new System.EventHandler(this.lblConnectionName_Click); // // lstLIBNODAVELokalCOMPort // - resources.ApplyResources(this.lstLIBNODAVELokalCOMPort, "lstLIBNODAVELokalCOMPort"); this.lstLIBNODAVELokalCOMPort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.lstLIBNODAVELokalCOMPort, "lstLIBNODAVELokalCOMPort"); this.lstLIBNODAVELokalCOMPort.FormattingEnabled = true; this.lstLIBNODAVELokalCOMPort.Name = "lstLIBNODAVELokalCOMPort"; - this.toolTip.SetToolTip(this.lstLIBNODAVELokalCOMPort, resources.GetString("lstLIBNODAVELokalCOMPort.ToolTip")); this.lstLIBNODAVELokalCOMPort.SelectedIndexChanged += new System.EventHandler(this.ValueChanged); // // lblLIBNODAVEBusSpeed // resources.ApplyResources(this.lblLIBNODAVEBusSpeed, "lblLIBNODAVEBusSpeed"); this.lblLIBNODAVEBusSpeed.Name = "lblLIBNODAVEBusSpeed"; - this.toolTip.SetToolTip(this.lblLIBNODAVEBusSpeed, resources.GetString("lblLIBNODAVEBusSpeed.ToolTip")); // // cmdUndo // resources.ApplyResources(this.cmdUndo, "cmdUndo"); this.cmdUndo.Name = "cmdUndo"; - this.toolTip.SetToolTip(this.cmdUndo, resources.GetString("cmdUndo.ToolTip")); this.cmdUndo.UseVisualStyleBackColor = true; this.cmdUndo.Click += new System.EventHandler(this.cmdUndo_Click); // @@ -323,29 +298,26 @@ private void InitializeComponent() // resources.ApplyResources(this.btnConfigEntryPoint, "btnConfigEntryPoint"); this.btnConfigEntryPoint.Name = "btnConfigEntryPoint"; - this.toolTip.SetToolTip(this.btnConfigEntryPoint, resources.GetString("btnConfigEntryPoint.ToolTip")); this.btnConfigEntryPoint.UseVisualStyleBackColor = true; this.btnConfigEntryPoint.Click += new System.EventHandler(this.btnConfigEntryPoint_Click); // // lstListEntryPoints // - resources.ApplyResources(this.lstListEntryPoints, "lstListEntryPoints"); this.lstListEntryPoints.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.lstListEntryPoints, "lstListEntryPoints"); this.lstListEntryPoints.FormattingEnabled = true; this.lstListEntryPoints.Name = "lstListEntryPoints"; - this.toolTip.SetToolTip(this.lstListEntryPoints, resources.GetString("lstListEntryPoints.ToolTip")); this.lstListEntryPoints.SelectedIndexChanged += new System.EventHandler(this.lstListEntryPoints_SelectedIndexChanged); // // lblLIBNODAVELokalComSpeed // resources.ApplyResources(this.lblLIBNODAVELokalComSpeed, "lblLIBNODAVELokalComSpeed"); this.lblLIBNODAVELokalComSpeed.Name = "lblLIBNODAVELokalComSpeed"; - this.toolTip.SetToolTip(this.lblLIBNODAVELokalComSpeed, resources.GetString("lblLIBNODAVELokalComSpeed.ToolTip")); // // lstLIBNODAVELokalComSpeed // - resources.ApplyResources(this.lstLIBNODAVELokalComSpeed, "lstLIBNODAVELokalComSpeed"); this.lstLIBNODAVELokalComSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.lstLIBNODAVELokalComSpeed, "lstLIBNODAVELokalComSpeed"); this.lstLIBNODAVELokalComSpeed.FormattingEnabled = true; this.lstLIBNODAVELokalComSpeed.Items.AddRange(new object[] { resources.GetString("lstLIBNODAVELokalComSpeed.Items"), @@ -367,46 +339,40 @@ private void InitializeComponent() resources.GetString("lstLIBNODAVELokalComSpeed.Items16"), resources.GetString("lstLIBNODAVELokalComSpeed.Items17")}); this.lstLIBNODAVELokalComSpeed.Name = "lstLIBNODAVELokalComSpeed"; - this.toolTip.SetToolTip(this.lstLIBNODAVELokalComSpeed, resources.GetString("lstLIBNODAVELokalComSpeed.ToolTip")); this.lstLIBNODAVELokalComSpeed.SelectedIndexChanged += new System.EventHandler(this.ValueChanged); // // lblLIBNODAVELokalComParity // resources.ApplyResources(this.lblLIBNODAVELokalComParity, "lblLIBNODAVELokalComParity"); this.lblLIBNODAVELokalComParity.Name = "lblLIBNODAVELokalComParity"; - this.toolTip.SetToolTip(this.lblLIBNODAVELokalComParity, resources.GetString("lblLIBNODAVELokalComParity.ToolTip")); // // lstLIBNODAVELokalComParity // - resources.ApplyResources(this.lstLIBNODAVELokalComParity, "lstLIBNODAVELokalComParity"); this.lstLIBNODAVELokalComParity.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.lstLIBNODAVELokalComParity, "lstLIBNODAVELokalComParity"); this.lstLIBNODAVELokalComParity.FormattingEnabled = true; this.lstLIBNODAVELokalComParity.Items.AddRange(new object[] { resources.GetString("lstLIBNODAVELokalComParity.Items"), resources.GetString("lstLIBNODAVELokalComParity.Items1"), resources.GetString("lstLIBNODAVELokalComParity.Items2")}); this.lstLIBNODAVELokalComParity.Name = "lstLIBNODAVELokalComParity"; - this.toolTip.SetToolTip(this.lstLIBNODAVELokalComParity, resources.GetString("lstLIBNODAVELokalComParity.ToolTip")); this.lstLIBNODAVELokalComParity.SelectedIndexChanged += new System.EventHandler(this.ValueChanged); // // txtRoutingDestination // resources.ApplyResources(this.txtRoutingDestination, "txtRoutingDestination"); this.txtRoutingDestination.Name = "txtRoutingDestination"; - this.toolTip.SetToolTip(this.txtRoutingDestination, resources.GetString("txtRoutingDestination.ToolTip")); this.txtRoutingDestination.TextChanged += new System.EventHandler(this.ValueChanged); // // lblRoutingDestination // resources.ApplyResources(this.lblRoutingDestination, "lblRoutingDestination"); this.lblRoutingDestination.Name = "lblRoutingDestination"; - this.toolTip.SetToolTip(this.lblRoutingDestination, resources.GetString("lblRoutingDestination.ToolTip")); // // chkRouting // resources.ApplyResources(this.chkRouting, "chkRouting"); this.chkRouting.Name = "chkRouting"; - this.toolTip.SetToolTip(this.chkRouting, resources.GetString("chkRouting.ToolTip")); this.chkRouting.UseVisualStyleBackColor = true; this.chkRouting.CheckedChanged += new System.EventHandler(this.ValueChanged); // @@ -414,58 +380,49 @@ private void InitializeComponent() // resources.ApplyResources(this.txtRoutingSubnetFirst, "txtRoutingSubnetFirst"); this.txtRoutingSubnetFirst.Name = "txtRoutingSubnetFirst"; - this.toolTip.SetToolTip(this.txtRoutingSubnetFirst, resources.GetString("txtRoutingSubnetFirst.ToolTip")); this.txtRoutingSubnetFirst.TextChanged += new System.EventHandler(this.ValueChanged); // // lblRoutingSubnet // resources.ApplyResources(this.lblRoutingSubnet, "lblRoutingSubnet"); this.lblRoutingSubnet.Name = "lblRoutingSubnet"; - this.toolTip.SetToolTip(this.lblRoutingSubnet, resources.GetString("lblRoutingSubnet.ToolTip")); // // txtRoutingSubnetSecond // resources.ApplyResources(this.txtRoutingSubnetSecond, "txtRoutingSubnetSecond"); this.txtRoutingSubnetSecond.Name = "txtRoutingSubnetSecond"; - this.toolTip.SetToolTip(this.txtRoutingSubnetSecond, resources.GetString("txtRoutingSubnetSecond.ToolTip")); this.txtRoutingSubnetSecond.TextChanged += new System.EventHandler(this.ValueChanged); // // lblRoutingMinus // resources.ApplyResources(this.lblRoutingMinus, "lblRoutingMinus"); this.lblRoutingMinus.Name = "lblRoutingMinus"; - this.toolTip.SetToolTip(this.lblRoutingMinus, resources.GetString("lblRoutingMinus.ToolTip")); // // txtRoutingRack // resources.ApplyResources(this.txtRoutingRack, "txtRoutingRack"); this.txtRoutingRack.Name = "txtRoutingRack"; - this.toolTip.SetToolTip(this.txtRoutingRack, resources.GetString("txtRoutingRack.ToolTip")); this.txtRoutingRack.TextChanged += new System.EventHandler(this.ValueChanged); // // lblRoutingRack // resources.ApplyResources(this.lblRoutingRack, "lblRoutingRack"); this.lblRoutingRack.Name = "lblRoutingRack"; - this.toolTip.SetToolTip(this.lblRoutingRack, resources.GetString("lblRoutingRack.ToolTip")); // // txtRoutingSlot // resources.ApplyResources(this.txtRoutingSlot, "txtRoutingSlot"); this.txtRoutingSlot.Name = "txtRoutingSlot"; - this.toolTip.SetToolTip(this.txtRoutingSlot, resources.GetString("txtRoutingSlot.ToolTip")); this.txtRoutingSlot.TextChanged += new System.EventHandler(this.ValueChanged); // // lblRoutingSlot // resources.ApplyResources(this.lblRoutingSlot, "lblRoutingSlot"); this.lblRoutingSlot.Name = "lblRoutingSlot"; - this.toolTip.SetToolTip(this.lblRoutingSlot, resources.GetString("lblRoutingSlot.ToolTip")); this.lblRoutingSlot.Click += new System.EventHandler(this.lblRoutingSlot_Click); // // groupBox1 // - resources.ApplyResources(this.groupBox1, "groupBox1"); this.groupBox1.Controls.Add(this.label4); this.groupBox1.Controls.Add(this.lstConnTypeRouting); this.groupBox1.Controls.Add(this.chkRouting); @@ -479,99 +436,87 @@ private void InitializeComponent() this.groupBox1.Controls.Add(this.lblRoutingSlot); this.groupBox1.Controls.Add(this.lblRoutingSubnet); this.groupBox1.Controls.Add(this.lblRoutingMinus); + resources.ApplyResources(this.groupBox1, "groupBox1"); this.groupBox1.Name = "groupBox1"; this.groupBox1.TabStop = false; - this.toolTip.SetToolTip(this.groupBox1, resources.GetString("groupBox1.ToolTip")); // // label4 // resources.ApplyResources(this.label4, "label4"); this.label4.Name = "label4"; - this.toolTip.SetToolTip(this.label4, resources.GetString("label4.ToolTip")); // // lstConnTypeRouting // - resources.ApplyResources(this.lstConnTypeRouting, "lstConnTypeRouting"); this.lstConnTypeRouting.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.lstConnTypeRouting, "lstConnTypeRouting"); this.lstConnTypeRouting.FormattingEnabled = true; this.lstConnTypeRouting.Items.AddRange(new object[] { resources.GetString("lstConnTypeRouting.Items"), resources.GetString("lstConnTypeRouting.Items1"), resources.GetString("lstConnTypeRouting.Items2")}); this.lstConnTypeRouting.Name = "lstConnTypeRouting"; - this.toolTip.SetToolTip(this.lstConnTypeRouting, resources.GetString("lstConnTypeRouting.ToolTip")); this.lstConnTypeRouting.SelectedIndexChanged += new System.EventHandler(this.ValueChanged); // // lblS7OnlineDevice // resources.ApplyResources(this.lblS7OnlineDevice, "lblS7OnlineDevice"); this.lblS7OnlineDevice.Name = "lblS7OnlineDevice"; - this.toolTip.SetToolTip(this.lblS7OnlineDevice, resources.GetString("lblS7OnlineDevice.ToolTip")); // // txtLIBNODAVECPUPort // resources.ApplyResources(this.txtLIBNODAVECPUPort, "txtLIBNODAVECPUPort"); this.txtLIBNODAVECPUPort.Name = "txtLIBNODAVECPUPort"; - this.toolTip.SetToolTip(this.txtLIBNODAVECPUPort, resources.GetString("txtLIBNODAVECPUPort.ToolTip")); this.txtLIBNODAVECPUPort.TextChanged += new System.EventHandler(this.ValueChanged); // // lblLIBNODAVECPUPort // resources.ApplyResources(this.lblLIBNODAVECPUPort, "lblLIBNODAVECPUPort"); this.lblLIBNODAVECPUPort.Name = "lblLIBNODAVECPUPort"; - this.toolTip.SetToolTip(this.lblLIBNODAVECPUPort, resources.GetString("lblLIBNODAVECPUPort.ToolTip")); // // lblTimeoutDescr // resources.ApplyResources(this.lblTimeoutDescr, "lblTimeoutDescr"); this.lblTimeoutDescr.Name = "lblTimeoutDescr"; - this.toolTip.SetToolTip(this.lblTimeoutDescr, resources.GetString("lblTimeoutDescr.ToolTip")); // // lblTimeoutIPConnectDescr // resources.ApplyResources(this.lblTimeoutIPConnectDescr, "lblTimeoutIPConnectDescr"); this.lblTimeoutIPConnectDescr.Name = "lblTimeoutIPConnectDescr"; - this.toolTip.SetToolTip(this.lblTimeoutIPConnectDescr, resources.GetString("lblTimeoutIPConnectDescr.ToolTip")); // // cmdTest // resources.ApplyResources(this.cmdTest, "cmdTest"); this.cmdTest.Name = "cmdTest"; - this.toolTip.SetToolTip(this.cmdTest, resources.GetString("cmdTest.ToolTip")); this.cmdTest.UseVisualStyleBackColor = true; this.cmdTest.Click += new System.EventHandler(this.cmdTest_Click); // // lblState // - resources.ApplyResources(this.lblState, "lblState"); this.lblState.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + resources.ApplyResources(this.lblState, "lblState"); this.lblState.Name = "lblState"; - this.toolTip.SetToolTip(this.lblState, resources.GetString("lblState.ToolTip")); // // lstConnType // - resources.ApplyResources(this.lstConnType, "lstConnType"); this.lstConnType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.lstConnType, "lstConnType"); this.lstConnType.FormattingEnabled = true; this.lstConnType.Items.AddRange(new object[] { resources.GetString("lstConnType.Items"), resources.GetString("lstConnType.Items1"), resources.GetString("lstConnType.Items2")}); this.lstConnType.Name = "lstConnType"; - this.toolTip.SetToolTip(this.lstConnType, resources.GetString("lstConnType.ToolTip")); this.lstConnType.SelectedIndexChanged += new System.EventHandler(this.ValueChanged); // // label3 // resources.ApplyResources(this.label3, "label3"); this.label3.Name = "label3"; - this.toolTip.SetToolTip(this.label3, resources.GetString("label3.ToolTip")); // // chkUseShortRequest // resources.ApplyResources(this.chkUseShortRequest, "chkUseShortRequest"); this.chkUseShortRequest.Name = "chkUseShortRequest"; - this.toolTip.SetToolTip(this.chkUseShortRequest, resources.GetString("chkUseShortRequest.ToolTip")); this.chkUseShortRequest.UseVisualStyleBackColor = true; this.chkUseShortRequest.CheckedChanged += new System.EventHandler(this.ValueChanged); // @@ -636,7 +581,6 @@ private void InitializeComponent() this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ConnectionEditor"; - this.toolTip.SetToolTip(this, resources.GetString("$this.ToolTip")); this.Load += new System.EventHandler(this.ConnectionEditor_Load); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); diff --git a/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.cs b/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.cs index e2c3e769..72bd1f75 100644 --- a/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.cs +++ b/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.cs @@ -165,16 +165,16 @@ private void LoadSettings() txtWritePort.Text = myConfig.WritePort.ToString(); txtLIBNODAVELokalMPI.Text = myConfig.LokalMpi.ToString(); lstLIBNODAVELokalCOMPort.SelectedItem = myConfig.ComPort; - if (myConfig.ComPortParity == 'e') + if (myConfig.ComPortParity == LibNodaveConnectionBusParity.even) lstLIBNODAVELokalComParity.SelectedItem = "even"; - else if (myConfig.ComPortParity == 'o') + else if (myConfig.ComPortParity == LibNodaveConnectionBusParity.odd) lstLIBNODAVELokalComParity.SelectedItem = "odd"; else lstLIBNODAVELokalComParity.SelectedItem = "none"; lstLIBNODAVELokalComSpeed.SelectedItem = myConfig.ComPortSpeed; - EnumListBoxExtensions.SelectEnumListItem(lstLIBNODAVEConnectionType, myConfig.ConnectionType); - EnumListBoxExtensions.SelectEnumListItem(lstLIBNODAVEBusSpeed, myConfig.BusSpeed); + EnumListBoxExtensions.SelectEnumListItem(lstLIBNODAVEConnectionType, (int)myConfig.ConnectionType); + EnumListBoxExtensions.SelectEnumListItem(lstLIBNODAVEBusSpeed, (int)myConfig.BusSpeed); txtRoutingDestination.Text = myConfig.RoutingDestination; txtRoutingRack.Text = myConfig.RoutingDestinationRack.ToString(); @@ -183,15 +183,15 @@ private void LoadSettings() txtRoutingSubnetFirst.Text = myConfig.RoutingSubnet1.ToString("X"); txtRoutingSubnetSecond.Text = myConfig.RoutingSubnet2.ToString("X"); - txtTimeout.Text = myConfig.Timeout.ToString(); - txtTimeoutIPConnect.Text = myConfig.TimeoutIPConnect.ToString(); + txtTimeout.Text = myConfig.Timeout.TotalMilliseconds.ToString(); + txtTimeoutIPConnect.Text = myConfig.TimeoutIPConnect.TotalMilliseconds.ToString(); chkNetlinkReset.Checked = myConfig.NetLinkReset; chkUseShortRequest.Checked = myConfig.UseShortDataBlockRequest; - lstConnType.SelectedIndex = myConfig.PLCConnectionType; - lstConnTypeRouting.SelectedIndex = myConfig.RoutingPLCConnectionType; + lstConnType.SelectedIndex = (int)myConfig.PLCConnectionType; + lstConnTypeRouting.SelectedIndex = (int)myConfig.RoutingPLCConnectionType; cmdUndo.Visible = false; cmdSave.Visible = false; @@ -226,15 +226,15 @@ private void updateConfig() myConfig.ComPortSpeed = lstLIBNODAVELokalComSpeed.SelectedItem.ToString(); if (lstLIBNODAVELokalComParity.SelectedItem.ToString() == "even") - myConfig.ComPortParity = 'e'; + myConfig.ComPortParity = LibNodaveConnectionBusParity.even; else if (lstLIBNODAVELokalComParity.SelectedItem.ToString() == "odd") - myConfig.ComPortParity = 'o'; + myConfig.ComPortParity = LibNodaveConnectionBusParity.odd; else - myConfig.ComPortParity = 'n'; + myConfig.ComPortParity = LibNodaveConnectionBusParity.none; - myConfig.ConnectionType = lstLIBNODAVEConnectionType.SelectedItem != null ? ((EnumListItem)lstLIBNODAVEConnectionType.SelectedItem).Value : 0; + myConfig.ConnectionType = (LibNodaveConnectionTypes)(lstLIBNODAVEConnectionType.SelectedItem != null ? ((EnumListItem)lstLIBNODAVEConnectionType.SelectedItem).Value : 0); - myConfig.BusSpeed = lstLIBNODAVEBusSpeed.SelectedItem != null ? ((EnumListItem)lstLIBNODAVEBusSpeed.SelectedItem).Value : 0; + myConfig.BusSpeed = (LibNodaveConnectionBusSpeed)(lstLIBNODAVEBusSpeed.SelectedItem != null ? ((EnumListItem)lstLIBNODAVEBusSpeed.SelectedItem).Value : 0); myConfig.NetLinkReset = chkNetlinkReset.Checked; @@ -247,11 +247,11 @@ private void updateConfig() myConfig.RoutingSubnet1 = Convert.ToInt32(txtRoutingSubnetFirst.Text, 16); myConfig.RoutingSubnet2 = Convert.ToInt32(txtRoutingSubnetSecond.Text, 16); - myConfig.Timeout = Convert.ToInt32(txtTimeout.Text); - myConfig.TimeoutIPConnect = Convert.ToInt32(txtTimeoutIPConnect.Text); + myConfig.Timeout = TimeSpan.FromMilliseconds(Convert.ToInt32(txtTimeout.Text)); + myConfig.TimeoutIPConnect = TimeSpan.FromMilliseconds(Convert.ToInt32(txtTimeoutIPConnect.Text)); - myConfig.PLCConnectionType = lstConnType.SelectedIndex; - myConfig.RoutingPLCConnectionType = lstConnTypeRouting.SelectedIndex; + myConfig.PLCConnectionType = (LibNodaveConnectionResource)lstConnType.SelectedIndex; + myConfig.RoutingPLCConnectionType = (LibNodaveConnectionResource)lstConnTypeRouting.SelectedIndex; } private void SaveSettings() diff --git a/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.es.resx b/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.es.resx index 05c18e5b..6f708d63 100644 --- a/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.es.resx +++ b/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.es.resx @@ -275,7 +275,7 @@ ADVERTENCIA: Conexiones de otros Software hacia Netlinka tambien seran desconect 92, 13 - Tiempo de espera + Timeout Tiempo de espera de los datos de la CPU @@ -325,15 +325,6 @@ ADVERTENCIA: Conexiones de otros Software hacia Netlinka tambien seran desconect - - Ninguno - - - par - - - impar - diff --git a/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.resx b/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.resx index d6af2dc6..2d2926e3 100644 --- a/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.resx +++ b/LibNoDaveConnectionLibrary/Communication/Editors/ConnectionEditor.resx @@ -118,1897 +118,1756 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 387, 256 + + 14, 27 - - 25 + + 336, 21 - + + 0 - - 47 - - - 97, 21 - - - 1 = PG/PC + + lstConnectionList - - 11 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + $this - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 47 - - 209, 97 + + True - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 11, 9 - - - 4 + + 73, 13 - - 11 + + 1 - - $this + + Verbindungen - - lblRoutingMinus + + label1 - - 37 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - True - - - 27, 9 + + 45 - - 387, 172 + + 356, 18 - - Microsoft Sans Serif, 6pt + + 76, 19 - - 4 + + 26 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + hinzufügen - - 7 + + cmdConnectionAdd - - $this + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 11 + + 43 - - 89, 38 + + 356, 43 - - Timeout IP Connect + + 76, 19 - - $this + + 27 - - groupBox1 + + löschen - - + + cmdConnectionDelete - - 155, 42 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Write Port + + $this - - 48, 239 + + 42 - + Popup - - chkRouting - - - True + + 14, 101 - - 76, 13 + + 333, 21 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 0 - - + + lstLIBNODAVEConnectionType - - True + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - txtRoutingRack + + $this - - 452, 10 + + 46 - + True - - 22 + + 11, 83 - - 20, 13 + + 48, 13 - - 26 + + 1 - - + + Protokoll - - 58, 13 + + label2 - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + $this - - 16 + + 44 - - groupBox1 + + True - - 26, 20 + + 44, 148 - - $this + + 76, 13 - - 2400 + + 4 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Zugangspunkt - - 130, 211 + + lblLIBNODAVEEntryPoint - + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - - txtRoutingSubnetFirst + + 35 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 130, 185 - - 130, 144 + + 49, 20 - - 48, 214 + + 4 - - 426, 365 + + 2 - - lblRoutingSubnet + + txtLIBNODAVECPURack - - 112, 21 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 13 + + $this - - lstLIBNODAVEBusSpeed + + 37 - - + + True - - + + 48, 188 - - hinzufügen + + 58, 13 - + + 4 + + + CPU-Rack + + + lblLIBNODAVECPURack + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - - 308, 175 + + 25 - - 4800 + + 130, 211 - - lblRoutingDestination + + 49, 20 + + + 5 - - + + 3 - - 0 + + txtLIBNODAVECPUSlot - + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 36 + + + True + + + 48, 214 + + + 50, 13 + + + 4 CPU-Slot - - 19 + + lblLIBNODAVECPUSlot - - lblLIBNODAVELokalComSpeed + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Popup + + $this - - 35 + + 24 - - 112, 13 + + 130, 262 - - 4 + + 97, 20 - - 131, 21 + + 7 - - 29 + + 192.168.1.1 txtLIBNODAVECPUIP - - 483, 175 - - - lblLIBNODAVECPUIP + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - + + 41 - - lstListEntryPoints + + True - - 28 + + 48, 265 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 58, 13 - + 4 - - lblTimeoutIPConnectDescr + + IP-Adresse - + + lblLIBNODAVECPUIP + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - + + 33 + + True - - COM-Parity + + 308, 235 - - 20 + + 53, 13 - - Popup + + 4 - - label2 + + COM-Port - - $this + + lblLIBNODAVELokalCOMPort - - 14, 27 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - lblTimeout + + $this - - True + + 31 - - 4 + + 387, 206 - - Popup + + 49, 20 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 12 + + + 0 - - + + txtLIBNODAVELokalMPI - + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 89, 38 + + $this - - 0 + + 39 - + True - - + + 308, 209 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 55, 13 - - 50, 20 + + 4 - - System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Lokal-MPI - - + + lblLIBNODAVELokalMPI - - 387, 231 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - - 39 + + 28 - - mS + + 130, 236 - - + + 49, 20 - + + 6 + + 2 - - 23 + + txtLIBNODAVECPUMPI - - True + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - groupBox1 + + 38 - - 45 + + True - - 289, 340 + + 48, 239 - - lstLIBNODAVELokalComSpeed + + 51, 13 - - 76, 19 + + 4 - - True + + CPU-MPI - + + lblLIBNODAVECPUMPI + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - - True + + 26 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Popup - - lstLIBNODAVELokalComParity + + 130, 314 - - 76, 19 + + 131, 21 - - MPI/DP Speed + + 9 - - True + + lstLIBNODAVEBusSpeed - - 30 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 308, 151 + + 23 - - 11 + + 452, 10 - - IP-Adresse + + 89, 38 - - txtTimeout + + 25 - - 13 + + OK - - 82, 13 + + cmdOK - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - CPU-MPI + + $this - - 308, 286 + + 19 - - 24 + + 362, 101 - - speichern + + 73, 21 - - 11, 83 + + 23 - - 90, 20 + + speichern - - Center + + False - - 10 + + cmdSave - - 65, 13 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17 - - 155, 94 + + Microsoft Sans Serif, 9pt, style=Bold - - lblLIBNODAVECPUSlot + + 14, 27 - - + + 333, 21 - - 4 + + 7 - - 308, 209 + + MiddleCenter - - + + False - - löschen + + lblConnectionName - - $this + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 4 + + $this - - 14, 19 + + 15 - - False + + Popup - - + + 387, 231 - - 31 + + 124, 21 - - + + 13 - - 18 + + lstLIBNODAVELokalCOMPort - - 4 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - lblState + + $this - - 289, 45 + + 22 - + True - - 49, 20 - - - Timeout zum warten auf Daten von der CPU - - - groupBox1 + + 47, 317 - - True + + 80, 13 - + 4 - - 10, 13 + + MPI/DP Speed - - 1 + + lblLIBNODAVEBusSpeed - - 31 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 4 + + $this - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 30 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 441, 101 - - 192.168.1.1 + + 73, 21 - - True + + 24 - - Popup + + rückgänig - - 55, 13 + + False - - 130, 262 + + cmdUndo - - 14 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - CPU-Rack + + $this - - 21 - - - Connection Typ - - - txtLIBNODAVECPURack - - - $this - - - 2 = OP - - - lstLIBNODAVEConnectionType - - - $this - - - 5 - - - 22, 13 - - - 250, 17 - - - none - - - cmdTest - - - groupBox1 - - - False - - - $this - - - 43 - - - txtRoutingSubnetSecond - - - 31 - - - 0 - - - NoControl - - - 73, 13 - - - $this - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Center - - - $this - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 4 - - - MiddleCenter - - - 427, 148 - - - 9 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 300 - - - 15 - - - 2 - - - - - - $this - - - 130, 288 - - - 80, 13 - - - 25 + + 16 - + + 128, 17 + + True - - False - - - - - - txtLIBNODAVELokalMPI - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - txtLIBNODAVECPUMPI - - - Lokal-MPI - - - $this - - - 3 - - - 6, 13 - - - 17 - - - 308, 260 - - - 2 - - - Popup + + 311, 317 - - 600 + + 188, 17 - - True + + 16 - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Netlink beim aufbau immer reseten - - 13 + + Es kann beim Netlink vorkommen das wenn eine Verbindung nicht richtig beendet wird, die +Verbindungsresource belegt bleibt. Da der Netlink nur 2 Verbindungen annehmen kann, ist wenn +dies das zweite mal passiert der Netlink nicht mehr erreichbar. Deshalb kann hiermit bei jeder neuen +Verbindung ein Reset ausgeführt werden. +Achtung: Verbindungen von anderer Software zum Netlink wird dann auch getrennt! - - $this + + chkNetlinkReset - - + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - True + + 14 - + + 128, 17 + + True - - - - - 5000 - - - Verbindungen - - - - - - 296, 93 - - - 12 - - - 2 = OP - - - 36 - - - 10 - - - 15 - - - 14, 368 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 34 - - - rückgänig - - - 49, 20 - - - 116, 97 + + 308, 175 - - 21 + + 45, 13 - - $this + + 13 - - $this + + Timeout - - 195, 288 + + Timeout zum warten auf Daten von der CPU - - 4 + + lblTimeout - - 28 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - - - - NoControl - - - Status - - - 14, 500 - - - 22 - - - 20 + + 8 - - False + + 387, 172 - - 1800 + + 90, 20 - - 31 + + 11 - - cmdSave + + 5000 - - 16 + + Timeout zum warten auf Daten von der CPU - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + txtTimeout - + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - ... - - - - - - True - - - 57600 + + 10 - - 17 + + 427, 148 - - Es kann beim Netlink vorkommen das wenn eine Verbindung nicht richtig beendet wird, die -Verbindungsresource belegt bleibt. Da der Netlink nur 2 Verbindungen annehmen kann, ist wenn -dies das zweite mal passiert der Netlink nicht mehr erreichbar. Deshalb kann hiermit bei jeder neuen -Verbindung ein Reset ausgeführt werden. -Achtung: Verbindungen von anderer Software zum Netlink wird dann auch getrennt! + + 50, 20 - - 320, 71 + + 10 - - chkUseShortRequest + + 5000 - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Timeout welcher für den Connect zu einer IP benutzt wird - - 4 + + txtTimeoutIPConnect - + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 406, 123 + + $this - - txtLIBNODAVECPUPort + + 9 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 308, 151 - - Timeout + + 101, 13 - - + + 13 - - Protokoll + + Timeout IP Connect - - txtRoutingSlot + + Timeout welcher für den Connect zu einer IP benutzt wird - - 4 + + lblTimeoutIPConnect - - 73, 21 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this + + 7 - - + + False - - $this + + 195, 288 - - 46 + + 59, 20 - - lblLIBNODAVEBusSpeed + + 32 - - $this + + Write Port - - True + + txtWritePort - - 356, 18 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 14 + + $this - - groupBox1 + + 0 - - 29 + + 265, 145 - - groupBox1 + + 26, 20 - - 27 + + 3 - - 192.168.1.1 + + ... - - Benutze Short DB Request (nur bei 400er CPU) + + btnConfigEntryPoint - - 40 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 26 + + 13 - - lblTimeoutDescr + + Popup - - groupBox1 + + 130, 144 - - 24 + + 131, 21 - - Timeout welcher für den Connect zu einer IP benutzt wird + + 1 - - $this + + lstListEntryPoints - - toolTip + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 11, 9 + + $this - - 48, 291 + + 12 - - 131, 21 + + True - - 47, 317 + + 308, 260 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 65, 13 - - lblLIBNODAVECPUPort + + 4 - - lblLIBNODAVEEntryPoint + + COM-Speed - - lblTimeoutIPConnect + + lblLIBNODAVELokalComSpeed - - label1 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + $this - - txtLIBNODAVECPUSlot + + 29 - - 53, 13 + + Popup - - chkNetlinkReset + + 75 - - - + + 110 - - 49, 20 + + 134 - - 13 + + 150 - - 000A + + 300 - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 600 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 1200 - - (none) + + 1800 - - $this + + 2400 - - btnConfigEntryPoint + + 4800 - - 25 + + 7200 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 9600 - - lblLIBNODAVELokalMPI + + 14400 - - 84, 20 + + 19200 - - COM-Speed + + 38400 - - 4 + + 57600 - - True + + 115200 - - 45, 13 + + 128000 - - 9 + + 387, 256 112, 21 - - + + 14 - - 1 = PG/PC + + lstLIBNODAVELokalComSpeed - - + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 19 + + $this - - 4 + + 21 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True - - 130, 185 + + 308, 286 - - + + 60, 13 - - 23 + + 4 - - + + COM-Parity - - 30 + + lblLIBNODAVELokalComParity - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 269, 68 + + $this - - groupBox1 + + 27 - - 13 + + Popup - - $this + + none - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + even - - 7 + + odd + + + 387, 282 + + + 112, 21 + + + 15 + + + lstLIBNODAVELokalComParity + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this - - lstConnTypeRouting + + 20 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 155, 42 - - + + 84, 20 - - True + + 18 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 192.168.1.1 - - lstConnectionList + + txtRoutingDestination - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 188, 17 + + groupBox1 - - 336, 21 + + 3 - - 9600 + + True - - 7200 + + 37, 45 - - 19200 + + 112, 13 - - 14400 + + 4 - - groupBox1 + + Ziel CPU (MPI/DP/IP) - - 38400 + + lblRoutingDestination - - $this + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 115200 + + groupBox1 - - 5000000 + + 8 - - txtRoutingDestination + + True - - + + 14, 19 - - lblLIBNODAVELokalComParity + + 63, 17 - - 60, 13 + + 17 - - 44, 148 + + Routing - - 101, 13 + + chkRouting - - 14, 101 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 51, 13 + + groupBox1 - - lblLIBNODAVECPURack + + 2 + + + 269, 68 - + 4 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 48, 20 - - 356, 43 + + 21 - - COM-Port + + 00A1 - - 9 + + Center - - + + txtRoutingSubnetFirst - - 49, 20 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 14, 27 + + groupBox1 - - 42 + + 6 - - Zugangspunkt + + True - - 48, 13 + + 289, 45 - - + + 76, 13 - - + + 4 - - 48, 20 + + S7-Subnetz-ID - - + + lblRoutingSubnet - - groupBox1 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 73, 21 + + groupBox1 - - 37, 45 + + 11 - - Timeout zum warten auf Daten von der CPU + + 332, 68 - - 48, 265 + + 4 - - lblLIBNODAVECPUMPI + + 48, 20 - - Port + + 22 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 000A - - + + Center - - + + txtRoutingSubnetSecond - - + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 311, 317 + + groupBox1 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 7 - + True - - odd + + 320, 71 - - 48, 20 + + 10, 13 - - 109, 507 + + 4 - - + + - - - lblLIBNODAVELokalCOMPort + + lblRoutingMinus - - ConnectionEditor + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + groupBox1 - - + + 12 - - 58, 13 + + 155, 68 - - 3 + + 49, 20 - - Rack + + 19 - - MiddleCenter + + 2 - - 112, 21 + + txtRoutingRack - - $this + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 128000 + + groupBox1 + + + 4 + + + True 116, 71 - - + + 33, 13 - + 4 - - lblRoutingSlot + + Rack - - 38 + + lblRoutingRack - - 6 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - OK + + groupBox1 - - Routing + + 9 - - True + + 155, 94 - - + + 49, 20 - - 5 + + 20 - + 2 - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 50, 13 - - - 433, 25 - - - txtTimeoutIPConnect - - - 155, 68 + + txtRoutingSlot - - Connection Typ + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - cmdOK + + groupBox1 - - 8 + + 5 - - Popup + + True - - 12 + + 116, 97 - - 427, 388 + + 25, 13 - - lstConnType + + 4 - - True + + Slot - - 33 + + lblRoutingSlot - - tryConnect + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + groupBox1 - - txtWritePort + + 10 + + + label4 - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 1 + + groupBox1 - - 134, 168 + + 0 - - 0 = ?? + + lstConnTypeRouting - - 44 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + groupBox1 + + 1 - - even + + 14, 368 - - 332, 68 + + 406, 123 - - Netlink beim aufbau immer reseten + + 11 - - + + groupBox1 - - + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - µS + + $this - - + + 11 - - 4 + + True - - 308, 235 + + NoControl - - lstLIBNODAVELokalCOMPort + + 209, 97 - - + + 82, 13 - - cmdUndo + + 31 - - + + Connection Typ - - + + label4 - - 26, 13 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 265, 145 + + groupBox1 - - 48, 188 + + 0 - - 59, 20 + + Popup - - 333, 21 + + 0 = ?? - - True + + 1 = PG/PC - - True + + 2 = OP - - $this + + 296, 93 - - 1 + + 97, 21 - - 2 + + 31 - - 49, 20 + + lstConnTypeRouting - - 6 + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 7 + + groupBox1 - - Popup + + 1 - - 110 + + True - - lblRoutingRack + + Microsoft Sans Serif, 6pt - - 483, 151 + + 134, 168 - + + 27, 9 + + 4 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + (none) - - 00A1 + + lblS7OnlineDevice - - NoControl + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 4 + + $this - - 387, 282 + + 34 - - $this + + 130, 288 - - Timeout welcher für den Connect zu einer IP benutzt wird + + 59, 20 - - 553, 543 + + 8 - - 0 = ?? + + 102 - - 6 + + txtLIBNODAVECPUPort - - 32 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 33, 13 + + $this - - cmdConnectionAdd + + 40 - - lblConnectionName + + True - - 130, 236 + + 48, 291 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 26, 13 - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 4 - - $this + + Port - - 97, 20 + + lblLIBNODAVECPUPort - - PLC Connection Library - Connection Editor + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 134 + + $this - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 32 - - 59, 20 + + True - - 25, 13 + + 483, 175 - - 41 + + 22, 13 - - 27 + + 13 - - groupBox1 + + mS - - label4 + + lblTimeoutDescr - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 333, 21 - - + $this - - 441, 101 + + 6 - - Microsoft Sans Serif, 9pt, style=Bold + + True - - 0 + + 483, 151 - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 22, 13 - - 8 + + 13 - - System.ComponentModel.BackgroundWorker, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + mS - - + + lblTimeoutIPConnectDescr - - True + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - label3 + + $this - - 8 + + 5 - - 3 + + 14, 500 - - + + 89, 38 - - 150 + + 25 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Verbindung testen - - 2 + + cmdTest - - + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 1200 + + $this - - 75 + + 18 - - + + 109, 507 - - 130, 314 + + 433, 25 - - 7 + + 28 - - 4 + + Status - - S7-Subnetz-ID + + MiddleCenter - - Ziel CPU (MPI/DP/IP) + + lblState + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this - - + + 4 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Popup - - 18 + + 0 = ?? - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 1 = PG/PC - - 124, 21 + + 2 = OP - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 427, 388 - - 49, 20 + + 112, 21 - - 76, 13 + + 30 - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + lstConnType - - + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 10 + + $this - - cmdConnectionDelete + + 2 - - 387, 206 + + True - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + NoControl - - 5 + + 426, 365 - - 32 + + 82, 13 - - 1 + + 29 - + + Connection Typ + + + label3 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this 3 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Slot - - - lblS7OnlineDevice - - - 63, 17 + + True - - 102 + + NoControl - - $this + + 289, 340 - - Verbindung testen + + 250, 17 - - 12 + + 31 - - 13 + + Benutze Short DB Request (nur bei 400er CPU) - - + + chkUseShortRequest - - groupBox1 + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 362, 101 + + $this - - 82, 13 + + 1 + + 17, 17 + True 29 - - 17, 17 - - - 128, 17 - + + 6, 13 + + + 553, 543 + + + PLC Connection Library - Connection Editor + + + toolTip + + + System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tryConnect + + + System.ComponentModel.BackgroundWorker, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ConnectionEditor + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/LibNoDaveConnectionLibrary/Communication/LibNoDave/libnodave.net.cs b/LibNoDaveConnectionLibrary/Communication/LibNoDave/libnodave.net.cs index 0bc35a62..90a60ab3 100644 --- a/LibNoDaveConnectionLibrary/Communication/LibNoDave/libnodave.net.cs +++ b/LibNoDaveConnectionLibrary/Communication/LibNoDave/libnodave.net.cs @@ -466,6 +466,10 @@ public int listReachablePartners(byte[] buffer) [DllImport("__Internal", EntryPoint = "daveSetTimeout")] #endif protected static extern void daveSetTimeout32(IntPtr di, int time); + /// + /// Set the default Response timeout + /// + /// Time in Microseconds public void setTimeout(int time) { if (IntPtr.Size == 8) diff --git a/LibNoDaveConnectionLibrary/Communication/PLCConnection.cs b/LibNoDaveConnectionLibrary/Communication/PLCConnection.cs index 0fdf1fcb..6996e4da 100644 --- a/LibNoDaveConnectionLibrary/Communication/PLCConnection.cs +++ b/LibNoDaveConnectionLibrary/Communication/PLCConnection.cs @@ -153,7 +153,7 @@ public string Name private System.Timers.Timer socketTimer; private Thread socketThread; - + private FetchWriteConnection _fetchWriteConnection; void socketTimer_Elapsed(object sender, ElapsedEventArgs e) @@ -199,8 +199,9 @@ public void Connect() lock (lockObj) { _NeedDispose = true; + //Debugging for LibNoDave - libnodave.daveSetDebug(0x0); + libnodave.daveSetDebug(0x0); //turn off libnodave log messages to console //libnodave.daveSetDebug(0x1ffff); //_configuration.ReloadConfiguration(); @@ -211,23 +212,26 @@ public void Connect() //This Jump mark is used when the Netlink Reset is activated! NLAgain: + #region Setup Port/Adapter //LibNodave Verbindung aufbauen switch (_configuration.ConnectionType) { - case 1: - case 2: - case 3: - case 4: - case 10: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Andrews_Version_without_STX: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Step_7_Version: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Adrews_Version_with_STX: + case LibNodaveConnectionTypes.PPI_über_Serial_Adapter: _errorCodeConverter = libnodave.daveStrerror; - _fds.rfd = libnodave.setPort(_configuration.ComPort, _configuration.ComPortSpeed, _configuration.ComPortParity); + _fds.rfd = libnodave.setPort(_configuration.ComPort, _configuration.ComPortSpeed, (int)_configuration.ComPortParity); break; - case 20: //AS511 + + case LibNodaveConnectionTypes.AS_511: _errorCodeConverter = libnodave.daveStrerror; - _fds.rfd = libnodave.setPort(_configuration.ComPort, _configuration.ComPortSpeed, _configuration.ComPortParity); + _fds.rfd = libnodave.setPort(_configuration.ComPort, _configuration.ComPortSpeed, (int)_configuration.ComPortParity); break; -#if !IPHONE - case 50: + +#if !IPHONE + case LibNodaveConnectionTypes.Use_Step7_DLL: _errorCodeConverter = libnodave.daveStrerror; _fds.rfd = libnodave.openS7online(_configuration.EntryPoint, 0); if (_fds.rfd.ToInt32() == -1) @@ -237,14 +241,14 @@ public void Connect() } break; #endif - case 122: - case 123: - case 124: - case 223: - case 224: - case 230: + + case LibNodaveConnectionTypes.ISO_over_TCP: + case LibNodaveConnectionTypes.ISO_over_TCP_CP_243: + case LibNodaveConnectionTypes.Netlink_lite: + case LibNodaveConnectionTypes.Netlink_lite_PPI: + case LibNodaveConnectionTypes.Netlink_Pro: _errorCodeConverter = libnodave.daveStrerror; - socketTimer = new System.Timers.Timer(_configuration.TimeoutIPConnect); + socketTimer = new System.Timers.Timer(_configuration.TimeoutIPConnect.TotalMilliseconds); socketTimer.AutoReset = true; socketTimer.Elapsed += socketTimer_Elapsed; socketTimer.Start(); @@ -269,66 +273,72 @@ public void Connect() socketTimer = null; socketThread = null; break; - case 500: + + case LibNodaveConnectionTypes.Fetch_Write_Active: _fetchWriteConnection=new FetchWriteConnection(this.Configuration); _fetchWriteConnection.Connect(); Connected = true; return; - break; + //case 9050: // _errorCodeConverter = Connection.daveStrerror; // _dc = new S7onlineNETdave(_configuration); // break; - case 9122: + case LibNodaveConnectionTypes.ISO_over_TCP_Managed: _errorCodeConverter = Connection.daveStrerror; _dc = new TcpNETdave(_configuration); break; } - - if (_configuration.ConnectionType < 9000 && _fds.rfd.ToInt32() == -999) + //if it is an Non manged version, using libnodave. Enums > 9000 are Managed implemntations + if ((int)_configuration.ConnectionType < 9000) { - _NeedDispose = false; - throw new Exception("Error: Timeout Connecting the IP"); - } - if (_configuration.ConnectionType < 9000) - { - if ((_configuration.ConnectionType != 50 && _fds.rfd.ToInt32() == 0) || _fds.rfd.ToInt32() < 0) + //if the socket handle still has its default value after connection + //this means it was an IP connection type, and it did not succed + if (_fds.rfd.ToInt32() == -999) + { + _NeedDispose = false; + throw new Exception("Error: Timeout Connecting the IP"); + } + + //if the read handle is still null or even has an error code, except for Simatic NEt connectoins + if ((_configuration.ConnectionType != LibNodaveConnectionTypes.Use_Step7_DLL && _fds.rfd.ToInt32() == 0) || _fds.rfd.ToInt32() < 0) { _NeedDispose = false; throw new Exception( "Error: Could not creating the Physical Interface (Maybe wrong IP, COM-Port not Ready,...)"); } - } - if (_configuration.ConnectionType < 9000) - { - //daveOSserialType Struktur befüllen + //The connection was successfull _fds.wfd = _fds.rfd; } if (_configuration.ConnectionName == null) _configuration.ConnectionName = Guid.NewGuid().ToString(); - if (_configuration.ConnectionType < 9000) + #endregion + + #region Create the Interface + //Create the Interface + if ((int)_configuration.ConnectionType < 9000) //Enums > 9000 are Managed implemntations { //Dave Interface Erzeugen - _di = new libnodave.daveInterface(_fds, _configuration.ConnectionName, _configuration.LokalMpi, _configuration.ConnectionType, _configuration.BusSpeed); + _di = new libnodave.daveInterface(_fds, _configuration.ConnectionName, _configuration.LokalMpi, (int)_configuration.ConnectionType, (int)_configuration.BusSpeed); //Timeout setzen... - _di.setTimeout(_configuration.Timeout); + _di.setTimeout((int)_configuration.TimeoutMicroseconds); //WARNING! setTimeout needs value in Microseconds //Dave Interface initialisieren var initret = _di.initAdapter(); if (initret != 0) - throw new Exception("Error: (Interface) (Code: " + initret.ToString() + ") " + _errorCodeConverter(initret)); + throw new PLCException("Error: (Interface) (Code: " + initret.ToString() + ") " + _errorCodeConverter(initret),initret); } //Get S7OnlineType - To detect if is a IPConnection bool IPConnection = false; #if !IPHONE - if (_configuration.ConnectionType == 50) + if (_configuration.ConnectionType == LibNodaveConnectionTypes.Use_Step7_DLL) { RegistryKey myConnectionKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Siemens\\SINEC\\LogNames\\" + @@ -346,27 +356,30 @@ public void Connect() } //Get S7OnlineType - To detect if is a IPConnection #endif + #endregion - //AS511 - if (_configuration.ConnectionType == 20) + #region Create Connection + if (_configuration.ConnectionType == LibNodaveConnectionTypes.AS_511) { _dc = new libnodave.daveConnection(_di, _configuration.CpuMpi, 0, 0); } - else if (_configuration.ConnectionType < 9000) + else if ((int)_configuration.ConnectionType < 9000) //Enums > 9000 are Managed implemntations { _dc = new libnodave.daveConnection(_di, _configuration.CpuMpi, _configuration.CpuIP, IPConnection, _configuration.CpuRack, _configuration.CpuSlot, _configuration.Routing, _configuration.RoutingSubnet1, _configuration.RoutingSubnet2, _configuration.RoutingDestinationRack, _configuration.RoutingDestinationSlot, - _configuration.RoutingDestination, _configuration.PLCConnectionType, - _configuration.RoutingPLCConnectionType); + _configuration.RoutingDestination, (int)_configuration.PLCConnectionType, + (int)_configuration.RoutingPLCConnectionType); } else { } - - if (_configuration.NetLinkReset && !_netlinkReseted && (_configuration.ConnectionType == 223 || _configuration.ConnectionType == 224)) + #endregion + + #region Connect PLC + if (_configuration.NetLinkReset && !_netlinkReseted && (_configuration.ConnectionType == LibNodaveConnectionTypes.Netlink_lite || _configuration.ConnectionType == LibNodaveConnectionTypes.Netlink_lite_PPI)) { _dc.resetIBH(); _netlinkReseted = true; @@ -375,19 +388,30 @@ public void Connect() } var ret = _dc.connectPLC(); - if (ret == -1) { _dc = null; throw new Exception("Error: CPU not available! Maybe wrong IP or MPI Address or Rack/Slot or ..."); } if (ret != 0) - throw new Exception("Error: (Connection) (Code: " + ret.ToString() + ") " + _errorCodeConverter(ret)); + throw new PLCException("Error: (Connection) (Code: " + ret.ToString() + ") " + _errorCodeConverter(ret), ret); Connected = true; + #endregion } } + /// + /// Internal Helper function that checks if the PLC is connectec, reconnects automatially or throws an Exception + /// Call this function befor accessing the PLC Communication + /// + void CheckConnection() + { + if (Connected) return; + if (AutoConnect) Connect(); + else throw new Exception("No connection to the PLC established yet"); + } + /// /// This Disconnects from the PLC and the Adapter /// @@ -404,8 +428,7 @@ public void PLCStop() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) _dc.stop(); @@ -420,8 +443,7 @@ public void PLCStart() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) _dc.start(); @@ -436,8 +458,7 @@ public DateTime PLCReadTime() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) return _dc.daveReadPLCTime(); @@ -453,8 +474,7 @@ public void PLCSetTime(DateTime tm) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) _dc.daveSetPLCTime(tm); @@ -639,8 +659,7 @@ S7FunctionBlockRow.SelectedStatusValues selRegister { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -893,8 +912,7 @@ public DataTypes.PLCState PLCGetSafetyStep() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -902,7 +920,7 @@ public DataTypes.PLCState PLCGetSafetyStep() int ret = _dc.readSZL(0x232, 4, buffer); if (ret < 0) - throw new Exception("Error: " + _errorCodeConverter(ret)); + throw new PLCException(ret); if (buffer[1] != 0x04) throw new WPFToolboxForSiemensPLCsException( WPFToolboxForSiemensPLCsExceptionType.ErrorReadingSZL); @@ -924,8 +942,7 @@ public bool PLCSendPassword(string pwd) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -960,8 +977,8 @@ public DataTypes.PLCState PLCGetState() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); + //Dokumentation of SZL can be found here: http://www.google.de/url?sa=t&source=web&cd=3&ved=0CCQQFjAC&url=http%3A%2F%2Fdce.felk.cvut.cz%2Frs%2Fplcs7315%2Fmanualy%2Fsfc_e.pdf&ei=tY8QTJufEYSNOLD_oMoH&usg=AFQjCNEHofHOLDcvGp-4eQBwlboKPu3oxQ if (_dc != null) { @@ -971,7 +988,7 @@ public DataTypes.PLCState PLCGetState() if (ret == 54273) return DataTypes.PLCState.NotSupported; if (ret < 0) - throw new Exception("Error: " + _errorCodeConverter(ret)); + throw new PLCException(ret); if (buffer[10] == 1 && buffer[11] == 1) return DataTypes.PLCState.Starting; else if (buffer[10] == 1) @@ -994,8 +1011,7 @@ public List PLCListBlocks(DataTypes.PLCBlockType myBlk) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1029,7 +1045,7 @@ public List PLCListBlocks(DataTypes.PLCBlockType myBlk) { int ret = _dc.ListBlocksOfType(Helper.GetPLCBlockTypeForBlockList(myBlk), blocks); if (ret < 0 && ret != -53763 && ret != -53774 && ret != -255) - throw new Exception("Error: " + _errorCodeConverter(ret)); + throw new PLCException(ret); if (ret > 0) for (int n = 0; n < ret*4; n += 4) { @@ -1052,8 +1068,7 @@ public List PLCListBlocks2(DataTypes.PLCBlockType myBlk) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1085,7 +1100,7 @@ public List PLCListBlocks2(DataTypes.PLCBlockType myBlk) { int ret = _dc.ListBlocksOfType(Helper.GetPLCBlockTypeForBlockList(myBlk), blocks); if (ret < 0 && ret != -53763 && ret != -53774 && ret != -255) - throw new Exception("Error: " + _errorCodeConverter(ret)); + throw new PLCException(ret); if (ret > 0) for (int n = 0; n < ret * 4; n += 4) { @@ -1107,8 +1122,7 @@ public Dictionary PLCGetBlockCount() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1120,7 +1134,7 @@ public Dictionary PLCGetBlockCount() //Send Request res = _dc.daveBuildAndSendPDU(PDU, Para, Data); if (res != 0) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); //Wait for Respond byte[] RecData = null; @@ -1128,7 +1142,7 @@ public Dictionary PLCGetBlockCount() res = _dc.daveRecieveData(out RecData, out RecPara); if (!(res == 0)) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); //Parse Response data Dictionary dict = new Dictionary(); @@ -1170,8 +1184,7 @@ public S7Block PLCGetBlockHeader(PLCBlockType type, int number) lock (lockObj) { //Auto connect or Error if not connected yet - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); //Load Block List from PLC //Para Format: @@ -1206,7 +1219,7 @@ public S7Block PLCGetBlockHeader(PLCBlockType type, int number) //Send Request res = _dc.daveBuildAndSendPDU(PDU, Para, Data); if (res != 0) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); byte[] RecData = null; //the Received Data byte[] RecPara = null; //The Receive Parameter @@ -1214,7 +1227,7 @@ public S7Block PLCGetBlockHeader(PLCBlockType type, int number) //Get response from controller res = _dc.daveGetPDUData(PDU, out RecData, out RecPara); if (!(res == 0)) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); //Trim first 10 bytes from header byte[] MC7Code = new byte[RecData.Length - 10]; @@ -1247,8 +1260,7 @@ public byte[] PLCGetBlockInMC7(string BlockName) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1299,10 +1311,10 @@ public byte[] PLCGetBlockInMC7(string BlockName) Array.Copy(buffer, retVal, readsize); return retVal; } - else if (ret == 53825) - throw new Exception("PLC is Password Protected, unlock before downloading Blocks!"); + else if (ret == 53825) //Error: D241: Operation not permitted in current protection level. + throw new PLCException("PLC is Password Protected, unlock before downloading Blocks!",ret); else - return null; + throw new PLCException(ret); } return null; } @@ -1317,8 +1329,7 @@ public void PLCPutBlockFromMC7toPLC(string BlockName, byte[] buffer) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1380,9 +1391,9 @@ public void PLCPutBlockFromMC7toPLC(string BlockName, byte[] buffer) return; } else if (ret == 53825) - throw new Exception("PLC is Password Protected, unlock before downloading Blocks!"); + throw new PLCException("PLC is Password Protected, unlock before downloading Blocks!",ret); else - throw new Exception("Error from PLC! Code: " + ret); + throw new PLCException(ret); } return; } @@ -1396,8 +1407,7 @@ public void PLCDeleteBlock(string BlockName) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1442,8 +1452,7 @@ public SZLData PLCGetSZL(Int16 SZLNummer, Int16 Index) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1459,7 +1468,7 @@ public SZLData PLCGetSZL(Int16 SZLNummer, Int16 Index) //COUNT(WORD) 6,7 if (ret < 0) - throw new Exception("Error: " + _errorCodeConverter(ret)); + throw new PLCException(ret); retVal.SzlId = (short) (buffer[1] + buffer[0]*256); retVal.Index = (short) (buffer[3] + buffer[2]*256); @@ -1606,8 +1615,7 @@ public SZLData PLCGetSZL(Int16 SZLNummer, Int16 Index) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1622,7 +1630,7 @@ public SZLData PLCGetSZL(Int16 SZLNummer, Int16 Index) //COUNT(WORD) 6,7 if (ret < 0) - throw new Exception("Error: " + _errorCodeConverter(ret)); + throw new PLCException(ret); int cnt = buffer[7] + buffer[6]*256; @@ -1647,8 +1655,7 @@ public DataTypes.PLCMemoryInfo PLCGetMemoryInfo() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -1688,8 +1695,7 @@ public void PLCCompressMemory() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); //This is a very slow function, so increase the timeout int Timeout = _di.getTimeout(); @@ -1703,7 +1709,7 @@ public void PLCCompressMemory() //Send Request res = _dc.daveBuildAndSendPDU(PDU, Para, Data); if (res != 0) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); //Wait for Respond byte[] RecData = null; @@ -1713,7 +1719,7 @@ public void PLCCompressMemory() _di.setTimeout(Timeout * 10); //Restore original Timeout if (!(res == 0)) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); } } @@ -1724,8 +1730,7 @@ public void PLCCopyRamToRom() { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); //This is a very slow function, so increase the timeout int Timeout = _di.getTimeout(); @@ -1739,7 +1744,7 @@ public void PLCCopyRamToRom() //Send Request res = _dc.daveBuildAndSendPDU(PDU, Para, Data); if (res != 0) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); //Wait for Respond byte[] RecData = null; @@ -1749,7 +1754,7 @@ public void PLCCopyRamToRom() _di.setTimeout(Timeout * 10); //Restore original Timeout if (!(res == 0)) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); } } #endregion @@ -2167,7 +2172,7 @@ private int GetPduSize() /// private void _TestNewReadValues(IEnumerable valueList, bool useReadOptimization) { - if (Configuration.ConnectionType == 20) //AS511 + if (Configuration.ConnectionType == LibNodaveConnectionTypes.AS_511) //AS511 { foreach (var plcTag in valueList) { @@ -2186,8 +2191,7 @@ private void _TestNewReadValues(IEnumerable valueList, bool useReadOptim //read the tags! //Look, that the byte count gets not bigger than a pdu! - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -2407,7 +2411,7 @@ private void _TestNewReadValues(IEnumerable valueList, bool useReadOptim return; } else if (res != 0 && res != 10) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); //positionInCompleteData = 0; //Save the Read Data to a User Byte Array (Because we use this in the libnodavevalue class!) @@ -2429,7 +2433,7 @@ private void _TestNewReadValues(IEnumerable valueList, bool useReadOptim details += "readsizes " + string.Join(";", cPDU.readenSizes) + Environment.NewLine; details += "usedShortRequest " + string.Join(";", cPDU.usedShortRequest) + Environment.NewLine; - throw new Exception("Error (1): " + _errorCodeConverter(res) + details); + throw new PLCException("Error (1): " + _errorCodeConverter(res) + details, res); } else { @@ -2500,7 +2504,7 @@ public void ReadValues(IEnumerable valueList) /// if the tag exceeds the data-blocks length, it will fail before sending it to the controller public void ReadValuesWithCheck(IEnumerable valueList, bool cacheDbSizes = false) { - if (Configuration.ConnectionType == 500 || Configuration.ConnectionType == 501) + if (Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Passive || Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Active) { ReadValuesFetchWrite(valueList, false); return; @@ -2547,7 +2551,7 @@ public void ReadValuesWithCheck(IEnumerable valueList, bool cacheDbSizes /// The List of values to be read form the controller public void ReadValues(IEnumerable valueList, bool useReadOptimization) { - if (Configuration.ConnectionType == 20) //AS511 + if (Configuration.ConnectionType == LibNodaveConnectionTypes.AS_511) //AS511 { foreach (var plcTag in valueList) { @@ -2556,7 +2560,7 @@ public void ReadValues(IEnumerable valueList, bool useReadOptimization) return; } - if (Configuration.ConnectionType == 500 || Configuration.ConnectionType == 501) + if (Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Active || Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Passive) { ReadValuesFetchWrite(valueList, useReadOptimization); return; @@ -2573,8 +2577,7 @@ public void ReadValues(IEnumerable valueList, bool useReadOptimization) //read the tags! //Look, that the byte count gets not bigger than a pdu! - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); if (_dc != null) { @@ -2800,7 +2803,7 @@ public void ReadValues(IEnumerable valueList, bool useReadOptimization) return; } else if (res != 0) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); //Save the Read Data to a User Byte Array (Because we use this in the libnodavevalue class!) for (akVar = 0; akVar < anzVar; akVar++) @@ -2825,7 +2828,7 @@ public void ReadValues(IEnumerable valueList, bool useReadOptimization) string.Join(Environment.NewLine, currentRead) + Environment.NewLine + Environment.NewLine; - throw new Exception("Error (2): " + _errorCodeConverter(res) + details); + throw new PLCException("Error (2): " + _errorCodeConverter(res) + details, res); } else { @@ -2920,7 +2923,7 @@ public void ReadValues(IEnumerable valueList, bool useReadOptimization) return; } else if (res != 0 && res != 10) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); //positionInCompleteData = 0; //Save the Read Data to a User Byte Array (Because we use this in the libnodavevalue class!) @@ -2942,7 +2945,7 @@ public void ReadValues(IEnumerable valueList, bool useReadOptimization) details += "readsizes " + string.Join(";", readenSizes) + Environment.NewLine; details += "usedShortRequest " + string.Join(";", usedShortRequest) + Environment.NewLine; - throw new Exception("Error (3): " + _errorCodeConverter(res) + details); + throw new PLCException("Error (3): " + _errorCodeConverter(res) + details, res); } else { @@ -3158,7 +3161,7 @@ public object ReadValue(string address) /// public void ReadValue(PLCTag value) { - if (!string.IsNullOrEmpty(value.SymbolicAccessKey) && Configuration.ConnectionType != 20) + if (!string.IsNullOrEmpty(value.SymbolicAccessKey) && Configuration.ConnectionType != LibNodaveConnectionTypes.AS_511) { ReadValues(new[] { value }); return; @@ -3170,7 +3173,7 @@ public void ReadValue(PLCTag value) return; } - if (Configuration.ConnectionType == 500 || Configuration.ConnectionType == 501) + if (Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Active || Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Passive) { ReadValuesFetchWrite(new[] { value }, false); return; @@ -3179,8 +3182,8 @@ public void ReadValue(PLCTag value) lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); + if (_dc != null) { @@ -3212,7 +3215,7 @@ public void ReadValue(PLCTag value) else if (res == 5 || res == 10) value.ItemDoesNotExist = true; else - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); } } } @@ -3252,10 +3255,9 @@ public void WriteValue(PLCTag value) lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); - if (Configuration.ConnectionType == 500 || Configuration.ConnectionType == 501) + if (Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Active || Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Passive) { WriteValuesFetchWrite(new []{value}); return; @@ -3292,7 +3294,7 @@ public void WriteValue(PLCTag value) return; } else if (res != 0) - throw new Exception("Error: " + _errorCodeConverter(res)); + throw new PLCException(res); } } } @@ -3349,10 +3351,9 @@ public void WriteValues(IEnumerable valueList, bool useWriteOptimation) { lock (lockObj) { - if (AutoConnect && !Connected) - Connect(); + CheckConnection(); - if (Configuration.ConnectionType == 500 || Configuration.ConnectionType == 501) + if (Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Active || Configuration.ConnectionType == LibNodaveConnectionTypes.Fetch_Write_Passive) { WriteValuesFetchWrite(valueList); return; @@ -3747,24 +3748,22 @@ public void Dispose() if (_configuration!=null) switch (_configuration.ConnectionType) { - case 1: - case 2: - case 3: - case 4: - case 10: - case 20: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Andrews_Version_without_STX: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Step_7_Version: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Adrews_Version_with_STX: + case LibNodaveConnectionTypes.PPI_über_Serial_Adapter: + case LibNodaveConnectionTypes.AS_511: libnodave.closePort(_fds.rfd); break; - case 50: + case LibNodaveConnectionTypes.Use_Step7_DLL: libnodave.closeS7online(_fds.rfd); break; - case 122: - case 123: - case 124: - case 223: - case 224: - case 230: - case 231: + case LibNodaveConnectionTypes.ISO_over_TCP: + case LibNodaveConnectionTypes.ISO_over_TCP_CP_243: + case LibNodaveConnectionTypes.Netlink_lite: + case LibNodaveConnectionTypes.Netlink_lite_PPI: + case LibNodaveConnectionTypes.Netlink_Pro: libnodave.closeSocket(_fds.rfd); break; } diff --git a/LibNoDaveConnectionLibrary/Communication/PLCConnectionConfiguration.cs b/LibNoDaveConnectionLibrary/Communication/PLCConnectionConfiguration.cs index a6a7901d..ed7a85c6 100644 --- a/LibNoDaveConnectionLibrary/Communication/PLCConnectionConfiguration.cs +++ b/LibNoDaveConnectionLibrary/Communication/PLCConnectionConfiguration.cs @@ -32,11 +32,11 @@ You should have received a copy of the GNU Library General Public License using Microsoft.Win32; namespace DotNetSiemensPLCToolBoxLibrary.Communication -{ +{ #if !IPHONE [System.ComponentModel.Editor(typeof(PLCConnectionUITypeEditor), typeof(System.Drawing.Design.UITypeEditor))] #endif - [Serializable] + [Serializable] /// /// This Class stores the Connection Configuration to a PLC /// @@ -51,8 +51,12 @@ private void NotifyPropertyChanged(String info) PropertyChanged(this, new PropertyChangedEventArgs(info)); } } - + + #region Properties private string _connectionName; + /// + /// Name of the connection. This value can be freely defined by the user + /// public String ConnectionName { get { return _connectionName; } @@ -65,6 +69,11 @@ public String ConnectionName } private string _entryPoint = "S7ONLINE"; + /// + /// the entry point of the Simatic NEt configuration to be used. + /// Please refer to the Simatic Net documentation for details. + /// by default is S7ONLINE + /// public string EntryPoint { get { return _entryPoint; } @@ -80,6 +89,10 @@ public bool UseShortDataBlockRequest } private int _cpuRack = 0; + /// + /// The Rack where the destination CPU is inserted. This value should be 0 in almost all cases. + /// Only in Multi CPU configurations this needs to be adjusted. + /// public int CpuRack { get { return _cpuRack; } @@ -87,6 +100,12 @@ public int CpuRack } private int _cpuSlot = 2; + /// + /// The slot where the destination CPU is inserted in the selected Rack. + /// This value depends on the particular hardware configuration of the CPU. + /// Usually it is 2 for S7-300 CPUs and 3 for S7-400 CPUs + /// On Redundant H-CPU configurations this value must be set accordingly, in order for the comunication to work properly + /// public int CpuSlot { get { return _cpuSlot; } @@ -94,6 +113,11 @@ public int CpuSlot } private int _cpuMpi = 2; + /// + /// The MPI address of the remote CPU. this depends on the particular hardware configuration and is usually + /// set to 2 by default. + /// Only relevant for MPI connections + /// public int CpuMpi { get { return _cpuMpi; } @@ -101,6 +125,10 @@ public int CpuMpi } private string _cpuIp = "192.168.1.100"; + /// + /// The IP-Adress or Hostname of the CPU's ethernet connection. + /// Only relevant for ISO over TCP connections. + /// public string CpuIP { get { return _cpuIp; } @@ -108,6 +136,10 @@ public string CpuIP } private int _port = 102; + /// + /// The TCP Port to be used for connecting the CPU via ISO over TCP. + /// This value usually should set to the default 102 (ISO Transport Service Access Point (TSAP) Class 0 protocol) + /// public int Port { get { return _port; } @@ -122,6 +154,10 @@ public int WritePort } private int _lokalMpi = 0; + /// + /// The local MPI Address to be used by the MPI adapter to comunicate with the CPU. + /// By convention the address 0 is reserved for Programing devices. + /// public int LokalMpi { get { return _lokalMpi; } @@ -129,35 +165,50 @@ public int LokalMpi } private string _comPort = "COM1"; + /// + /// The Com port name where the MPI adapter is connected to. + /// if an RS232 to USB adapter is used (such as the Siamtic USB-MPI adapter) + /// the Virtual com port name of the adapter must be chosen. + /// public string ComPort { get { return _comPort; } set { _comPort = value; NotifyPropertyChanged("ComPort"); NotifyPropertyChanged("ObjectAsString"); } } - private int _plcConnectionType = 1; - public int PLCConnectionType + private LibNodaveConnectionResource _plcConnectionType = LibNodaveConnectionResource.PG; + /// + /// Defines the Connection resource to be used in the PLC + /// + public LibNodaveConnectionResource PLCConnectionType { get { return _plcConnectionType; } set { _plcConnectionType = value; NotifyPropertyChanged("PLCConnectionType"); NotifyPropertyChanged("ObjectAsString"); } } - private int _routingplcConnectionType = 1; - public int RoutingPLCConnectionType + private LibNodaveConnectionResource _routingplcConnectionType = LibNodaveConnectionResource.PG; + public LibNodaveConnectionResource RoutingPLCConnectionType { get { return _routingplcConnectionType; } set { _routingplcConnectionType = value; NotifyPropertyChanged("RoutingPLCConnectionType"); NotifyPropertyChanged("ObjectAsString"); } } - private int _connectionType = 122; - public int ConnectionType + private LibNodaveConnectionTypes _connectionType = LibNodaveConnectionTypes.ISO_over_TCP; + /// + /// Defines how the connection to the PLC should be established + /// + public LibNodaveConnectionTypes ConnectionType { get { return _connectionType; } set { _connectionType = value; NotifyPropertyChanged("ConnectionType"); NotifyPropertyChanged("ObjectAsString"); } } - private int _busSpeed = 2; - public int BusSpeed + private LibNodaveConnectionBusSpeed _busSpeed = LibNodaveConnectionBusSpeed.Speed_187k; + /// + /// defines the Bus speed for the connected MPI adapter + /// The default MPI bus speed is 19200 bit / second + /// + public LibNodaveConnectionBusSpeed BusSpeed { get { return _busSpeed; } set { _busSpeed = value; NotifyPropertyChanged("BusSpeed"); NotifyPropertyChanged("ObjectAsString"); } @@ -171,14 +222,22 @@ public bool NetLinkReset } private string _comPortSpeed = "38400"; + /// + /// defines the Bus speed for the connected MPI adapter + /// The default MPI bus speed is 19200 bit / second + /// public string ComPortSpeed { get { return _comPortSpeed; } set { _comPortSpeed = value; NotifyPropertyChanged("ComPortSpeed"); NotifyPropertyChanged("ObjectAsString"); } } - private int _comPortParity = 1; - public int ComPortParity + private LibNodaveConnectionBusParity _comPortParity = LibNodaveConnectionBusParity.even; + + /// + /// Com port parity to use for MPI connection. By default MPI uses Even parity + /// + public LibNodaveConnectionBusParity ComPortParity { get { return _comPortParity; } set @@ -231,20 +290,52 @@ public int RoutingSubnet2 set { _routingSubnet2 = value; NotifyPropertyChanged("RoutingSubnet2"); NotifyPropertyChanged("ObjectAsString"); } } - private int _timeout = 5000000; - public int Timeout + private TimeSpan _timeout = TimeSpan.FromMilliseconds( 5000); + /// + /// The timeout to wait for responses from the PLC + /// in microseconds + /// + [XmlIgnore] + public TimeSpan Timeout { get { return _timeout; } set { _timeout = value; NotifyPropertyChanged("Timeout"); NotifyPropertyChanged("ObjectAsString"); } } - private int _timeoutIpConnect = 5000; - public int TimeoutIPConnect + /// + /// Used for serialization only. + /// + /// The Problem is that the XML Serializer can not serialize Timespans. So serialize an "hidden" integer instead + [XmlElement(ElementName = "Timeout"), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public int TimeoutMicroseconds + { + get { return (int)Timeout.TotalMilliseconds * 1000; } + set { Timeout = TimeSpan.FromMilliseconds(value / 1000); } + } + + private TimeSpan _timeoutIpConnect = TimeSpan.FromMilliseconds(5000); + /// + /// The default Timeout to be used for ISO over TCP conection + /// In miliseconds + /// + [XmlIgnore] + public TimeSpan TimeoutIPConnect { get { return _timeoutIpConnect; } set { _timeoutIpConnect = value; NotifyPropertyChanged("TimeoutIPConnect"); NotifyPropertyChanged("ObjectAsString"); } } + /// + /// Used for serialization only. + /// + /// The Problem is that the XML Serializer can not serialize Timespans. So serialize an "hidden" integer instead + [XmlElement (ElementName = "TimeoutIPConnect"), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] + public int TimeoutIPConnectMiliseconds + { + get { return (int)TimeoutIPConnect.TotalMilliseconds;} + set { _timeoutIpConnect = TimeSpan.FromMilliseconds (value); } + } + private bool _initDone { get; set; } private LibNodaveConnectionConfigurationType _configurationType; @@ -253,6 +344,7 @@ public LibNodaveConnectionConfigurationType ConfigurationType get { return _configurationType; } set { _configurationType = value; NotifyPropertyChanged("ConfigurationType"); NotifyPropertyChanged("ObjectAsString"); } } + #endregion public string ObjectAsString { @@ -264,26 +356,27 @@ public static String[] GetConfigurationNames() #if !IPHONE if (File.Exists(ConfigurationPathAndFilename)) { - DictionarySerializer ConnectionsDicSer = new DictionarySerializer(); Dictionary Connections = null; - StreamReader strm = new StreamReader(ConfigurationPathAndFilename); - Connections = ConnectionsDicSer.Deserialize(strm); - //string txt = strm.ReadToEnd(); + using (TextReader strm = new StreamReader(ConfigurationPathAndFilename)) + { + Connections = LoadConfigFile(strm); strm.Close(); - //Connections = General.SerializeToString>.DeSerialize(txt); - if (Connections != null) - { - string[] Names = new string[Connections.Count]; - Connections.Keys.CopyTo(Names, 0); - return Names; - } + } + + //Connections = General.SerializeToString>.DeSerialize(txt); + if (Connections != null) + { + string[] Names = new string[Connections.Count]; + Connections.Keys.CopyTo(Names, 0); + return Names; + } } return new string[0]; - RegistryKey myConnectionKey = - Registry.CurrentUser.CreateSubKey("Software\\JFKSolutions\\WPFToolboxForSiemensPLCs\\Connections"); - return myConnectionKey.GetSubKeyNames(); + //RegistryKey myConnectionKey = + // Registry.CurrentUser.CreateSubKey("Software\\JFKSolutions\\WPFToolboxForSiemensPLCs\\Connections"); + //return myConnectionKey.GetSubKeyNames(); #else return null; #endif @@ -372,13 +465,14 @@ public void ReloadConfiguration() if (File.Exists(ConfigurationPathAndFilename)) { - DictionarySerializer ConnectionsDicSer = new DictionarySerializer(); Dictionary Connections = null; - StreamReader strm = new StreamReader(ConfigurationPathAndFilename); - Connections = ConnectionsDicSer.Deserialize(strm); - //string txt = strm.ReadToEnd(); - strm.Close(); + using (TextReader strm = new StreamReader(ConfigurationPathAndFilename)) + { + Connections = LoadConfigFile(strm); + strm.Close(); + } + //Connections = General.SerializeToString>.DeSerialize(txt); if (Connections != null && Connections.ContainsKey(ConnectionName)) { @@ -414,76 +508,165 @@ public void ReloadConfiguration() } return; - - RegistryKey myConnectionKey = - Registry.CurrentUser.CreateSubKey( - "Software\\JFKSolutions\\WPFToolboxForSiemensPLCs\\Connections\\" + ConnectionName); - if (myConnectionKey != null) - { - this.EntryPoint = (String)myConnectionKey.GetValue("EntryPoint", "S7ONLINE"); - this.CpuRack = Convert.ToInt32(myConnectionKey.GetValue("CpuRack", "0")); - this.CpuSlot = Convert.ToInt32(myConnectionKey.GetValue("CpuSlot", "2")); - this.CpuMpi = Convert.ToInt32(myConnectionKey.GetValue("CpuMpi", "2")); - this.CpuIP = (String)myConnectionKey.GetValue("CpuIP", "192.168.1.1"); - this.LokalMpi = Convert.ToInt32(myConnectionKey.GetValue("LokalMpi", "0")); - this.ComPort = (String)myConnectionKey.GetValue("ComPort", ""); - this.ConnectionType = Convert.ToInt32(myConnectionKey.GetValue("ConnectionType", "1")); - this.BusSpeed = Convert.ToInt32(myConnectionKey.GetValue("BusSpeed", "2")); - this.NetLinkReset = Convert.ToBoolean(myConnectionKey.GetValue("NetLinkReset", "false")); - this.ComPortSpeed = (String)myConnectionKey.GetValue("ComPortSpeed", "38400"); - this.ComPortParity = Convert.ToInt32(myConnectionKey.GetValue("ComPortParity", "1")); - this.Routing = Convert.ToBoolean(myConnectionKey.GetValue("Routing", "false")); - this.RoutingDestinationRack = - Convert.ToInt32(myConnectionKey.GetValue("RoutingDestinationRack", "0")); - this.RoutingDestinationSlot = - Convert.ToInt32(myConnectionKey.GetValue("RoutingDestinationSlot", "2")); - this.RoutingSubnet1 = Convert.ToInt32(myConnectionKey.GetValue("RoutingSubnet1", "0")); - this.RoutingSubnet2 = Convert.ToInt32(myConnectionKey.GetValue("RoutingSubnet2", "0")); - this.RoutingDestination = Convert.ToString(myConnectionKey.GetValue("RoutingDestination", "2")); - this.Port = Convert.ToInt32(myConnectionKey.GetValue("Port", "102")); - this.WritePort = Convert.ToInt32(myConnectionKey.GetValue("WritePort", "30501")); - - this.PLCConnectionType = Convert.ToInt32(myConnectionKey.GetValue("PLCConnectionType", "1")); - this.RoutingPLCConnectionType = Convert.ToInt32(myConnectionKey.GetValue("RoutingPLCConnectionType", "1")); - - this.Timeout = Convert.ToInt32(myConnectionKey.GetValue("Timeout", "5000000")); - this.TimeoutIPConnect = Convert.ToInt32(myConnectionKey.GetValue("TimeoutIPConnect", "5000")); - } + //RegistryKey myConnectionKey = + // Registry.CurrentUser.CreateSubKey( + // "Software\\JFKSolutions\\WPFToolboxForSiemensPLCs\\Connections\\" + ConnectionName); + //if (myConnectionKey != null) + //{ + // this.EntryPoint = (String)myConnectionKey.GetValue("EntryPoint", "S7ONLINE"); + // this.CpuRack = Convert.ToInt32(myConnectionKey.GetValue("CpuRack", "0")); + // this.CpuSlot = Convert.ToInt32(myConnectionKey.GetValue("CpuSlot", "2")); + // this.CpuMpi = Convert.ToInt32(myConnectionKey.GetValue("CpuMpi", "2")); + // this.CpuIP = (String)myConnectionKey.GetValue("CpuIP", "192.168.1.1"); + // this.LokalMpi = Convert.ToInt32(myConnectionKey.GetValue("LokalMpi", "0")); + // this.ComPort = (String)myConnectionKey.GetValue("ComPort", ""); + // this.ConnectionType = (LibNodaveConnectionTypes)Convert.ToInt32(myConnectionKey.GetValue("ConnectionType", "1")); + // this.BusSpeed = (LibNodaveConnectionBusSpeed)Convert.ToInt32(myConnectionKey.GetValue("BusSpeed", "2")); + // this.NetLinkReset = Convert.ToBoolean(myConnectionKey.GetValue("NetLinkReset", "false")); + // this.ComPortSpeed = (String)myConnectionKey.GetValue("ComPortSpeed", "38400"); + // this.ComPortParity = (LibNodaveConnectionBusParity)Convert.ToInt32(myConnectionKey.GetValue("ComPortParity", "1")); + // this.Routing = Convert.ToBoolean(myConnectionKey.GetValue("Routing", "false")); + // this.RoutingDestinationRack = + // Convert.ToInt32(myConnectionKey.GetValue("RoutingDestinationRack", "0")); + // this.RoutingDestinationSlot = + // Convert.ToInt32(myConnectionKey.GetValue("RoutingDestinationSlot", "2")); + // this.RoutingSubnet1 = Convert.ToInt32(myConnectionKey.GetValue("RoutingSubnet1", "0")); + // this.RoutingSubnet2 = Convert.ToInt32(myConnectionKey.GetValue("RoutingSubnet2", "0")); + // this.RoutingDestination = Convert.ToString(myConnectionKey.GetValue("RoutingDestination", "2")); + // this.Port = Convert.ToInt32(myConnectionKey.GetValue("Port", "102")); + // this.WritePort = Convert.ToInt32(myConnectionKey.GetValue("WritePort", "30501")); + + // this.PLCConnectionType = (LibNodaveConnectionResource)Convert.ToInt32(myConnectionKey.GetValue("PLCConnectionType", "1")); + // this.RoutingPLCConnectionType = (LibNodaveConnectionResource)Convert.ToInt32(myConnectionKey.GetValue("RoutingPLCConnectionType", "1")); + + // this.Timeout = Convert.ToInt32(myConnectionKey.GetValue("Timeout", "5000000")); + // this.TimeoutIPConnect = TimeSpan.FromMilliseconds( Convert.ToInt32(myConnectionKey.GetValue("TimeoutIPConnect", "5000"))); + //} #endif } else { if (!_initDone) { - this.ConnectionType = 122; + this.ConnectionType = LibNodaveConnectionTypes.ISO_over_TCP; this.CpuMpi = 2; this.EntryPoint = "S7ONLINE"; this.CpuIP = "192.168.1.1"; this.CpuRack = 0; this.CpuSlot = 2; this.Port = 102; - this.TimeoutIPConnect = 5000; - this.Timeout = 5000000; + this.TimeoutIPConnect = TimeSpan.FromMilliseconds (5000); + this.Timeout = TimeSpan.FromMilliseconds(5000); _initDone = true; } } } + #region Load and Repair Config File + /// + /// Reads the configuration from an Stream + /// + /// + /// + private static Dictionary LoadConfigFile(TextReader strm) + { + Dictionary Connections; + DictionarySerializer ConnectionsDicSer = new DictionarySerializer(); + + //the idea here is, to try to deserialize the data once, and if it fails, + //Try to repair it. If it fails also the second time, then give up an throw + //This is neede to maintain Backwards compatibility with config files that do not use + //Enumerations. + try + { + Connections = ConnectionsDicSer.Deserialize(strm); + + } + catch (Exception ex) + { + try + { + strm.Close(); //Close old stream + strm = new StreamReader(ConfigurationPathAndFilename); //Reopen temporary stream + string repaired = repairConfig(strm.ReadToEnd()); + strm.Close(); //Close temporary stream + strm = new StringReader(repaired); + Connections = ConnectionsDicSer.Deserialize(strm); + } + catch + { + throw ex; //Throw orignial Exception + } + } + return Connections; + } + + /// + /// Try to repair the configuration file if an error is encoutnerd + /// + /// + /// + private static string repairConfig(string original) + { + string config = original; + config = fixEnum(config, "ConnectionType", typeof(LibNodaveConnectionTypes)); + config = fixEnum(config, "PLCConnectionType", typeof(LibNodaveConnectionResource)); + config = fixEnum(config, "RoutingPLCConnectionType", typeof(LibNodaveConnectionResource)); + config = fixEnum(config, "BusSpeed", typeof(LibNodaveConnectionBusSpeed)); + config = fixEnum(config, "ComPortParity", typeof(LibNodaveConnectionBusParity)); + + return config; + } + + /// + /// Replace the numerical enumeration value with its textual Value + /// + /// The original Config file content to search in + /// The Name of the property to replace the value on + /// The type of Enumeration of the property in question + /// + private static string fixEnum(string original, string PropertyName, Type PropertyEnumType) + { + string New = original; + + int idx = original.IndexOf("<" + PropertyName + ">", 0, StringComparison.Ordinal); + + while (idx >= 0) + { + idx = idx + PropertyName.Length + 2; + + //Find next "Closing" tag and extract the current numerical value + int Eidx = New.IndexOf("", idx, StringComparison.Ordinal); + } + + return New; + } + #endregion + public static void DeleteConfiguration(string ConnectionName) { #if !IPHONE try { - DictionarySerializer ConnectionsDicSer = new DictionarySerializer(); - Dictionary Connections = null; + if (File.Exists(ConfigurationPathAndFilename)) { - StreamReader strm = new StreamReader(ConfigurationPathAndFilename); - Connections = ConnectionsDicSer.Deserialize(strm); - //string txt = strm.ReadToEnd(); - strm.Close(); - //Connections = General.SerializeToString>.DeSerialize(txt); + using (TextReader strm = new StreamReader(ConfigurationPathAndFilename)) + { + Connections = LoadConfigFile(strm); + strm.Close(); + } } if (Connections == null) Connections = new Dictionary(); @@ -493,6 +676,7 @@ public static void DeleteConfiguration(string ConnectionName) Directory.CreateDirectory(Path.GetDirectoryName(ConfigurationPathAndFilename)); StreamWriter sstrm = new StreamWriter(ConfigurationPathAndFilename, false); + DictionarySerializer ConnectionsDicSer = new DictionarySerializer(); ConnectionsDicSer.Serialize(Connections, sstrm); //sstrm.Write(stxt); //sstrm.Flush(); @@ -500,8 +684,8 @@ public static void DeleteConfiguration(string ConnectionName) return; - Registry.CurrentUser.DeleteSubKeyTree( - "Software\\JFKSolutions\\WPFToolboxForSiemensPLCs\\Connections\\" + ConnectionName); + //Registry.CurrentUser.DeleteSubKeyTree( + // "Software\\JFKSolutions\\WPFToolboxForSiemensPLCs\\Connections\\" + ConnectionName); } catch (Exception) { } @@ -514,16 +698,17 @@ public void SaveConfiguration() { #if !IPHONE - DictionarySerializer ConnectionsDicSer = new DictionarySerializer(); - + DictionarySerializer ConnectionsDicSer = new DictionarySerializer(); Dictionary Connections = null; + if (File.Exists(ConfigurationPathAndFilename)) { - StreamReader strm = new StreamReader(ConfigurationPathAndFilename); - Connections = ConnectionsDicSer.Deserialize(strm); - //string txt = strm.ReadToEnd(); - strm.Close(); - //Connections = General.SerializeToString>.DeSerialize(txt); + using (TextReader strm = new StreamReader(ConfigurationPathAndFilename)) + { + Connections = LoadConfigFile(strm); + strm.Close(); + } + } if (Connections == null) Connections = new Dictionary(); @@ -542,36 +727,36 @@ public void SaveConfiguration() return; - RegistryKey myConnectionKey = - Registry.CurrentUser.CreateSubKey( - "Software\\JFKSolutions\\WPFToolboxForSiemensPLCs\\Connections\\" + ConnectionName); - if (myConnectionKey != null) - { - myConnectionKey.SetValue("EntryPoint", this.EntryPoint); - myConnectionKey.SetValue("CpuRack", this.CpuRack); - myConnectionKey.SetValue("CpuSlot", this.CpuSlot); - myConnectionKey.SetValue("CpuMpi", this.CpuMpi); - myConnectionKey.SetValue("CpuIP", this.CpuIP); - myConnectionKey.SetValue("LokalMpi", this.LokalMpi); - myConnectionKey.SetValue("ComPort", this.ComPort); - myConnectionKey.SetValue("ConnectionType", this.ConnectionType); - myConnectionKey.SetValue("BusSpeed", this.BusSpeed); - myConnectionKey.SetValue("NetLinkReset", this.NetLinkReset); - myConnectionKey.SetValue("ComPortSpeed", this.ComPortSpeed); - myConnectionKey.SetValue("ComPortParity", this.ComPortParity); - myConnectionKey.SetValue("Routing", this.Routing); - myConnectionKey.SetValue("RoutingDestinationRack", this.RoutingDestinationRack); - myConnectionKey.SetValue("RoutingDestinationSlot", this.RoutingDestinationSlot); - myConnectionKey.SetValue("RoutingSubnet1", this.RoutingSubnet1); - myConnectionKey.SetValue("RoutingSubnet2", this.RoutingSubnet2); - myConnectionKey.SetValue("RoutingDestination", this.RoutingDestination); - myConnectionKey.SetValue("Port", this.Port); - myConnectionKey.SetValue("WritePort", this.WritePort); - myConnectionKey.SetValue("PLCConnectionType", this.PLCConnectionType); - myConnectionKey.SetValue("RoutingPLCConnectionType", this.RoutingPLCConnectionType); - myConnectionKey.SetValue("Timeout", this.Timeout); - myConnectionKey.SetValue("TimeoutIPConnect", this.TimeoutIPConnect); - } + //RegistryKey myConnectionKey = + // Registry.CurrentUser.CreateSubKey( + // "Software\\JFKSolutions\\WPFToolboxForSiemensPLCs\\Connections\\" + ConnectionName); + //if (myConnectionKey != null) + //{ + // myConnectionKey.SetValue("EntryPoint", this.EntryPoint); + // myConnectionKey.SetValue("CpuRack", this.CpuRack); + // myConnectionKey.SetValue("CpuSlot", this.CpuSlot); + // myConnectionKey.SetValue("CpuMpi", this.CpuMpi); + // myConnectionKey.SetValue("CpuIP", this.CpuIP); + // myConnectionKey.SetValue("LokalMpi", this.LokalMpi); + // myConnectionKey.SetValue("ComPort", this.ComPort); + // myConnectionKey.SetValue("ConnectionType", (int)this.ConnectionType); + // myConnectionKey.SetValue("BusSpeed", (int)this.BusSpeed); + // myConnectionKey.SetValue("NetLinkReset", this.NetLinkReset); + // myConnectionKey.SetValue("ComPortSpeed", this.ComPortSpeed); + // myConnectionKey.SetValue("ComPortParity", (int)this.ComPortParity); + // myConnectionKey.SetValue("Routing", this.Routing); + // myConnectionKey.SetValue("RoutingDestinationRack", this.RoutingDestinationRack); + // myConnectionKey.SetValue("RoutingDestinationSlot", this.RoutingDestinationSlot); + // myConnectionKey.SetValue("RoutingSubnet1", this.RoutingSubnet1); + // myConnectionKey.SetValue("RoutingSubnet2", this.RoutingSubnet2); + // myConnectionKey.SetValue("RoutingDestination", this.RoutingDestination); + // myConnectionKey.SetValue("Port", this.Port); + // myConnectionKey.SetValue("WritePort", this.WritePort); + // myConnectionKey.SetValue("PLCConnectionType", (int)this.PLCConnectionType); + // myConnectionKey.SetValue("RoutingPLCConnectionType", (int)this.RoutingPLCConnectionType); + // myConnectionKey.SetValue("Timeout", this.Timeout); + // myConnectionKey.SetValue("TimeoutIPConnect", this.TimeoutIPConnect); + //} #endif } } @@ -582,46 +767,46 @@ public override string ToString() switch (ConnectionType) { - case 1: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter: retVal = "MPI über seriell" + " (Port: " + ComPort + ", MPI: " + CpuMpi.ToString() + ")"; break; - case 2: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Andrews_Version_without_STX: retVal = "MPI über seriell (Andrews Version)" + " (Port: " + ComPort + ", MPI: " + CpuMpi.ToString() + ")"; break; - case 3: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Step_7_Version: retVal = "MPI über seriell (Step7 Version)" + " (Port: " + ComPort + ", MPI: " + CpuMpi.ToString() + ")"; break; - case 4: + case LibNodaveConnectionTypes.MPI_über_Serial_Adapter_Adrews_Version_with_STX: retVal = "MPI über seriell" + " (Port: " + ComPort + ", MPI: " + CpuMpi.ToString() + ")"; break; - case 10: + case LibNodaveConnectionTypes.PPI_über_Serial_Adapter: retVal = "PPI über seriell"; break; - case 20: + case LibNodaveConnectionTypes.AS_511: retVal = "AS 511"; break; - case 50: + case LibNodaveConnectionTypes.Use_Step7_DLL: retVal = "Step7 DLL" + " (" + EntryPoint + ")"; break; - case 122: + case LibNodaveConnectionTypes.ISO_over_TCP: retVal = "ISO over TCP" + " (IP:" + CpuIP.ToString() + ",Rack:" + CpuRack.ToString() + ",Slot:" + CpuSlot.ToString() + ")"; break; - case 123: + case LibNodaveConnectionTypes.ISO_over_TCP_CP_243: retVal = "ISO over TCP (CP243)" + " (IP:" + CpuIP.ToString() + ",Rack:" + CpuRack.ToString() + ",Slot:" + CpuSlot.ToString() + ")"; break; - case 223: + case LibNodaveConnectionTypes.Netlink_lite: retVal = "Netlink lite" + " (IP:" + CpuIP.ToString() + ")"; break; - case 224: + case LibNodaveConnectionTypes.Netlink_lite_PPI: retVal = "Netlink lite PPI" + " (IP:" + CpuIP.ToString() + ")"; break; - case 230: + case LibNodaveConnectionTypes.Netlink_Pro: retVal = "Netlink PRO" + " (IP:" + CpuIP.ToString() + ")"; break; - case 500: + case LibNodaveConnectionTypes.Fetch_Write_Active: retVal = "Fetch/Write (Active)" + " (IP:" + CpuIP.ToString() + ", Port:" + Port + ", WritePort:" + WritePort + ")"; break; - case 501: + case LibNodaveConnectionTypes.Fetch_Write_Passive: retVal = "Fetch/Write (Passive)" + " (IP:" + CpuIP.ToString() + ", Port:" + Port + ", WritePort:" + WritePort + ")"; break; } @@ -634,7 +819,6 @@ public override string ToString() return retVal; } - public void SaveConfigToFile(string filename) { string txt = General.SerializeToString.Serialize(this); @@ -662,14 +846,35 @@ public enum LibNodaveConnectionConfigurationType public enum LibNodaveConnectionTypes { // ReSharper disable InconsistentNaming + None = 0, + + /// + /// Connection via MPI adapter connected to an Serial Com Port + /// MPI_über_Serial_Adapter = 1, MPI_über_Serial_Adapter_Andrews_Version_without_STX = 2, MPI_über_Serial_Adapter_Step_7_Version = 3, MPI_über_Serial_Adapter_Adrews_Version_with_STX = 4, PPI_über_Serial_Adapter = 10, + + /// + /// Connection via the AS511 Protocoll used by S5 series PLCs + /// AS_511 = 20, + + /// + /// Connection via the Simatic Net libraries. Simatic Net must be installed + /// Use_Step7_DLL = 50, + + /// + /// Connections via the TCP/IP protocoll + /// ISO_over_TCP = 122, + + /// + /// Connections via TCP/IP to an CP243 for S7-200 series PLCs + /// ISO_over_TCP_CP_243 = 123, Netlink_lite = 223, Netlink_lite_PPI = 224, @@ -692,4 +897,34 @@ public enum LibNodaveConnectionBusSpeed Speed_93k = 6 // ReSharper restore InconsistentNaming } + + public enum LibNodaveConnectionBusParity + { + even = 'e', + odd = 'o', + none = 'n' + } + + /// + /// Defines the type of connection resource to use for communiction with the PLC + /// 'PG' for operations that manipulate MC7 code (this the default) + /// 'OP' for operations on data only + /// + public enum LibNodaveConnectionResource + { + /// + /// No resource or an unknown resource will be used for communication + /// + unknown = 0, + + /// + /// Use PC/PG (Programming functions) resource. Allows manipulation of MC7 code + /// + PG = 1, + + /// + /// Use OP (operator panel) functions. Allows datamanipulation functions only + /// + OP = 2 + } } diff --git a/LibNoDaveConnectionLibrary/Communication/PLCException.cs b/LibNoDaveConnectionLibrary/Communication/PLCException.cs new file mode 100644 index 00000000..153c8de5 --- /dev/null +++ b/LibNoDaveConnectionLibrary/Communication/PLCException.cs @@ -0,0 +1,29 @@ +using DotNetSiemensPLCToolBoxLibrary.Communication.LibNoDave; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace DotNetSiemensPLCToolBoxLibrary.Communication +{ + public class PLCException:Exception + { + int _ErrorCode; + int ErrorCode + { + get { return _ErrorCode; } + } + + public PLCException (int errorCode): + base(String.Format("Operation failed due to error from PLC {0}: {1}",errorCode, libnodave.daveStrerror(errorCode))) + { + _ErrorCode = errorCode; + } + + public PLCException(string msg, int errorCode) : + base(msg) + { + _ErrorCode = errorCode; + } + } +} diff --git a/LibNoDaveConnectionLibrary/DotNetSiemensPLCToolBoxLibrary.csproj b/LibNoDaveConnectionLibrary/DotNetSiemensPLCToolBoxLibrary.csproj index 64874f88..47f03e3f 100644 --- a/LibNoDaveConnectionLibrary/DotNetSiemensPLCToolBoxLibrary.csproj +++ b/LibNoDaveConnectionLibrary/DotNetSiemensPLCToolBoxLibrary.csproj @@ -90,6 +90,7 @@ + diff --git a/SimpleCSharpService/Service.cs b/SimpleCSharpService/Service.cs index 665703ff..694d52d4 100644 --- a/SimpleCSharpService/Service.cs +++ b/SimpleCSharpService/Service.cs @@ -47,7 +47,7 @@ protected override void OnStart(string[] args) base.OnStart(args); var cfg = new PLCConnectionConfiguration("myConnection", LibNodaveConnectionConfigurationType.ObjectSavedConfiguration); - cfg.ConnectionType = (int) LibNodaveConnectionTypes.ISO_over_TCP; + cfg.ConnectionType = LibNodaveConnectionTypes.ISO_over_TCP; cfg.CpuIP = "192.168.1.185"; cfg.CpuSlot = 2;