private void FormCnc_Load(object sender, System.EventArgs e) { MainApp.GetDoc().tcFKey1.Focus(); // restore the view type tcAxesList1.AxisPositionType = (TcAxisPositionType)MainApp.appSettings.axesPositionType; tcAxesList1.CncCoordinateSystem = (TcCoordinateSystem)MainApp.appSettings.axesCoordinateSystem; tcAxesList1.CncValueOutputFormat = MainApp.appSettings.axesValueOutputFormat; // Language Manager if (tclm != null) { tclm.StringDel += new CTCLManager.InitStringDelegate(LoadLanguageStrings); LoadLanguageStrings(); } // Operation Mode tcFKeyOpMode.FKeyTextAlign = System.Drawing.ContentAlignment.MiddleRight; tcFKeyOpMode.FKeyImageAlign = System.Drawing.ContentAlignment.MiddleLeft; int i; Button btn; for (i = 1; i <= 4; i++) { btn = tcFKeyOpMode.FKeyButtonObj(i); btn.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); } // Left Keys for (i = 1; i <= 8; i++) { btn = tcFKeyLeft.FKeyButtonObj(i); btn.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); } // Path for CNC Program Selection opModeAuto1.selectFile1.InitialDirectory = MainApp.appSettings.pathSettings[0]; }
private void LoadLanguageKeysLeft() { Button btn; tcFKeyLeft.FKeySelectedMode = true; if (adsNcServer != null && adsNcServer.NcIsRunning) { int max = adsNcServer.NcClient.InterfaceData.NumberOfChannels; for (int i = 1; i <= max; i++) { tcFKeyLeft.FKeyText(i, tclm["FormCnc.tcFKeyLeft[1]"] + " " + i.ToString()); } // select first if (0 < selectedKeyPressChannel && selectedKeyPressChannel <= max || selectedKeyPressChannel == 8) { btn = tcFKeyLeft.FKeyButtonObj(selectedKeyPressChannel); btn.BackColor = MainApp.GetDoc().ColorCaption; // is the selected color } tcFKeyLeft.FKeyText(8, tclm["FormCnc.tcFKeyLeft[8]"]); //"CNC Kanäle" } }
private void buttonTargetSystem_Click(object sender, EventArgs e) { Beckhoff.Forms.TcAdsPlcServer adsPlcServer = MainApp.GetDoc().AdsPlcServer; Beckhoff.Forms.TcRemoteDialog remoteDlg = new Beckhoff.Forms.TcRemoteDialog(); remoteDlg.LocalAmsNetId = adsPlcServer.PlcClient.TcAdsSystemClient.ClientNetID.ToString(); remoteDlg.ShowDialog(); if (remoteDlg.DialogResult == DialogResult.OK) { if (remoteDlg.IsLocal) { textBoxAmsNetId.Clear(); } else { textBoxAmsNetId.Text = remoteDlg.AmsNetId; } Application.DoEvents(); if (adsPlcServer.ClientNetId != textBoxAmsNetId.Text) { adsPlcServer.ClientNetId = textBoxAmsNetId.Text; adsPlcServer.PlcClient.Reconnect(); } } }
public override void FKeyUpEvent(int nIdx) { switch (nIdx) { case 1: cBLanguage.Visible = true; buttonLocate.Visible = true; eventLogStatusTag = "FormMessages.labelEventLogStatus.ActiveEvents"; tcEventLoggerData1.GetActiveEvents(); // not absolutely necessary LoadLanguageStrings(); tcEventLoggerList1.Focus(); tcLog4NetView1.ShowEvents(false); MainApp.GetDoc().tcFKey1.FKeyEnabled(6, false); MainApp.GetDoc().tcFKey1.FKeyEnabled(7, false); break; case 2: cBLanguage.Visible = false; buttonLocate.Visible = false; eventLogStatusTag = "FormMessages.labelEventLogStatus.LoggedEvents"; LoadLanguageStrings(); tcLog4NetView1.ShowEvents(true); MainApp.GetDoc().tcFKey1.FKeyEnabled(6, true); MainApp.GetDoc().tcFKey1.FKeyEnabled(7, true); /* * try * { * eventLogStatusTag = "FormMessages.labelEventLogStatus.LoggedEvents"; * tcEventLoggerData1.GetAllLoggedEvents(); * } * catch {} * LoadLanguageStrings(); * tcEventLoggerList1.Focus(); */ break; case 3: if (tcLog4NetView1.Visible == true) { tcLog4NetView1.ShowDetailWindow = !tcLog4NetView1.ShowDetailWindow; tcLog4NetView1.Focus(); } else { tcEventLoggerList1.ShowDetailWindow = !tcEventLoggerList1.ShowDetailWindow; tcEventLoggerList1.Focus(); } break; case 5: eventLogStatusTag = "FormMessages.labelEventLogStatus.ActiveEvents"; tcEventLoggerData1.ClearActiveEvents(); LoadLanguageStrings(); break; case 6: try { string logFile = tcLog4NetView1.FileName; DialogResult msgBoxRes = new DialogResult(); // make a copy msgBoxRes = MessageBox.Show("Do you want to save the logfile before clearing it?", "Save logfile", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (msgBoxRes == DialogResult.Yes) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "LOG files (*.log)|*.log|All files (*.*)|*.*";; dlg.RestoreDirectory = true; if (dlg.ShowDialog() == DialogResult.OK) { System.IO.File.Copy(logFile, dlg.FileName, true); } } // delete logfile if (msgBoxRes == DialogResult.Yes || msgBoxRes == DialogResult.No) { log4net.LogManager.GetRepository().ResetConfiguration(); log4net.LogManager.GetRepository().Shutdown(); System.IO.File.Delete(logFile); log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Application.StartupPath + "\\System\\log.xml")); MainApp.log.Info("Log file has been deleted by " + LocalMenu.UserAdmin.CurrentUser.Name + " (" + LocalMenu.UserAdmin.CurrentUser.FullName + ")"); tcLog4NetView1.ShowEvents(); } } catch { } break; case 7: try { // make a copy string logFile = tcLog4NetView1.FileName; SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "LOG files (*.log)|*.log|All files (*.*)|*.*";; dlg.RestoreDirectory = true; if (dlg.ShowDialog() == DialogResult.OK) { System.IO.File.Copy(logFile, dlg.FileName, true); } } catch { } break; } }
private void tcFKeyRight_FKeyUpEvent(int nIdx) { bool bActivate; int selectedChannel = MainApp.GetDoc().AppHeader.ChannelNr; string plcString = ".PLCMachineMode[" + selectedChannel.ToString() + "]"; switch (nIdx) { case 1: // Single step / Einzelsatz if (tclm["FormCnc.tcFKeyRight[1]"] != "") { bActivate = !SpecialFunc.SingleBlockMode; if (SetPLCVar(plcString + ".SingleBlock", bActivate)) { SpecialFunc.SingleBlockMode = bActivate; } } break; case 2: // Skip block / (Program block ignore) / Satz ausblenden if (tclm["FormCnc.tcFKeyRight[2]"] != "") { bActivate = !SpecialFunc.SkipBlock; if (SetPLCVar(plcString + ".PrgBlockIgnore", bActivate)) { SpecialFunc.SkipBlock = bActivate; } } break; case 3: // M01Stop / Wahlhalt if (tclm["FormCnc.tcFKeyRight[3]"] != "") { bActivate = !SpecialFunc.M01Stop; if (SetPLCVar(plcString + ".M01Stop", bActivate)) { SpecialFunc.M01Stop = bActivate; } } break; case 4: // Backward / Retrace / Rückwärts fahren if (tclm["FormCnc.tcFKeyRight[4]"] != "") { bActivate = !SpecialFunc.Retrace; if (SetPLCVar(plcString + ".Backward", bActivate)) { SpecialFunc.Retrace = bActivate; } } break; case 6: break; case 7: // Set Program if (tclm["FormCnc.tcFKeyRight[7]"] != "") { MainApp.appSettings.mdiCommand[selectedChannel] = opModeMDI1.MdiText; SetPLCVar(plcString + ".MDIString", opModeMDI1.MdiText); SetPLCVar(plcString + ".ProgramName", opModeAuto1.selectFile1.Arguments); } break; case 8: // Enable / HW Freigabe if (tclm["FormCnc.tcFKeyRight[8]"] != "") { bActivate = !SpecialFunc.EnableHW; if (SetPLCVar(".PLCAxisEnable", bActivate)) { SpecialFunc.EnableHW = bActivate; } } break; } ShowIconStatus(); }
/// <summary> /// Initializes a new instance of the <see cref="T:FormCnc"/> class. /// </summary> /// <param name="f">The form.</param> public FormCnc(Form form) { parentForm = form; InitializeComponent(); //resolution 800x6000 if (MainApp.appSettings.applicationHeaderType == 1 || MainApp.appSettings.applicationHeaderType == 2) { int left = panelCnc.Left; tcFKeyLeft.Visible = false; int diff = tcFKeyRight.Width - 100; tcFKeyRight.Width = 100; panelCnc.Left = 0; panelCnc.Width += left + diff; panelChannelOverview.Left = 0; panelChannelOverview.Width += left + diff; } MainApp mainApp = MainApp.GetDoc(); int svrPortNrNc = 0; if (MainApp.appSettings.tagetSystem == 0) { svrPortNrNc = 553; } else { svrPortNrNc = 501; blockSearch1.Enabled = false; // no block search with NCI syntaxCheck1.Enabled = false; // no syntax check with NCI } // the one and only instance of the AdsNcServer and AdsPlcServer string amsNetId = MainApp.appSettings.amsNetId; adsNcServer = new TcAdsNcServer(svrPortNrNc, amsNetId); adsPlcServer = new TcAdsPlcServer(801, amsNetId); // map the adsServer object to the main form mainApp.AdsPlcServer = adsPlcServer; mainApp.AdsNcServer = adsNcServer; // connect the components to the adsServer tcSpeedControl1.AdsNcServer = adsNcServer; tcAxesList1.AdsNcServer = adsNcServer; tcOverride1.AdsNcServer = adsNcServer; tcTechnoData1.AdsNcServer = adsNcServer; blockSearch1.AdsPlcServer = adsPlcServer; syntaxCheck1.AdsPlcServer = adsPlcServer; teachIn1.AdsPlcServer = adsPlcServer; teachIn1.AdsNcServer = adsNcServer; opModeManual1.AdsNcServer = adsNcServer; if (svrPortNrNc == 501 && MainApp.appSettings.plcVarNciOverrideChannel1 != "") { tcPlcConnectNciOvrChannel0 = new TcPlcConnect(); tcPlcConnectNciOvrChannel0.PlcVariableName = MainApp.appSettings.plcVarNciOverrideChannel1; tcPlcConnectNciOvrChannel0.AdsPlcServer = adsPlcServer; tcPlcConnectNciOvrChannel0.ValueChanged += new TcPlcValueChangedEventHandler(tcPlcConnectNciOvrChannel0_ValueChanged); } plcFKeyRightStatus = new bool[8]; plcFKeyLeftStatus = new bool[8]; // Language Manager tclm = mainApp.GetTCLanguageManager(); tcAxesList1.LanguageManager = tclm; tcOverride1.LanguageManager = tclm; tcSpeedControl1.LanguageManager = tclm; tcTechnoData1.LanguageManager = tclm; blockSearch1.LanguageManager = tclm; syntaxCheck1.LanguageManager = tclm; teachIn1.LanguageManager = tclm; // Operation Mode Keys tcFKeyOpMode.Visible = false; // color for the right and left keys tcFKeyLeft.FKeyBtnBackColor = mainApp.ColorFKeyLR; tcFKeyLeft.FKeyBtnSelectedColor = mainApp.ColorCaption; tcFKeyLeft.BackColor = mainApp.ColorFKeyLR; tcFKeyRight.FKeyBtnBackColor = mainApp.ColorFKeyLR; tcFKeyRight.FKeyBtnSelectedColor = mainApp.ColorCaption; tcFKeyRight.BackColor = mainApp.ColorFKeyLR; // Set the program name for the first channel opModeAuto1.selectFile1.Arguments = MainApp.appSettings.programName[1]; opModeAuto1.tcNcProgramSection1.CncProgramName = MainApp.appSettings.programName[1]; System.Collections.Generic.List <string> listOfSearchPaths = new System.Collections.Generic.List <string>(); int nMin = MainApp.appSettings.pathSettings.GetLowerBound(0); int nMax = MainApp.appSettings.pathSettings.GetUpperBound(0); for (int i = nMin; i <= nMax; i++) { if (!string.IsNullOrEmpty(MainApp.appSettings.pathSettings[i])) { listOfSearchPaths.Add(MainApp.appSettings.pathSettings[i]); } } adsNcServer.NcClient.ProgramSectionPathList(listOfSearchPaths); opModeMDI1.MdiText = MainApp.appSettings.mdiCommand[1]; // Delegate instance: Selecting axis in manual mode tcAxesList1.AxisSelectEvent += new SingleAxisSelectEventHandler(tcAxesList1_AxisSelectEvent); // Delegate instance: Override change tcOverride1.OverrideChanged += new OverrideChangedEventHandler(tcOverride1_OverrideChanged); // Delegate instance: TwinCAT Cnc is Running adsNcServer.TcNcStateChanged += new Beckhoff.Forms.Nc.TcAdsStateChangedEventHandler(adsNcServer_TcNcStateChanged); // Delegate instance: TwinCAT Plc is Running adsPlcServer.TcPlcStateChanged += new Beckhoff.Forms.TcAdsStateChangedEventHandler(adsPlcServer_TcPlcStateChanged); // Delegate instance: Error handling for errors from the AdsServer adsNcServer.NcClient.Error += new Beckhoff.Forms.Nc.TcErrorEventHandler(AdsClient_Error); adsPlcServer.PlcClient.Error += new Beckhoff.Forms.TcErrorEventHandler(AdsClient_Error); // Delegate instance: Operation mode switch adsNcServer.NcClient.OpModeStateChanged += new CncOpModeStateChangedEventHandler(NcClient_OpModeStateChanged); // Moves the operation modes key-window OpModeWindow = new OperationModeWindow(); TimerStatusUpdate = new Timer(); TimerStatusUpdate.Interval = 2000; TimerStatusUpdate.Tick += new EventHandler(TimerStatusUpdate_Tick); // tcChannelStatus1.AdsNcServer = adsNcServer; tcChannelStatus2.AdsNcServer = adsNcServer; tcChannelStatus3.AdsNcServer = adsNcServer; tcChannelStatus4.AdsNcServer = adsNcServer; tcChannelStatus1.ChannelNumber = 1; tcChannelStatus2.ChannelNumber = 2; tcChannelStatus3.ChannelNumber = 3; tcChannelStatus4.ChannelNumber = 4; tcAxesList2.AdsNcServer = adsNcServer; tcAxesList3.AdsNcServer = adsNcServer; tcAxesList4.AdsNcServer = adsNcServer; tcAxesList5.AdsNcServer = adsNcServer; tcAxesList2.ChannelNumber = 1; tcAxesList3.ChannelNumber = 2; tcAxesList4.ChannelNumber = 3; tcAxesList5.ChannelNumber = 4; panelChannelOverview.BringToFront(); tcAxesList1.CaptionBackColor = mainApp.ColorCaption; tcChannelStatus1.BackColor = mainApp.ColorCaption; tcChannelStatus2.BackColor = mainApp.ColorCaption; tcChannelStatus3.BackColor = mainApp.ColorCaption; tcChannelStatus4.BackColor = mainApp.ColorCaption; tcSpeedControl1.CaptionBackColor = mainApp.ColorCaption; tcTechnoData1.CaptionBackColor = mainApp.ColorCaption; tcOverride1.CaptionBackColor = mainApp.ColorCaption; opModeAuto1.CaptionBackColor = mainApp.ColorCaption; opModeManual1.CaptionBackColor = mainApp.ColorCaption; opModeMDI1.CaptionBackColor = mainApp.ColorCaption; blockSearch1.CaptionBackColor = mainApp.ColorCaption; syntaxCheck1.CaptionBackColor = mainApp.ColorCaption; teachIn1.CaptionBackColor = mainApp.ColorCaption; tcAxesList1.AxisRowHeight = MainApp.appSettings.axesRowHeight; if (MainApp.appSettings.overrideStyle == true) //changeable by screen { tcOverride1.PlcVarFeedOverride = MainApp.appSettings.plcVarFeedOverride; } tcOverride1.PlcVarSpindleOverride = MainApp.appSettings.plcVarSpindleOverride; tcOverride1.OverrideStyle = (MainApp.appSettings.overrideStyle == true) ? 2 : 1; if (tcOverride1.OverrideStyle == 1 && tcOverride1.PlcVarSpindleOverride.Length != 0) { SetPLCVar(tcOverride1.PlcVarSpindleOverride, 100); tcOverride1.SpindleOverrideValue = 100; } // Status from the NCI channel oldOpState.Mode = new Int16[8]; oldOpState.State = new Int16[8]; if (svrPortNrNc == 501) { tcPlcConnect1.AdsPlcServer = adsPlcServer; tcPlcConnect2.AdsPlcServer = adsPlcServer; tcPlcConnect1.PlcVariableName = ".PLCNciChannelState.Mode"; tcPlcConnect2.PlcVariableName = ".PLCNciChannelState.State"; } }
private void tcRecipe1_afterRead() { //button1.Top = tcRecipe1.Top + tcRecipe1.Height; //button1.Left = tcRecipe1.Left; MainApp.GetDoc().tcFKey1.FKeyBackColor(10, oldButtonColor); }
private void btAdd_Click(object sender, EventArgs e) { int selectedChannel = MainApp.GetDoc().AppHeader.ChannelNr; if (adsPlcServer == null) { return; } int maxChannelAxes = adsNcServer.NcClient.Channel[selectedChannel].AxisMax; string[] axisName; int[] axisNr; string valueOutputFormat = "0.000"; axisName = new string[maxChannelAxes]; axisNr = new int[maxChannelAxes]; int i; int axis = 0; int maxAxes = adsNcServer.NcClient.InterfaceData.NumberOfAxis; for (int j = 1; j <= maxAxes; j++) { i = j; // for the NCI if (adsNcServer.ClientPortNr == 501) { i = adsNcServer.NcClient.Channel[selectedChannel].McAxes[j]; } if (adsNcServer.NcClient.Axis[i].ChannelNr == selectedChannel && adsNcServer.NcClient.Axis[i].AxisName != null) // this can be a gantry axis, don't show { axisNr[axis] = i; axisName[axis++] = adsNcServer.NcClient.Axis[i].AxisName; } } if (axis != 0) { // generate the default header if (tbTeachIn.TextLength < 3) { tbTeachIn.Text = "(Teach Program)\r\n"; tbTeachIn.Text += "(Created: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToString("T") + ")\r\n"; tbTeachIn.Text += "G90 G01 F1000 G17\r\n"; } // build string tmp = ""; string tmpAxisName = ""; for (i = 0; i < maxChannelAxes; i++) { tmpAxisName = axisName[i]; if (tmpAxisName != null) { char lastChar = tmpAxisName[tmpAxisName.Length - 1]; if ('0' <= lastChar && lastChar <= '9') { tmpAxisName += "="; } tmp = tmp + tmpAxisName + adsNcServer.NcClient.Axis[axisNr[i]].McActivePosition.ToString(valueOutputFormat) + " "; } } tbTeachIn.Text += tmp + "\r\n"; } }
public override void FKeyUpEvent(int nIdx) { switch (nIdx) { case 1: break; case 4: tcRecipe1.InsertRow(); MainApp.GetDoc().tcFKey1.FKeyBackColor(10, Color.DarkGray); hasChanged = true; break; case 5: tcRecipe1.DeleteRow(); MainApp.GetDoc().tcFKey1.FKeyBackColor(10, Color.DarkGray); hasChanged = true; break; case 7: // Recipe löschen if (textBoxAuftrag.Text != "") { if (askDeleteRecipe(textBoxAuftrag.Text)) { System.IO.File.Delete(rootdir + "\\" + textBoxAuftrag.Text + ending); if (treeView2.SelectedNode != null) { treeView2.Nodes.Remove(treeView2.SelectedNode); } // ein anderes Element selektieren if (treeView2.Nodes.Count != 0) { treeView2.SelectedNode = treeView2.Nodes[0]; } else { textBoxAuftrag.Text = ""; recipeFilename = ""; } } } break; case 8: InputBox box = new InputBox(GetText("New", "Neu anlegen"), GetText("FileName", "Dateiname:")); box.ShowDialog(); if (box.DialogResult == DialogResult.OK && !box.GetInput().Equals("")) { string fileName = box.GetInput(); recipeFilename = rootdir + "\\" + fileName + ending; tcRecipe1.NewFile(recipeFilename); tcRecipe1.WriteData(); treeView2.Nodes.Add(fileName, fileName); textBoxAuftrag.Text = fileName; } break; case 9: tcRecipe1.ReadData(); break; case 10: tcRecipe1.WriteData(); MainApp.GetDoc().tcFKey1.FKeyBackColor(10, oldButtonColor); hasChanged = false; break; case 11: try { // Get recipe data and write to the Plc System.IO.MemoryStream memStream; tcRecipe1.WriteDataToMemory(out memStream); TwinCAT.Ads.AdsStream adsStream = new TwinCAT.Ads.AdsStream((int)memStream.Capacity); adsStream.Write(memStream.GetBuffer(), 0, (int)memStream.Length); adsServer.PlcClient.Write(".RecipeData", adsStream); memStream = null; } catch (Exception ex) { string tmp = this.Name + " Error writing recipe data to the PLC!"; MainApp.log.Error(tmp, ex); MessageBox.Show(tmp); } break; case 12: timerListbox.Enabled = false; break; } }
void tcRecipe1_afterChange() { MainApp.GetDoc().tcFKey1.FKeyBackColor(10, Color.DarkGray); hasChanged = true; }
/// <summary> /// Displays the user manager dialog. /// </summary> public void UserManagerDialog() { MainApp.GetDoc().tcUserAdmin1.UserManagerDialog(); }
/// <summary> /// Displays the user administration dialog. /// </summary> /// <param name="bHideBackground">if set to <c>true</c> [b hide background].</param> /// <param name="bAutoLogOn">if set to <c>true</c> [b auto log on].</param> /// <param name="bLockComputer">if set to <c>true</c> [b lock computer].</param> public void UserAdminDialog(bool bHideBackground, bool bAutoLogOn, bool bLockComputer) { Beckhoff.App.TcFKey fKey = MainApp.GetDoc().tcFKey1; MainApp.GetDoc().tcUserAdmin1.LogOnDialog(bHideBackground, bAutoLogOn, bLockComputer); }
private void FormMain_Activated(object sender, System.EventArgs e) { Beckhoff.App.TcFKey fKey = MainApp.GetDoc().tcFKey1; fKey.FKeySelectedMode = false; }
string aktuelleSprachversion; // Aktuelle Sprache in der der aktuellen übersetzten Version public FormLanguage(Form form) { parentForm = form; InitializeComponent(); tclm = MainApp.GetDoc().GetTCLanguageManager(); }
public override void FKeyDownEvent(int nIdx) { int selectedChannel = MainApp.GetDoc().AppHeader.ChannelNr; string plcString = ".PLCMachineMode[" + selectedChannel.ToString() + "]"; if (tcFKeyOpMode.Visible == true) { OpModeWindow.Close(0); } try { switch (nIdx) { case 1: if (MainApp.appSettings.manualModeAds == 1) { if (adsNcServer != null && adsNcServer.NcIsRunning) { adsNcServer.NcClient.NcManual.MoveAxisNegative(SpecialFunc.ManualModeRapidFeed); } } else { SetPLCVar(".PlcManualModeLeftKey", true); } break; case 2: if (MainApp.appSettings.manualModeAds == 1) { if (adsNcServer.NcClient.Channel[selectedChannel].CmdOpMode == (int)OperationMode.Manual) { SpecialFunc.ManualModeRapidFeed = !SpecialFunc.ManualModeRapidFeed; } } else { SpecialFunc.ManualModeRapidFeed = !SpecialFunc.ManualModeRapidFeed; SetPLCVar(".PlcManualModeRapidFeedKey", SpecialFunc.ManualModeRapidFeed); } if (SpecialFunc.ManualModeRapidFeed) { MainApp.GetDoc().tcFKey1.FKeyBackColor(2, Color.Orange); } else { MainApp.GetDoc().tcFKey1.FKeyBackColor(2, Color.Yellow); } break; case 3: if (MainApp.appSettings.manualModeAds == 1) { if (adsNcServer != null && adsNcServer.NcIsRunning) { adsNcServer.NcClient.NcManual.MoveAxisPositive(SpecialFunc.ManualModeRapidFeed); } } else { SetPLCVar(".PlcManualModeRightKey", true); } break; case 4: if (tcFKeyOpMode.Visible == false) { OpModeWindow.Open(this.Height, tcFKeyOpMode); } break; case 5: MainApp.appSettings.mdiCommand[selectedChannel] = opModeMDI1.MdiText; SetPLCVar(plcString + ".MDIString", opModeMDI1.MdiText); SetPLCVar(plcString + ".ProgramName", opModeAuto1.selectFile1.Arguments); SetPLCVar(plcString + ".Start", true); break; case 6: SetPLCVar(plcString + ".Stop", true); break; case 7: SetPLCVar(plcString + ".Reset", true); SetPLCVar(".PLCReset", true); // Refresh the view by setting the actual channel number or the program name again opModeAuto1.tcNcProgramSection1.CncProgramName = opModeAuto1.selectFile1.Arguments; break; case 12: ManualModeSelected(false); break; } } catch (Exception ex) { MainApp.log.Error("FormCnc FKeyDownEvent()", ex); } }
private void Start_BlockSearch() { try { if ((rbStartBreakPoint.Checked && tbBreakPoint.Text != "") || (rbBlockCount.Checked && tbBlockCount.Text != "") || (rbStartBlockNr.Checked && tbBlockNr.Text != "")) { if (adsServer != null && adsServer.PlcIsRunning) { int selectedChannel = MainApp.GetDoc().AppHeader.ChannelNr; string plcVar = ".PLCMachineMode[" + selectedChannel.ToString() + "].BlockSearch"; // Automatische Anfahrt an Unterbrechungsstelle adsPlc.WriteSymbol(plcVar + ".bAutoReturn", "TRUE"); // Zurueckgelegter Weg if (tbDistance.Text != "") { adsPlc.WriteSymbol(plcVar + ".fDistance", tbDistance.Text); } else { adsPlc.WriteSymbol(plcVar + ".fDistance", "0"); } // Typ festlegen if (rbStartBreakPoint.Checked) // Suchtyp Unterbrechungsstelle { adsPlc.WriteSymbol(plcVar + ".nBlockCount", tbBreakPoint.Text); adsPlc.WriteSymbol(plcVar + ".nType", (short)BlockSearchMode.START_INDIVID_MARK); } if (rbStartBlockNr.Checked) // Suchtyp Satznummer { adsPlc.WriteSymbol(plcVar + ".nType", (short)BlockSearchMode.START_BLOCK_NR); adsPlc.WriteSymbol(plcVar + ".nBlockNumber", tbBlockNr.Text); } if (rbBlockCount.Checked) // Suchtyp Satzzähler { adsPlc.WriteSymbol(plcVar + ".nType", (short)BlockSearchMode.START_BLOCK_COUNT); adsPlc.WriteSymbol(plcVar + ".nBlockCount", tbBlockCount.Text); } // Suchlauf starten adsPlc.WriteSymbol(plcVar + ".bStartWrite", "TRUE"); // Set Flag Satzsuchlauf aktiv adsPlc.WriteSymbol(plcVar + ".Active", "TRUE"); TimerOnTick(null, null); } } else { string caption = tclm.GetString("BlockSearch.MessageHeader", "Block Search"); string msg = tclm.GetString("BlockSearch.MessageString", "Wrong mode or parameter missing"); MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); } } catch (Exception ex) { MainApp.log.Error("Error in Start_BlockSearch()", ex); } }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { const int WM_KEYDOWN = 0x100; const int WM_KEYUP = 0x101; const int WM_SYSKEYDOWN = 0x104; // suppress Ctrl-F4, Ctrl-F6, Alt-F4, Alt-F6 if ((keyData & Keys.Modifiers) == Keys.Control || (keyData & Keys.Modifiers) == Keys.Alt) { if ((keyData & (~Keys.Modifiers)) == Keys.F4 || (keyData & (~Keys.Modifiers)) == Keys.F6 || (keyData & (~Keys.Modifiers)) == Keys.Tab) { return(true); // do nothing } /* * if ((keyData & Keys.Modifiers) == Keys.Alt * && (keyData & (~Keys.Modifiers)) == Keys.F4) * { * return true; // do nothing * } * * if ((keyData & (~Keys.Modifiers)) == Keys.F4 || (keyData & (~Keys.Modifiers)) == Keys.F6) ||{ || if (msg.Msg == WM_KEYDOWN) || { || KeyEventArgs kea = new KeyEventArgs(keyData); || OnKeyDown(kea); || return true; || } || || if (msg.Msg == WM_KEYUP) || { || KeyEventArgs kea = new KeyEventArgs(keyData); || OnKeyUp(kea); || return true; || } ||} */ } if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_SYSKEYDOWN) { if (Keys.F1 <= (keyData & (~Keys.Modifiers)) && (keyData & (~Keys.Modifiers)) <= Keys.F12) { if (fKeyIsPressed == true) { return(true); } fKeyIsPressed = true; KeyEventArgs kea = new KeyEventArgs(keyData); oldKea = new KeyEventArgs(keyData); tcFKey1.FKeyDown(kea); return(true); } } //control keys if ((msg.Msg == WM_KEYDOWN || msg.Msg == WM_SYSKEYDOWN) && (keyData & Keys.Modifiers) == Keys.Control) { if ((keyData & (~Keys.Modifiers)) == Keys.Q && MainApp.GetDoc().tcUserAdmin1.CurrentUserLevel == Beckhoff.App.Security.TcUserLevel.Administrator) { if (symbolBrowser == null || symbolBrowser.IsDisposed) { symbolBrowser = new FormSymbolBrowser(); } symbolBrowser.AdsPlcServer = adsPlcServer; symbolBrowser.ShowDialog(); } if ((keyData & (~Keys.Modifiers)) == Keys.A && MainApp.GetDoc().tcUserAdmin1.CurrentUserLevel == Beckhoff.App.Security.TcUserLevel.Administrator) { if (menu != null) { menu.MenuManager(); } } if ((keyData & (~Keys.Modifiers)) == Keys.L) { MainApp.GetDoc().tcUserAdmin1.LogOnDialog(true, false, false); } } return(base.ProcessCmdKey(ref msg, keyData)); }