Reboot after close

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
KevinA.
Posts: 34
Joined: Wed Oct 24, 2012 1:22 pm

Reboot after close

Post by KevinA. »

How can I reboot my application after I do a close of the application, without having to download or to power it off?

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Reboot after close

Post by mark.monroe »

This topic has been already covered in this forum post. You just need to add the code to the event that you want. In the example script, it is associated with a button.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

KevinA.
Posts: 34
Joined: Wed Oct 24, 2012 1:22 pm

Re: Reboot after close

Post by KevinA. »

I downloaded your zip file and tried it but each time I try it simulation as soon as I click one of the buttons an error closes the program. Here is the error;

Also when I copy the reboot part of the HMI in my application, I have all these errors.
Attachments
errorlist.PNG
errorlist.PNG (58.65 KiB) Viewed 14695 times
applicationscript.PNG
applicationscript.PNG (80.68 KiB) Viewed 14695 times
ErrorSoftReboot.png
ErrorSoftReboot.png (274.59 KiB) Viewed 14695 times

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Reboot after close

Post by mark.monroe »

That file is used to reboot a HMI that runs Windows CE. Running the application in simulation mode on a PC will not work because there are different functions used to reboot a Windows 7 machine as opposed to a Windows CE machine.

What is the OS and/or name of the HMI panel that you are trying to reboot?
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

KevinA.
Posts: 34
Joined: Wed Oct 24, 2012 1:22 pm

Re: Reboot after close

Post by KevinA. »

I am using a T10A and T7A HMI panel. Will it work with those?

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Reboot after close

Post by mark.monroe »

Yes, those run Windows CE. Try downloading your application to one of those terminals and see it the button works.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

KevinA.
Posts: 34
Joined: Wed Oct 24, 2012 1:22 pm

Re: Reboot after close

Post by KevinA. »

I've put this code in my application

Code: Select all

void Button36_Click(System.Object sender, System.EventArgs e)
	{
	string systemStateName = "reboot";
	uint nError = CESetSystemPowerState(systemStateName.ToCharArray(), 0, 0x0);
	}
but I can't download to my HMI cause he gives me this error while trying :S
Attachments
Windows error.PNG
Windows error.PNG (19.54 KiB) Viewed 14668 times

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Reboot after close

Post by mark.monroe »

You need to add the code that defines the CESetSystemPowerState function.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

KevinA.
Posts: 34
Joined: Wed Oct 24, 2012 1:22 pm

Re: Reboot after close

Post by KevinA. »

which code is it? If it is this one

Code: Select all

	
[DllImport("coredll.dll", EntryPoint = "GetSystemPowerState")]
		private static extern uint CEGetSystemPowerState(StringBuilder Buffer, uint Length, out uint Flags);

		[DllImport("coredll.dll", EntryPoint = "SetSystemPowerState")]
		private static extern uint CESetSystemPowerState(char[] sState, uint StateFlags, uint Options);
When I put those lines it gives me those errors
Attachments
Windows error.PNG
Windows error.PNG (49.19 KiB) Viewed 14663 times

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Reboot after close

Post by mark.monroe »

Copy all the "using" values as well.

Specifically:
using System.Text;
using System.Runtime.InteropServices;
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Post Reply