CAPL PutValuetoControl - panel

I am trying to display a message using PutvaluetoControl in Hex/Text Editor, but it is not working.
on diagResponse Active_Steering.Active_Steering_Feb2021.DID_B526_Read
{
Write("PUT value into display panel");
putValueToControl("NexteerDataWrite","DisplayStatus","DONE");
}
NexteerDataWrite is Panelname
DisplayStatus is Controlname
What is the mistake in my code?

putvaluetoControl works only with "CAPL Output View " it doesn't work with other tools of CAPL Panel designer.

Related

Setting time variable via textbox in Twincat 3 HMI

With variables such as integer, float or string I used Write To Symbol to write the variable to the PLC with the HMI textbox under .onTextChanged in the properties window (see images below).
But it won't work with the Time variable.
How can I make this work without changing the PLC code?
I've never worked with javascript before, but that is where I found the sollution.
I also used .onUserInteractionFinished instead of .onTextChanged like displayed in image underneath:
After that I wrote this javascript code:
(function (TcHmi) {
var CheckTextboxForNumber = function (Textbox) {
//get content from the textbox
var _text = Textbox.getText();
//convert to time variable in
if (!_text.startsWith('PT')) {
var _value = Number(_text);
Textbox.setText('PT' + _value.toFixed(3) + 'S');
return _value.toFixed(3);
}
};
TcHmi.Functions.registerFunction('CheckTextboxForNumber', CheckTextboxForNumber);
})(TcHmi);
I put the code in before the Write To Symbol, with an added rounding, because the rounding is done differently after the 3th decimal: when I tested it without rounding the decimals, starting with the 4th, the PLC would display other decimals then I input in the HMI textbox.
What I input in the 'actions and conditons' window can be seen in below image:
After that it worked as it was supposed to.
Try the object "Numeric input" on the TC Hmi to write variable in the PLC, with the event ".onUserInteractionFinished". it should work.
enter image description here

adding events to random buttons of the keyboard

Hello guys i really need your help . I want to make some program in javafx so i need to add listener to random generated button on the keyboard. For example :
i don't want to add some action if user type enter but i want to add action to some random button and nobody would know which is that button . so the user need to click every single button on the keyboard to find out which is that button.How would he knows that this is the correct button ? - > well the program will be executed , when he click on the wrong button -> nothing will happen.
Try something like this:
private void handleKeyPress(KeyEvent ke) {
String text = ke.getText();
KeyCode code = ke.getCode();
if ( ke.isControlDown() || ke.isMetaDown() ) {
//DO something for example
}
}

Outlook 2013 Addin: Change Ribbon Button Image on click of button using c#

I have created Ribbon button for Outlook 2013 using c#.
And i have also set image for the ribbon.
Now on click of Ribbon button i want to change Ribbon Image.
Is it possible to achieve this using c#.?
Not sure how exactly you want it to work, but this could do the trick.
bool callback {get;set}
public Bitmap GetImage(IRibbonControl control)
{
switch (control.Id)
{
case "FooButtonId":
{
if(callback== true){
callback = false;
return new Bitmap(Properties.Resources.someimage1);
}else
callback =true;
return new Bitmap(Properties.Resources.someimage2);
}
}
}
}
This question is 3 yo but helped me to go further and I want to share this with you.
First, I accomplished this in VB.net so my code will be in VB.net. There are some online tools to convert the code into C#.
Second, I used a Toggle button instead of a Simple button.
Third, I used OnOff as a project setting in order to save the state of the Toggle button.
Step 1: Ribbon.xml file, code to place the toggle button on the ribbon.
Assuming you already have set up the tab and group tags in the file.
<toggleButton id="onoffTBTN" label="ON/OFF" showImage="true" onAction="OnOffToggle" getImage="OnOffImage"/>
Step 2: Ribbon.vb file, code to change the OnOff setting based on the Toggle button status(pressed or not) and forces to invalidate the custom control
Public Sub OnOffToggle(ByVal control As Office.IRibbonControl, ByVal pressed As Boolean)
My.Settings.OnOff = pressed
My.Settings.Save()
myRibbon.InvalidateControl("onoffTBTN")
End Sub
Step 3: Ribbon.vb file, reads the OnOff setting and changes the image accordingly. Have in mind that your images must have been added to your project resources in order to use them at My.Resources.*. I used png files that support transparent pixels. This function is called in two occasions, first when the Outlook starts and second when the toggle button is pressed and specifically with the command myRibbon.InvalidateControl("onoffTBTN").
Public Function OnOffImage(ByVal control As Office.IRibbonControl) As Drawing.Bitmap
Dim onoff As Boolean = My.Settings.OnOff
Select Case control.Id
Case "onoffTBTN"
If onoff = True Then
Return New Drawing.Bitmap(My.Resources._on)
Else
Return New Drawing.Bitmap(My.Resources.off)
End If
End Select
End Function
The only weird behaviour is when the OnOff setting has been set to TRUE. The correct image is displayed but the Toggle button looks unpressed. You have to click twice in order to set the OnOff setting to False.

hiding crosstab columns in BIRT when format is excel

I want to hide two of the crosstab columns based on some condition. I have been able to achieve it by using
function onPrepareCell( cell, reportContext )
if(some condition){
if( cell.getCellID() == cell#){
cell.getStyle().setDisplay("none");
}
}
in the onPrepare event of cross tab. It works fine in PDF,HTML format but the columns are not getting hidden when the format is Excel. I need to get this done soon please help
I got the answer from BIRT exchange i am posting the answer here so that it may be helpful to others
In the onPrepare() event of crosstab you can write the code as given below
function onPrepareCrosstab( crosstab, reportContext )
{
if(some condition ){
reportContext.getDesignHandle().getElementByID(ElementId#).setStringProperty("width","0px");
}
}
here ElementId# is the Id# of the cell you want to hide. As you can see we can also use this to change the width of the cell dymanically.
Try your code in an OnCreateCell event.

AutoCAD VB.Net Color Picker

I am porting some AutoCAD VBA to VB.Net.
Several of the modules do a ThisDrawing.SendCommand("_color" & vbCR) to popup an AutoCAD color picker, then process the response by doing a ThisDrawing.GetVariable("CECOLOR") to get the selected color.
With .Net, the SendCommand does not execute until the program ends.
How can I get the AutoCAD color picker to execute inline in my code?
There is a ColorDialog class to do that. Here is some C# code:
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Windows;
var cd = new ColorDialog();
if (cd.ShowDialog() != DialogResult.OK) return;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("\nSelected color: " + cd.Color);

Resources