FleetApi - How to use legal rest times? - rest

I'd like to know the position in which the driver would need to rest with given waypoints.
I am calling GET https://fleet.ls.hereapi.com/2/calculateroute.json with the following params:
{
mode: "fastest;car;traffic:enabled",
waypoint0: "19.286769, -99.652773",
waypoint1: "19.419185, -99.17755430000001",
waypoint2: "19.41530,-99.17844",
waypoint3: "31.29778, -110.93690",
restTimes: "MEX",
maxSpeed: 110,
departure: "2021-07-20T15:00:00.000Z"
}
This returns warnings with the info of rest times like this:
{
"message": "Taking the short driver rest time after 18036 sec for 1800 sec at routeLinkSeqNum 1485",
"code": 14,
"routeLinkSeqNum": 1485
}
I would like to know how to use/read this info. I don't know what routeLinkSeqNum is and how to utilize it.

Governments impose rules on how long a truck driver can drive before he needs to rest. Routing can consider these regulations w.r.t. short rests during a day and long (overnight) rests.
For example, in EU countries drivers have to rest after 4.5 hours of driving for at least 45 minutes, and must not exceed a total of 9 working hours per day before they have to rest for 11 hours.
Activate this feature in the router using the "&restTimes=local", in this case, it is the "MEX" in the request parameter. Routing will then consider each country's local regulations.
In the same parameter, you can specify whether the driver starts the route freshly or how long he is already driving / on duty since his last short or long rest period
routeLinkSeqNum is an index of the link array within a Leg. If you check the response, there will be response>route>[0]>leg[0]>[2]>link[1485].
So one route can have n-legs, 1 leg can have m-links
This will help you to plot the rest times.
Here is an example shown in the tool:
https://tcs.ext.here.com/examples/v3/fleet_telematics_api

Related

What is the correct way to calculate number of DNS queries/second using Get-DnsServerStatistics?

I am trying to figure out how to get the number of DNS queries/second for each domain controller using PowerShell Get-DnsServerStatistics. I copied some of the relevant outputs below.
I try to figure out what is the time period of getting 11793847 "TotalQueries" ?
Under section "TimeStatistics," does the field "TimeElapsedSinceLastClearStatisticsBetweenRestart" with value 00:00:28 means 28 seconds? There is another field "TimeElapsedSinceServerStart" has value 34.01:35:21 and I don't understand what it means? maybe 34 days 1 hour 35 min 21 second?
But if there are 28 seconds with total 11793847 DNS queries. i.e. 421208 queries/second is seems not true in our environment. Could you please help me out?
TimeStatistics:
==============
**TimeElapsedSinceLastClearedStatisticsBetweenRestart 00:00:28**
LastClearTime 9/7/2021 9:33:20 PM
ServerStartTime 9/7/2021 9:33:20 PM
TimeElapsedSinceLastClearedStatistics 34.01:35:21
TimeElapsedSinceServerStartBetweenRestart 00:00:28
**TimeElapsedSinceServerStart 34.01:35:21**
Query2Statistics:
================
TypeAll 1917
TKeyNego 0
TypeOther 897431
**TotalQueries 11793847**
Your assumptions about the time formats are correct. The *BetweenRestart times are the offline times of your DNS service. The time you are looking for is
TimeElapsedSinceLastClearedStatistics - TimeElapsedSinceLastClearedStatisticsBetweenRestart
This is the timespan in which your DNS service was actually answering queries (34.01:34:53). I recommend to parse the timespans into TimeSpan objects using [System.TimeSpan]::Parse("34.01:35:21"), for example. Then you can easily subtract the timespans like shown above.
The resulting timespan object offers you the TotalSeconds member attribute, which you can use for your ratio calculation (your ratio is about 4 queries/s).

QuickfixJ - I am getting sec definition details in logs but message.getGroup method fails when I try to retrieve field information

I am getting 35=d message from ICE in my logs with all the details while requesting it via java application which is using quickfixj.
In onMessage implementation I am trying to get group data and values of individual field but my code fails at getGroup() and gives the error that field not found.
quickfix.fix44.SecurityDefinition.NoUnderlyings group = new quickfix.fix44.SecurityDefinition.NoUnderlyings();
message.getGroup(count, group);
This getGroup method internally calls getGroups function of quickfixJ which is failing becasuse at below line in -
this.getGroups(group.getFieldTag()); //group.getFieldTag() is 711 or NoUnderlyings
Is there anything that I am missing here? I have tried different ways to get the fields but no luck, help would be much appreciated.
Just an observation - In fromapp /on message method, I am not seeing the full message when I do message.toString(); . I Only see the first part, Second part which has actual security(many groups) is not being displayed. Not sure if there is any other way(other than toString()) to see full message in methods.
Message that I am getting in fromApp/OnMessage on message.toString();
<20190828-12:14:47, FIX.4.4:XXXX/1/0->ICE, incoming> (8=FIX.4.4 9=XXXXX 35=d 49=ICE 34=5 52=20190828-12:14:47.695 56=XXXX 57=1 322=10342 323=4 320=1566994457340_0 393=91 82=1 67=1 9064=0 711=91
Message that I am getting in logs :
<20190828-12:14:47, FIX.4.4:XXXX/1/0->ICE, incoming> (8=FIX.4.4 9=XXXXX 35=d 49=ICE 34=5 52=20190828-12:14:47.695 56=XXXX 57=1 322=10342 323=4 320=1566994457340_0 393=91 82=1 67=1 9064=0 711=91
311=5094981 309=UPL FQF0021.H0021 305=8 463=FXXXXX 307=UK Peak Electricity Futures (Gregorian) - UK Grid - Q1 21 308=IFEU 542=20201230 436=1.0 9013=0.01 9014=1.0 9040=0.01 9041=1.0 9017=1.0 9022=768 9024=1.0 9025=Y 916=20210101 917=20210331 9201=1900 9200=15 9202=Q1 21 9300=8148 9301=IPE UK Grid, UK (Peak) 9302=UK Grid 9303=UPL 998=MWh 9100=GBP 9101=GBP / MWh 9085=hourly 9083=2 9084=0 9061=4639 9062=UK Peak Electricity Futures (Gregorian) 9063=UK Power Peakload Futures (Gregorian) 9032=0.01 9215=1 9216=0 763=800
311=5094980 309=UPL FMH0021! 305=8 463=FXXXXX 307=UK Peak Electricity Futures (Gregorian) - UK Grid - Mar21 308=IFEU 542=20210225 436=1.0 9013=0.01 9014=1.0 9040=0.01 9041=1.0 9017=1.0 9022=276 9024=1.0 9025=Y 916=20210301 917=20210331 9201=1875 9200=12 9202=Mar21 9300=8148 9301=IPE UK Grid, UK (Peak) 9302=UK Grid 9303=UPL 998=MWh 9100=GBP 9101=GBP / MWh 9085=hourly 9083=2 9084=0 9061=4639 9062=UK Peak Electricity Futures (Gregorian) 9063=UK Power Peakload Futures (Gregorian) 9032=0.01 9215=1 9216=0 457=1 458=GB00H1RK4P63 459=U4 763=0
Which version of QuickFIX/J are you using? In some older versions the message got truncated when there were unknown fields.
That brings me to the question whether your used data dictionary is really containing all the fields that ICE is sending. Do you have all that 9000+ tags in your dictionary? Please double-check that.

extract Date and Time from two 16-bit modbus registers

I'm using an ElNet energy&power meter that communicates with my processor via Modbus RTU protocol.
There are two 16-bit ElNet registers that contain information about the Date and Time (separately) in a Win Format (registers 85-86, page 6 of this document). I'm able to read these two registers. However, I'm unable to extract information about the Date and Time.
For example, Date register contains decimal value of 17841 for today's date (31/07/2015). Is there any person willing to explain me how to convert 17841 into 31/07/2015?
I have the same problem with the time. My time register contains a decimal value of 55296. Can you help me extract the time from this number?
This thread addresses the same problem:
HEX/Decimal to date and time from modbus
However, I'm not sure I understand the extraction algorithm applied there. My point of operation is processor with the code written in C or C++.
Thank you very much for your time and effort to help me.
Sincerely,
Bojan.
The MS-DOS date/time format is described here: https://archive.is/2bVlz (was http://proger.i-forge.net/MS-DOS_date_and_time_format/OFz but is gone)
It makes sense for the 17256 value mentioned in the other question, as it translates to 2013-11-08. See here how to do it:
Register bit description: 0bYYYYYYYMMMMDDDDD
Registervalue: 17256 0b0100001101101000
Yearmask: 0b1111111000000000
Yearpart: 0b0100001000000000
Yearpart rightshifted 9 steps: 0b0000000000100001 = 33 years after 1980
Monthmask: 0b0000000111100000
Monthpart: 0b0000000101100000
Monthpart rightshifted 5 steps: 0b0000000000001011 = 11
Daymask: 0b0000000000011111
Daypart: 0b0000000000001000 = 8
Unfortunately your register value 17841 does not make sense, as it translates to 2014-13-17 (That is month 13).
Are you sure that:
you read the correct register? (change the time setting in the instrument, and see what happens to the register value)
you do not mix up the two bytes in the register?
the time setting is correct?

Simpy 3.0.4, setting resource priority

I am having trouble with resource priority in simpy. Consider the following code:
import simpy
env = simpy.Environment()
res = simpy.PriorityResource(env, capacity = 1)
def go(id):
with res.request(priority = id) as req:
yield req
print id,res
env.process(go(3))
env.process(go(2))
env.process(go(4))
env.process(go(5))
env.process(go(1))
env.run()
Lower number means higher priority, so I should get 1,2,3,4,5. But instead i am getting 3,1,2,4,5. So the first output is wrong, after that its sorted!
Thanks in advance for your help.
This is correct. When "3" requests the resource, it is empty so it gets the
slot. The remaining processes have to queue and will get the resource in the
order 1, 2, 4, 5.
If you use the PreemptiveResource instead (like request(priority=id,
preempt=True)), 3 will still get the resource first but will be preempted by
2. 2 will then get preempted by 1. 2 and 3 would then have to request the
resource again to gain access to it.
Even I had the same problem where I was supposed to make a factory FIFO. At that time I assigned a reaction time to a part and made it to follow the previous part. That is only if the previous part had got into service of resource, I made the next part request. It solved the problem objectively but seemed like it slowed down the simulation little and also gave a rexn time to the part. It was basically a revamp of the factory process. But I would love to see a feature when the part doesn't have to request again.
Can it be done in the present version?

How can I get exchange rates after google retired iGoogle?

I used this link to fetch the pound to euro exchange rate on a daily (nightly) basis:
http://www.google.com/ig/calculator?hl=en&q=1pound=?euro
This returned an array which I then stripped and used the data I needed.
Since the first of November they retired iGoogle resulting in the URL to forward to: https://support.google.com/websearch/answer/2664197
Anyone knows an alternative URL that won't require me to rewrite the whole function? I'm sure google didn't stop providing this service entirely.
I started getting cronjob errors today on this very issue. So I fell back to a prior URL I was using before I switched to the faster/reliable iGoogle.
Url to programmatically hit (USD to EUR):
http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=EUR
Details about it:
http://www.webservicex.net/ws/WSDetails.aspx?CATID=2&WSID=10
It works for now, but its prone to be slow at times, and used to respond with an "Out of space" error randomly. Just be sure to code in a way to handle that, and maybe run the cron four times a day instead of once. I run ours every hour.
Example code to get the rate out of the return (there is probably a more elegant way):
$ci = curl_init($accessurl);
curl_setopt($ci, CURLOPT_HTTPGET, 1);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1);
$rawreturn = curl_exec($ci);
curl_close($ci);
$rate = trim(preg_replace("/.*<double[^>]*>([^<]*)<\/double[^>]*>.*/i","$1",$rawreturn));