I have used alarm manger to set an alarm and I put it for repeating but it is not working well - operating-system

Is there any other way to invoke alarm at exact time daily,I mean any way by which we can tell the OS that this alarm posses higher priority so at any cost invoke it at exact time.

Related

Restrict user to use only network provided time

I made an attendance app in Flutter in which I want to restrict employees to use only network provided time so that employees won't be able to temper the date and time.
Is there any option or solution to implement this in android and iOS as well?
Using this package datetime_settings we will get the settings of Automatic date & time of mobile so when automatic date & time is on mobile will give us an accurate network time otherwise we will show an error to turn on the automatic date & time in settings. That's how I used to restrict users to use only network-provided time.
I'll tell you what worked for me. Hope this can help you. I don't know if it's the most optimized way to do it, but it worked very well for me:
You need to create an internal clock for your app, and from this, use it instead of the DateTime.now() function. For this, you must take the server time when opening the app, and keep it updated with a timer that runs every 1 second.
Please note that the app goes to sleep (or closes) when the device is locked or the app is minimized for a certain amount of time (this depends on the operating system and battery saver settings), thereby stopping the internal clock, and consequently, it is delayed when the app is activated again. In my case, I got around this problem by using a foreground service that I designated to perform this task (I used flutter_foreground_task). Another advantage of using a foreground service, is that the user can close the app and the clock keeps running (and in my case, I also perform other simple tasks periodically).
If the user does not manipulate the system time, the difference should never reach 1 second.
Optionally, you could check when retrieving the server time, the difference with the device time, and if it is greater than a certain gap that you determine, warn the user, so that he can correct it if he prefers, so that he does not see a discrepancy with the time recorded and displayed by the application.
Regards.

OpenGL VSync / NSTimer issues on macOS

I'm trying to set up a simple OpenGL game on macOS, using an NSTimer to set up a run loop as explained here. The idea is to create a repeating timer with a very small (~1ms) time interval and rely on vsync to regulate the frame rate.
I'm setting my NSOpenGLContext swap interval to a value of 1, which should enable vsync. I was under the impression that this would cause NSOpenGLContext.flushbuffer to block, but this doesn't seem to be the case. My render code is firing off much more frequently than 60 times per second.
The document I linked has been marked as retired, but all the official documentation I've read suggests that it's possible to throttle an NSTimer loop to the display's refresh rate somehow. I haven't been able to get this working though, and I'm wondering if this approach is no longer viable.
Am I missing something? In a modern project, is it better just to go with a CVDisplayLink?
My understanding is that it's unlikely that an NSTimer will fire more frequently than about 10-20 times per second, and with timer coalescing you aren't likely to get guaranteed fire times appropriate for this type of application. For example, one answer to this question points out that the docs say:
Because of the various input sources a typical run loop manages, the effective resolution of the time interval for a timer is limited to on the order of 50-100 milliseconds. If a timer’s firing time occurs during a long callout or while the run loop is in a mode that is not monitoring the timer, the timer does not fire until the next time the run loop checks the timer. Therefore, the actual time at which the timer fires potentially can be a significant period of time after the scheduled firing time.
CVDisplayLink is definitely the preferred solution. It's quite simple to use, too.
And to answer your other question, yes something has changed. The OS has changed how timers are handled to help improve energy performance. I worked on an app that used the method you're suggesting up until about OS 10.9 or 10.10. Once that came out we had to rethink our strategy because timers worked differently.

FTView ME Acknowledge Alarms

I would like to be able to press a button on an HMI and have it both acknowledge an ALMD/ALMA alarm in the PLC and also acknowledge it in the Alarm List in the HMI. With a FT Alarm and Events server for FTView SE this would be a piece of cake, but unfortunately I'm running this on a machine.
My thoughts were to somehow use some type of PB to connect to a tag in the PLC to acknowledge the alarm there and also connect it to a macro to push the standard Ack Alarm button that you can link to the alarm list.
Would anyone know how to do that? Or have a better idea of a way to do what I am trying to do?
Thanks
This may be a better way:
On many automation platforms (ones that don't utilize the Alarms and Events feature on HMI's) a simple way to do it would be by storing an integer in the PLC. This integer would represent the "Fault Code" or "Alarm Code".
Based on watchdog conditions in the PLC, a different non-zero integer would be moved into the Fault Code address for each fault.
When the Fault Code is not equal to zero, a Fault Bit is active.
This Fault Bit would trigger the alarm screen on the HMI. The "Clear Alarm" PB on the HMI would attempt to move a zero to the Fault Code, and also attempt to re-start the automated sequence or process, in an attempt to "Reset" the fault. If successful, the fault would be cleared. If the attempt is unsuccessful, the fault would simply remain active.
As long as the alarm is displayed on the alarm screen, the HMI will log the fault.

What event will reset backgroundTimeRemaining?

In the context of an application that has been registered to run in the background with the location services, what event(s) will result in backgroundTimeRemaining being reset to its maximum value and will that reset extend the duration allowed for the completion of ongoing tasks?
Based on the experiments I ran on the simulator and hardware, and for the context I defined in the question, backgroundTimeRemaining is reset whenever an internal call from the location library is made to didUpdateLocations (or didUpdateToLocation for IOS<6).
This is what all approaches used to running continuously in background leverage in one way or another.
What are you trying to do exactly? It looks like you want to run continuously in the background.
Or maybe you just want to run a little bit of code when the location updates? Then don't "cheat the system" and run that code when your app is notified of a location change (and run it using beginBackgroundTaskWithExpirationHandler:).

iPhone Timer Frequency

I am trying to use iPhone for some sort of measurement and I need an event that fires every mSec (or sooner), this event will turn on/off the LED.
I have tried a few options to make this work without any success. If I use NSTImer event, the maximum frequency I can reach is around 100Hz.
If I turn on/off the LED in a simple for loop, the frequency goes to 300Hz but that seems to be the maximum. Also it is not purely periodic, a context switch happens and I get the control back much later.
I also experimented with Mach API but no luck. Do you think is it even possible to turn on/off LED at a frequency around 1KHz.
NSTimer has a limited resolution as you have discovered.
Apps are not designed to be real-time systems and system processes can (and do) occur from time to time which may delay processing periodically (memory alerts, system functions, etc). These may not be manifested in obvious ways for usual apps, but if you are attempting to do some intense loops then you will observe them more frequently.