How to use tango within Qtcreator - c++

I have just started using Qt creator. I have created a simple form in QT4 designer and I used python for it. It is a simple form with two fields and a button. These two fields populate values from the device that I have defined in my jive.I am using the following statement in python to read the values from the device:
taurus.Attribute('device_name/instance_name/attribute_name').getDisplayValue()
This statement fetches the value of the attribute and I am appending this value to the text fields I have on the form.I have an "import taurus" statement in my python code.I am trying to do the similar thing in C++ but I am not sure on how we can read the values from the device defined in jive. So could you let me know how this can be achieved.

This question is really framework-specific. There isn't many Tango users on StackOverflow. Have a look at the QTango documentation on QTWatcher and QTWriter.
Here is a basic example where the attribute value from your device is linked to a ProgressBar:
QProgressBar *pbar = new QProgressBar(this);
QTWatcher *pbarWatcher = new QTWatcher(this);
pbarWatcher­->attach(pbar, SLOT(setValue(int)));
// configure maximum and minimum values when available
pbarWatcher­->setAutoConfSlot(QTWatcher::Min, SLOT(setMinimum(int)));
pbarWatcher-­>setAutoConfSlot(QTWatcher::Max, SLOT(setMaximum(int)));
pbarWatcher­->setSource("$1/short_scalar_ro");

Related

How can I create a custom module to display a calculated value on an already existing page/view?

Trying get started with custom module development on Drupal 8. Don't have previous Drupal dev background. Been reading and watching some materials in the past 2 or so weeks.
I decided to dare doing a little more "complex" other than "Hello World", but I got stuck on how would I actually go about this.
This is what I have so far:
I created a content type for "people". It's very simple, all it has is the person's name and birthdate (date only), so you can use the form to input a few people.
I created a view that displays the list of people, their names and their birthdate. Of course everything so far is using the core admin thing.
Now, I wanted to create a custom module that calculates the person's age (based on the date stored in the DB). It takes today's date, subtracts the person's birthdate, and calculates their age.
Then, with some magic, it returns the age to the render/page output and now this calculated value (the age) will be displayed on the view as well along with the person's name and birthdate.
I assume I would need to "hook into" a place somewhere, where the list of people is returned from the database. Then I loop through the data, get the birthdate, calculate the age, stick the result (age) back into the data, and then the page/view will display this - somehow.
Of course I am already stuck on how would I go about doing this? Where would I need to hook into? With what API? And then of course, I created a view already, but the view doesn't have the "age" field - since that is calculated on the fly. So where and how would I display it?
So many questions...
If anyone would know some tutorial that is similar to this, I'd appreciate it. It's kinda tough getting started with the "custom" side of Drupal.
Thanks for some tips!
without custom programming
You can actually do this without custom coding. For this you can I would use either of the following modules field_token_value or computed_field.
They both create a field without giving the user a textbox to input any value.
The value of such fields are calculated from predefined rules/custom coding/tokens defined per field.
from your custom theme
The easiest way is to do this on the theming layer and not store this value in the database. You have to use hook_preprocess_node in your THEMENAME.theme
function THEMENAME_preprocess_node(&$variables){
//install debug and kint to be able to use
//kint($variables);
$node = $variables["node"];
if($node->getType() == "CONTENTTYPE" && $node->hasField('field_date')){
//get date value something like "2018-09-07T21:35:30"
$date = $node->field_date->value;
//your logic and age calculations
// ...
$age = 35;
//set variable to use in node.html.twig based templates
$variables["person_age"] = $age;
}
}
In order to get more information on what is available install debug module and enable kint (which is part of debug) to be able to see variables using kint function
Than copy node.html.twig from your custom theme (or parent theme or classy core theme) to your THEMENAME/templates folder and rename it node--CONTENTTYPE.html.twig.
In there you can include the variable you just created in proprocess.
person age: {{ person_age }}
Make sure you clear the cache for all those changes to be seen by Drupal.
FOR MORE INFO
To find out what twig templates to override see here
More on twig and getting available variables
Getting more info on which twig template is used can also be obtained by enabling debug mode on previous link.
I would suggest you pick up a book on drupal development to understand all those concepts in a more concrete way.

Does Qt5 accept Numpy float64?

I'm making a QTableView based on a QStandardItemModel. I add data in the following fashion:
def addTableXYData(self,row):
label = 'Point '+str(row)
data = [label, self.x[row-1], self.y[row-1]]
for index, item in enumerate(data):
self.tableModel.setData(self.tableModel.index(row-1,index), item)
self.tableModel.layoutChanged.emit()
The strings for the label show up fine in the table, however it doesn't show the numbers. The numbers come from clicking points on a Matplotlib Qt Canvas, and are naturally numpy.float64 dtypes.
Is Qt5 capable of handling numpy.float64 datatypes? Or must I change it in to something else? I assume it may have something to do with PyQt5 using bindings to the C++ language, and maybe that can't handle it?
I've tried reading the docs on QVariant but it doesn't seem to tell me that I can't use floats.
Edit Instead of down-voting me without saying anything how about laying some wisdom on me and helping me out?
It turns out that PyQt5 does not possess the capability of sending numpy datatype classes to Qt5. It does native python classes like int(), float() etc. but not numpy.int32() etc. I assumed that would have been built-in functionality but, there ya go. The more you know.

Odoo v7 to v8 translation

I am converting OpenERP code from version 7 to version 8 and I have come across a weird structure. In version 7 we can use fields, function and one of the attributes is store. The store function allows current field to be updated when fields of other objects are changed.
In the new API, the store function only accepts 'True' or 'False'. I was wondering if I have inherit other models and modify their fields so they perform a value update of model in question using "onchange"
Nope, in Odoo 8 store function is working fine. you can search add-ons and find some interesting examples, Understand from it.
Some example I found in online
[http://www.odoo.yenthevg.com/saving-and-resizing-images-in-odoo-8/]
go through it.
In v8 their is no fields.function field and with that we also do not need store with fields pararms, but you can achieve same thing very easily by using [#depends][1] decorator , which does same thing as store with field does.
```
#openerp.api.depends(*args)
Return a decorator that specifies the field dependencies of a "compute" method (for new-style function fields).
```
so you can say that you field to be calculated on change of some field change.

Getting error while reading salesforce custom field type Rich Textarea

I am using salesforce.cfc (downloded from Riaforge) to integrate coldfusion with salesforce.
<cfset latestProductList = salesforce.queryObject("SELECT Id, Name, Description__c, Price__c, ProductImage__c FROM Product__c") />
I have created one custom object named "Product__c". This object have one custom field "ProductImage__c" type "Rich TextArea". When i an trying to get product without this custom field it is run, but when i am trying to get product with this field i am getting below error:
"INVALID_FIELD: Name, Description__c, Price__c, ProductImage__c FROM Product__c ^ ERROR at Row:1:Column:44 No such column 'ProductImage__c' on entity 'Product__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. "
But i have this field. attached screen image of salesforce below.
Thanks,
Arun
A quick look at Salesforce CFC shows that it hasn't been updated in a while. The file SalesForce.cfc is pointing at:
https://www.salesforce.com/services/Soap/u/11.1
That's version 11.1 of the API, which is quite old and is long before rich text fields came into existence.
You might be able to fix this issue by simply updating the reference in SalesForce.cfc to the latest version of the API by changing
https://www.salesforce.com/services/Soap/u/11.1
to
https://www.salesforce.com/services/Soap/u/28.0
in that file, although there's a pretty good likelihood that that will break something else, since version 28.0 will have lots of new stuff that SalesForce.cfc is not coded to handle.
In any case, your problem is in fact the API version that you're using. In cases like this, when a field type did not exist as of a certain API version, then that field is invisible for that version. In your case, your rich text field is invisible for your API version, 11.1.

How do you make a django field reference to a python class?

I am working on a project to expand a testing suite that my company uses. One of this things that was asked of me was to link the website to our Github source for code so that the dev team could continue tracking the issues there instead of trying to look in two places. I was able to do this but the problem is that every time the a bug is reported an issue is opened.
I want to add a field to my Django model that tracks an Issue object (from the github3.py wrapper) that is sent to Github. I want to use this to check if an Issue has already been created in Github by that instance of the BugReport and if it has been created, edit the Issue instead of creating another issue in Github that is a duplicate. Does Django have a something that can handle this sort of reference?
I am using Django 1.3.1 and Python 2.7.1
EDIT
I was able to figure my specific problem out using esauro's suggestions. However, as mkoistinen said, If this problem came up in a program where the work-around was not as easy as this one was, should an object reference be created like I had originally asked about or is that bad practice? and if it is okay to make an object reference like that, how would you do it with the Django models?
I'm the creator of github3.py.
If you want to get the issue itself via a number, there are a couple different ways to do this. I'm not sure how you're interacting with the API but you can do:
import github3
i = githbu3.issue('repo_owner', 'repo_name', issue_number)
or
import github3
r = github3.repository('repo_owner', 'repo_name')
i = r.issue(issue_number)
or
import github3
g = github3.login(client_key='client_key', client_secret='client_secret')
i = g.issue('repo_owner', 'repo_name', issue_number)
# or
r = g.repository('repo_owner', 'repo_name')
i = r.issue(issue_number)
otherwise if you're looking for something that's in an issue without knowing the number:
import github3
r = github3.repository('repo_owner', 'repo_name')
for i in r.iter_issues():
if 'text to search for' in i.body_text:
i.edit('...')