I want to get the data from Excel and update the values of the data between certain dates in the osisoft system. But I don't know how to code AfTimeRange.
I get the error "value cannot be converted to OSIsoft.AF.Time.AFTime".
enter image description here
Good news: You've constructed your [AFTimeRange] correctly!
Notice that the error being thrown is not by the [AFTimeRange] constructor, but from something else.
The issue is that you are trying to set the 'Timestamp' attribute [OSIsoft.AF.Time.AFTime] to a value of type [OSIsoft.AF.Time.AFTimeRange], and so it's failing. A PI event has a single timestamp, not a time range.
I'm not familiar with Python, but it should work if you input the value as an AFTime object using its string constructor, assuming you're intending to use yesterday midnight as your timestamp:
val.timestamp = AFTime("y")
See the documentation on AFTime for more detail.
Related
I have successfully imported geodata (originally from a shapefile, converted to CSV) into my RavenDB. I am now trying to access the data with a naive, simplistic select (sanity check to see if everything's there) but I can't get any data member values back. Since I am a total RavenDB newbie and haven't created the data myself (programmatically), my approach was to define a class that has the same name as what I find in Raven Studio (minus the automatically-appended plural 's') under Raven-Entity-Name, and to declare each of the data members to be of type string.
The query runs through and retrieves the first 128 results, but all the data members are null. I used this:
List<AdministrativeArea> AdministrativeArea = session
.Query<AdministrativeArea>()
.ToList();
Looking at the entries in Raven Studio, I can see that some of the data member values of the documents are coloured blue (so are probably already type-cast to be integer) but that shouldn't be the cause of ALL the data members showing up as null...
No exceptions are being thrown, and the query list contains elements. What am I doing wrong here ?
Thanks for your help !
The problem was the instantiation of int data members. Even when declaring the int members to be nullable, the problem of empty strings came up and prevented correct instantiation of the objects.
I supose that when CSV imports are used, and in some of the cases the field/data member comes up "empty" (but as a string type), and in other cases, you DO have numbers, then you have to resort to declaring them all to be strings. The only other solution I could think of is to adapt the CSV import code, for which I am still too new to RavenDB to think about.
I have a problem and I don't quite know how to deal with it. It must be a common problem, but I didn't find a good answer yet.
I'm coding a MEAN stack app, using Mongoose, and the problem I have is with the dates format when changing the language in my app.
The scenario is: The user can insert some data that has a Date field, for example their birthday. That field is then sent to mongoose in a specific format (yyyy-MM-dd) and it gets stored correctly in a Date field in mongoose. When the user searches for the data stored, I have an $http get request that get back the data in JSON format. Right before the data is send from the server, I have this in the JSON:
{datetime: '2015-11-13T20:00:00.000Z'}
And send it from nodejs like this:
return res.status(201).send(obj);
And when the Angular gets it, depending on the language I'm using in that moment, it resolves to a Date or an Invalid date. If the language I'm using is English, the resulting JSON has a valid Date in that field. If I change it to Spanish for example, then it results into an Invalid date field.
The code in Angular is this:
$http.get(url).then(function (result) {
//here the result.data may have an Invalid Date field
deferred.resolve(result.data);
}, function (error) {
deferred.reject(error);
});
I set the language in my app with the help of angular-translate, and I use angular-i18n and momentjs also.
I've read on this and here https://docs.angularjs.org/api/ng/service/$http it say that
If JSON response is detected, deserialize it using a JSON parser.
I understand that the default parser detects the Spanish i18n and tries to parse the date as yyyy-dd-MM, and obviously gets an Invalid Date.
The question here is: How can I explicitly set all the dates parsed in Angular, to follow a specific format, like yyyy-MM-dd, regardless of the i18n used? I've seen this solution already, but doesn't work for me: http://aboutcode.net/2013/07/27/json-date-parsing-angularjs.html
Is there a better way to handle all this? Maybe store the dates in Mongo not as Date fields, but like Strings, using the JS getTime() function?
This last method means that I would have to change all the dates in my app. It's a lot more work, but the result will be more standard, right?
Thank you!
I have an item of type float, but sometimes a string is received in case of error instead of a number. How can I make a trigger regexp to fire in this case?
I have no idea now to check for "wrong data type".
Actually this is by design and what I'm trying to do is this: if the data gathering fails, I send an error message in order to see it on zabbix end.
I tried with nodata(0), but this doesn't seem to work.
In you case zabbix will not store the "wrong" value for the item. And if you don't care what the string is then you can just setup a trigger for "nodata" for the period of your interval. Look in the triggers manual and search for the "nodata".
Edit: scratch that, didn't read the whole question ....
Edit2: if you are certain that this is not working by design and not because your trigger interval misses the data interval, then you can try to catch the unsupported status. There is an open request for the functionality, but you can setup a side script similar to this. Or you can wrap the monitored item on the node into a UserParameter script that reads the value and prints -1 or something if it is not a number. Then proceed with a normal numeric trigger.
I wanted to check in here to see if anyone has any suggestions before submitting a bug report to Oracle.
I'm using MySQL for Excel in Excel 2013, and when trying to import a table that has a TIME type column, the import fails and I get the following error message:
An error occurred when trying to import the data.
Method's type signature is not Interop compatible.
I looked up information about Method's type signature is not Interop compatible. but found only things relating to C/C#.
I'm trying to insert data that is formatted as a relative time duration, e.g. 00:02:34 (2 minutes 34 seconds), but I cannot find a way to do this. MySQL for Excel won't import a TIME column, and when I define the column as VARCHAR, it does some calculation on each value when it's submitted to the database; 00:02:34 ends up as 0.00178240740740741 in the database.
Is there a different column type that I can use that will leave a string like 00:00:00 unformatted?
That's because excel can't handle the conversion of that data type so what is being reported... the .001782... is the time in days. So if you take 24*60*60* that number you get your 2:34...
When importing to Excel you can append a single quote ' to the beginning of the string value. This kept the formatting in the cell; but it may cause problems with the data later when you have to pull the ' off for processing.
This issue in MySQL for Excel was fixed [at least partially] since version 1.3.0, when you choose to a Create Excel Table on the Advanced Options menu of the Import Dialog. (If you leave that option unchecked the error still appears.)
A bug report with a similar description of the error message you describe has been raised to the MySQL team in charge of MySQL for Excel. If you wanna receive updates on this please feel free to suscribe to Email Updates in this link: http://bugs.mysql.com/bug.php?id=72504
I have a Spring / Hibernate project and I am trying to store a date into the database but it's not working. It must be something stupid but I have no idea what I am doing wrong.
Here is my code:
user.setFailedPasswordAnswerAttemptCount(0);
user.setLastLoginDate(new Date());
user.setIsOnline(true);
The other two variables (failedPasswordAnswerAttemptCount and isOnline) are getting written to the database without issue. I have also tried it with just passing a java.util.Date instead of a java.sql.Timestamp...same result. Here is how the property is defined on the user object:
private Date lastLoginDate;
#Temporal(TemporalType.TIMESTAMP)
#Column(name="last_login_date")
public Date getLastLoginDate() {
return this.lastLoginDate;
}
public void setLastLoginDate(Date lastLoginDate) {
this.lastLoginDate = lastLoginDate;
}
Here is the column definition:
`last_login_date` datetime DEFAULT NULL
Any help? I don't even know what else to look for as this should be working.
Some more detail about the error: No errors or strange messages in the hibernate log. The hibernate log is showing a parameterized query but it isn't telling me what it is actually writing. It looks like it's not updating the column at all. In other words, if there is already a date there it doesn't change, or if it is null it doesn't change.
Update: I have looked at the logs and it looks like hibernate does write the proper data, but then immediately writes the incorrect data again. I see the following entry in the log:
11:15:12.280 [http-bio-8080-exec-26] TRACE o.h.e.def.AbstractSaveEventListener - detached instance of: com.hi.model.User
11:15:12.280 [http-bio-8080-exec-26] TRACE o.h.e.def.DefaultMergeEventListener - merging detached instance
And right after that I see it putting the old value back in for the lastLoginDate.
Why are you using
Date date = new Date();
user.setLastLoginDate(new Timestamp(date.getTime()));
and not just this?
user.setLastLoginDate(new Date());
First - You may not want to use Date and Timestamp at the same time.(e.g. for collections, etc)
There are some classes in the Java platform libraries that do extend an instantiable
class and add a value component. For example, java.sql.Timestamp
extends java.util.Date and adds a nanoseconds field. The equals implementation
for Timestamp does violate symmetry and can cause erratic behavior if
Timestamp and Date objects are used in the same collection or are otherwise intermixed.
The Timestamp class has a disclaimer cautioning programmers against
mixing dates and timestamps. While you won’t get into trouble as long as you
keep them separate, there’s nothing to prevent you from mixing them, and the
resulting errors can be hard to debug. This behavior of the Timestamp class was a
mistake and should not be emulated. (Bloch, Effective Java, 2nd Ed.)
Second - I checked your examples, and it works fine for me on mysql-connector(5.1.21) / hibernate (4.0.1)
I prepared simple test project with arquillian integration test(You need to prepare jboss before running it):
https://github.com/rchukh/StackOverflowTests/tree/master/13803848
If you can provide some more information it might help - hibernate version, mysql version, mysql engine(MyISAM, InnoDB, etc.)
Otherwise it is possible that this is just a misconfiguration.
I found the problem. I am refactoring some code and it looks like I was doing this:
//get user object
User user = getUser();
//call a function which modifies user
functionModifiesUser();
//modify user
user.blah = blah;
entityManager.merge(user);
So the parent function had a stale copy of the user object when I tried to save it. Actually, removing the merge statement was enough to fix it. But I have refactored the code to put all this in one place.
Setting the column last_login_date as timestamp should work, at least works for me.