Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - authorleon

Pages: [1] 2
1
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 28, 2018, 04:22:18 PM »
Right. I have the code working for toggle now....

For anyone, it if like this:

 
Code: [Select]
public void hook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            if (e.Modifier == (Src.Hooks.ModifierKeys.Win | Src.Hooks.ModifierKeys.Alt) && e.Key == Keys.F12)
            {
               
                serialDF1forSLCMicroCom1.Write ("B3:0/0", "1");
            }
            else if (e.Modifier == (Src.Hooks.ModifierKeys.Win | Src.Hooks.ModifierKeys.Alt) && e.Key == Keys.F11)
            {
                serialDF1forSLCMicroCom1.Write("B3:0/0", "0");

            }
            // show the keys pressed in a label.

        }


I jsut need help with keep up and release...

Thank you all very much

2
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 28, 2018, 04:02:17 PM »
Hello,

Right, I have some progress now. I have global hotkeys working which is fantastic....

I just need a little bit of help tweaking the code please.

 
Code: [Select]
public void hook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            if (e.Modifier == (Src.Hooks.ModifierKeys.Win | Src.Hooks.ModifierKeys.Alt) && e.Key == Keys.F12)
            {
                Me.SerialDF1forSLCMicroCom1.Write("B3:0/0", "0")
                switch = False
            }
            else if (e.Modifier == (Src.Hooks.ModifierKeys.Win | Src.Hooks.ModifierKeys.Alt) && e.Key == Keys.F11)
            {
                MessageBox.Show("Combinacion F11");
            }
            // show the keys pressed in a label.

        }


Please note, I do not want a toggle function. I would like you that when the button is pressed ("B3:0/0", "1"). And when the button is released ("B3:0/0", "0"). In other words the action only continues when the button is pressed and held down. Once released the bit is put back to zero.

Thank you very much...


3
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 22, 2018, 06:12:37 AM »
Fantastic !!!!!!!!!!!!!!! THANK YOU VERY MUCH!!!!!!!!!!

I love to learn and you have saved a lot of time!!!!!!!

Thank you again... A beer for you.

4
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 21, 2018, 06:43:33 PM »
Thank you very much... However I have realized that the code is in C#.

Here is the program had in the old application which worked. Of course I understand now that I have to use a B reference.

   
Code: [Select]
Private Sub MainForm_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

        If (e.KeyCode And Not Keys.Modifiers) = Keys.T AndAlso e.Modifiers = Keys.Control Then
            DF1Com1.Write("O:1/0", "1")
        End If

    End Sub

    Private Sub MainForm_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp

        If (e.KeyCode And Not Keys.Modifiers) = Keys.T AndAlso e.Modifiers = Keys.Control Then
            DF1Com1.Write("O:1/0", "0")
        End If

    End Sub

Of course, I have now realized that the code is in C#.

Does anyone have the equivalent code in C# please. I have had to look online and consulted the Microsoft website but I tried that code and he did not work...

Much appreciated all.

Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AdvancedHMICS
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void basicButton1_Click(object sender, EventArgs e)
        {
         
        }
    }
}



5
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 21, 2018, 12:22:18 PM »
Thank you both very much, it is now working so I just want to confirm a few things.

With the new version: X399 you cannot use a button with a direct output. e.g. O:1/1 etc. You have to use B3:0/0   (Make a ladder B3:0/0 > O:1/1 )

The second part is that I utterly have a piece of code which allows for the board shortcuts:

Code: [Select]
If (e.KeyCode And Not Keys.Modifiers) = Keys.T AndAlso e.Modifiers = Keys.Control Then
            DF1Com1.Write("O:1/0", "0")  ' (O:9/0) (R)
        End If

Could I have a little bit of help modifying this code so it would activate B3:0/0.

Once this has been achieved.

I will then focus on making global keyboard shortcuts. Thank you gents very much.


6
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 21, 2018, 11:53:33 AM »
The correct driver should be SerialDF1forSLCMicroCom.

You should also know all your COM1 settings and include them in the driver properties:
- BaudRate, change from AUTO to exact baud rate for your PLC
- TargetNode, is usually 1 but use RSLinx / RSLogix to confirm
- Parity
- ChecksumType

As Archie suggested, you should have 1 rung with contact set to B3:0/0 and coil set to O:2/4.
Then change the PLCAddressClick to B3:0/0 and maybe select Toggle as OutputType.

Hello,

I have all the config working:



I am trying what you suggested now.


7
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 21, 2018, 11:47:09 AM »
Hello, I gave it a go.. Still the same...

Yes, of course. I have closed down RSlinx 100%.

Would TeamV be an option... as I really would love to get this sorted. ?

8
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 21, 2018, 11:28:38 AM »
I have nothing in the PLC.. I.e. no code.. just 1 empty ladder


9
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 21, 2018, 11:27:56 AM »
Nope..

I have an older application that does not include the C#


It works perfectly.

I have check that the com port is all good.

Thanks


10
Support Questions / Re: DF1Com1 in C# - Simple issue. I think
« on: April 21, 2018, 11:05:27 AM »
Hello,

Fantastic... Right, I have done that. Also, I have VS 2017.

I have created a button, I am using DF1Com1 (AKA SerialDF1For5Com1). I assume that is the correct one. I run the program. the form comes up with the button. However, when I press the button, my AB SLC 500 does nothing. The relay does not toggle at all.

I am very close, thank you very much.






11
Support Questions / DF1Com1 in C# - Simple issue. I think
« on: April 19, 2018, 02:39:30 PM »
Hello all,

I need to use C# because I need to use global hotkeys.

I am just setting up a basic program with one button, using an SLC 500.

Unfortunately I'm getting some errors and I don't know why.

I have had a look around but I don't know how to approach the problem.

Please have a look at the attached images.

Effectively I am just trying to get one button to work so it turns on output on the SLC 500.

I can get this working if I use .NET.  But fortunately I stated before I need to get it working in C#...

I hope I have explained it clearly. These have a look at the attached images

12
Support Questions / Re: Global hotkey
« on: March 10, 2018, 08:08:18 PM »
Hello,

Thank you very much for the information.

I have had a look at the links and I do have the global hotkeys. But I have a problem maybe somebody can help you with.

I am using the buttons in the application.

So when I press the button. It activates the appropriate output.
When I release the button, it deactivates that same output.

So physically pressing the buttons works perfectly.

I am using the buttons not as a toggle. When you press and hold the button the output stays on. When you release the button it turns off.

I cannot find any release function at all in VB.

Does anyone know of a special trick, hack or whatever to get this working.

I am willing to pay as well, if only I could have just a piece of code and then I can integrated.

I really appreciated and I really need to find a solution. Thank you very much

13
Support Questions / Re: Global hotkey
« on: March 08, 2018, 02:38:21 PM »
Is it possible to have a piece of code that emulates pressing the button.

I can get one working but you have to be focused on the form...

Can anyone really help me with this???

14
Support Questions / Global hotkey
« on: March 08, 2018, 01:15:37 PM »
Hello,

I have a very simple form which uses a few buttons to directly control the outputs on an SLC500.

I have a piece of code which allows you to have hotkeys but only when you are focused on the form.

Is there a simple way to have global hotkeys. i.e. CTRL + ALT + SHIFT + U (Mover motor up).

I have been trying for the last six months on and off but unfortunately no success.

15
Tips & Tricks / Re: Add keystroke (shortcut) to basic button
« on: May 30, 2017, 10:03:40 AM »
Go it working.

Please note the following:

https://www.codeproject.com/Questions/376421/Csharp-Keydown-or-keycode-not-working

he reason is that when a key is pressed it will go to the control which has focus on the form, as the KeyPreview property of Form is set to False by default. Let us say the cursor is in a TextBox. Now, if the F3 key is pressed it will not go to the Form's KeyDown event and instead it is captured by the TextBox and the KeyDown event of TextBox fires.

So, to enable the KeyDown event of Form even when the focus is on any other control, then the KeyPreview property of the Form has to be set to true as explained here
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview.aspx[^]
KeyPreview Gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.
and under remarks as
To handle keyboard events only at the form level and not allow controls to receive keyboard events, set the KeyPressEventArgs.Handled property in your form's KeyPress event handler to true.



Pages: [1] 2