Alguie sabe sobre el systema de automatizacion X10

Pregunta Sin Miedo no te cortes cualquier cosa para empezar - Autoit se comienza facilmente.Para Ordenes o Comandos sueltos. Ver nota como preguntar.
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

hola amigos , como dije en el titulo alguno de ustedes sabe como trabaja el sistema de automatatizacion X10 , es que tengo un pequenito programita que me hiciseron pero no lo logro acoplar a mi programa , entonces la persona me dio el codigo de este programita o parte de el , eso espero , basicamente el programa lo que hace es que yo tengo un interface llamado CM15A , el cual esta conectado a la corriente y a USB a la pc , cuando la electricidad se va o ocurre algun corte de electricidad este interface manda a la pc un evento que se desconecto , y cuando la electicidad vuelve , el manda otro evento de que ya esta conectado , entonces el programita este lo que hace es captar este evento y hacerme un macro a una direccion determinada de un interruptor y le manda la orden de apagarla o prenderla , en mi casa deseo la que se apague ... ahora bien , lo no se en que lenguaje este esta parte del codigo que me dieron , y queria hacer este mismo programita pero en autoit , para poder manejarlo mejor con mi programa

el evento que este dispositivo manda cuando se desconecta es

RECVRF A6 DEVICESTOP

y el evento cuando se conecta es

RECVRF A6 DEVICESTART

ahora en mi caso me interesa que el reciba cuando se conecta , para luego que me mande un comando a esta direccion

ActiveHomeObj.SendAction(sendplc, E7 off)

el codigo que me dieron seria este

Código: Seleccionar todo

Public Sub ActiveHome_Received(ByVal bszAction As Object, ByVal bszParam1 As Object, ByVal bszParam2 As Object, ByVal bszParam3 As Object, ByVal bszParam4 As Object, ByVal bszParam5 As Object, ByVal bszReserved As Object) Handles AHOBJ.RecvAction
        '    'Since this is an ActiveX Object we should convert the objects to strings which is what they really are

        Dim Reserved As String
        Dim wrap As String
        wrap = Chr(13) & Chr(10)
        Try
            action = CType(bszAction, String)   'recvplc, recvrf
            Param1 = CType(bszParam1, String)   'housecode
            Param2 = CType(bszParam2, String)   'power,on,off, dim bright
            Param3 = CType(bszParam3, String)   'not needed here
            Param4 = CType(bszParam4, String)   'not needed here
            Param5 = CType(bszParam5, String)   'not needed here
            Reserved = CType(bszReserved, String) 'not needed here
        Catch ex As Exception
            'Since we could get floods of x10 messages its best not to put any message boxes here
        End Try
        'we're only concerned about the interface reconnect
        'so we only watch for the devicestart string
        If Param2.ToUpperInvariant.ToString = "DEVICESTART" Then
            ' sends command to configured text boxes
            AHOBJ.SendAction("SendPLC", ComboBox1.Text + ComboBox2.Text + " " + ComboBox3.Text)
        End If
        'writes received info to text box
        TextBox1.Text = action + " " + Param1 + " " + Param2
       
    End Sub
tambien ajunto el programita que me dieron
Adjuntos
Xpoweron.rar
(11.42 KiB) Descargado 170 veces
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

Esta Hecho en vb.Net

Con ObjCreate & ObjEvent se puede hacer. ahorita no tengo el au3 aquí. mañana si tengo tiempo miro bien.

saludos
  • ............................................Imagen
    ......................................Imagen
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

Hola. Quizás con algo como esto debería funcionar.

Código: Seleccionar todo

Ejemplo()

Func Ejemplo()


; Monitor de Error
Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

; Creamos el Objeto
Local $oX10 = ObjCreate("X10.ActiveHome")
If @error Then Return


; Evento
Local $oX10Events = ObjEvent($oX10, "X10Event_", "_X10RecvEventRecvAction")
If @error Then Return


;Loop
While True
	Sleep(10)
WEnd

EndFunc


Func X10Event__X10RecvEventRecvAction($bszAction, $bszParm1, $bszParm2, $bszParm3, $bszParm4, $bszParm5, $bszReserved)

	ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
			"$bszAction= " & $bszAction & @CRLF & _
			"$bszParm1= " & $bszParm1 & @CRLF & _
			"$bszParm2= " & $bszParm2 & @CRLF & _
			"$bszParm3= " & $bszParm3 & @CRLF & _
			"$bszParm4= " & $bszParm4 & @CRLF & _
			"$bszParm5= " & $bszParm5 & @CRLF & _
			"$bszReserved= " & $bszReserved & @CRLF & _
			"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)

;~ 			Aqui el codigo algo como esto

;~          If $bszParm2="DEVICESTART" then
;~ 			$oX10.SendAction("sendplc", "E1 off")
;~ 			EndIf



EndFunc   ;==>X10Event__X10RecvEventRecvAction


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
	; Do anything here.
	ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
			"err.windescription:" & @TAB & $oError.windescription & @CRLF & _
			"err.description is: " & @TAB & $oError.description & @CRLF & _
			"err.source is: " & @TAB & $oError.source & @CRLF & _
			"err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
			"err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
			"err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
			"err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
			"err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

Prueba a ver como te va. saludos :smt027
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

hermano , lo prove pero nada , no funciona
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

que error te da? que te muestra?
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

no nada , yo lo que hice fue cuando lo abri ,vi esto

;~ Aqui el codigo algo como esto

;~ If $bszParm2="DEVICESTART" then
;~ $oX10.SendAction("sendplc", "E1 off")
;~ EndIf

y que no estaba en colores , sino en verde , y le quite la ;~ , pero no se si tenia que hacer asi o dejarlo como lo pusistes , yo se que luego lo compose , y basicamente , desconecte el interface de la pc , y lo conecto de nuevo y el deberia reconocer el evento

"DEVICESTART"

y luego deberia mandar el comando para apagar la luz en E1 , pero no sale nada , ni dice nada
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

ayudame a ayudarte dime que te muestra la consola de autoit(el debuger de abajo)


Prueba estos codigo:

Código: Seleccionar todo

Global $oX10=0
Ejemplo()

Func Ejemplo()


; Monitor de Error
Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

; Creamos el Objeto
$oX10 = ObjCreate("X10.ActiveHome")
If @error Then Return


; Evento
Local $oX10Events = ObjEvent($oX10, "X10Event_", "_X10RecvEventRecvAction")
If @error Then Return



$oX10.SendAction("sendplc", "E7 on")
sleep(2000)

;Loop
While True
   Sleep(10)
WEnd

EndFunc


Func X10Event__X10RecvEventRecvAction($bszAction, $bszParm1, $bszParm2, $bszParm3, $bszParm4, $bszParm5, $bszReserved)

   ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
         "$bszAction= " & $bszAction & @CRLF & _
         "$bszParm1= " & $bszParm1 & @CRLF & _
         "$bszParm2= " & $bszParm2 & @CRLF & _
         "$bszParm3= " & $bszParm3 & @CRLF & _
         "$bszParm4= " & $bszParm4 & @CRLF & _
         "$bszParm5= " & $bszParm5 & @CRLF & _
         "$bszReserved= " & $bszReserved & @CRLF & _
         "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)

;~          Aqui el codigo de lo que quieres hacer prueba asi a ver si te funciona

         If $bszParm2="DEVICESTART" then
         $oX10.SendAction("sendplc", "E7 off")
         EndIf



EndFunc   ;==>X10Event__X10RecvEventRecvAction


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
   ; Do anything here.
   ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
         "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
         "err.description is: " & @TAB & $oError.description & @CRLF & _
         "err.source is: " & @TAB & $oError.source & @CRLF & _
         "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
         "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
         "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
         "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
         "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
	 EndFunc   ;==>_ErrFunc



y este:

Código: Seleccionar todo

Global $oX10=0
Ejemplo()

Func Ejemplo()


; Monitor de Error
Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

; Creamos el Objeto
$oX10 = ObjCreate("X10.ActiveHome")
If @error Then Return


; Evento
Local $oX10Events = ObjEvent($oX10, "X10Event_", "_X10RecvEventRecvAction")
If @error Then Return



$oX10.SendAction("sendplc", "E7 on")
sleep(2000)

;Loop
While True
   Sleep(10)
WEnd

EndFunc


Func X10Event_RecvAction($bszAction, $bszParm1, $bszParm2, $bszParm3, $bszParm4, $bszParm5, $bszReserved)

   ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
         "$bszAction= " & $bszAction & @CRLF & _
         "$bszParm1= " & $bszParm1 & @CRLF & _
         "$bszParm2= " & $bszParm2 & @CRLF & _
         "$bszParm3= " & $bszParm3 & @CRLF & _
         "$bszParm4= " & $bszParm4 & @CRLF & _
         "$bszParm5= " & $bszParm5 & @CRLF & _
         "$bszReserved= " & $bszReserved & @CRLF & _
         "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)

;~          Aqui el codigo de lo que quieres hacer prueba asi a ver si te funciona

         If $bszParm2="DEVICESTART" then
         $oX10.SendAction("sendplc", "E7 off")
         EndIf



EndFunc   ;==>X10Event__X10RecvEventRecvAction


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
   ; Do anything here.
   ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
         "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
         "err.description is: " & @TAB & $oError.description & @CRLF & _
         "err.source is: " & @TAB & $oError.source & @CRLF & _
         "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
         "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
         "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
         "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
         "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

y dime lo que te muestre la consola de autoit.

saludos
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

aver si te explico

se supone que el script no lo tenga que correr o que este corriendo siempre , para cuando yo desconec y conecte el interface del usb o de la corriente , se detecte ese evento y entonces haga su trabajo de apagar la luz

supongamos que el script yo lo tengo compose osea .exe e el destop , si hago la operacion , el debe abrise solo detectar y mandar el comando , o si el script esta siempre ejecutado , igual , cuando detecte la operacion , manda el comando ... ahora me dices que sale cuando lo ejecuto en la barra del autoit , pues ale esto ,

en el primer script esto sale

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\AUTOMATION\Desktop\CM15A-1.au3"
err.number is: -2147319785
err.windescription: Field name not defined in the record.

err.description is:
err.source is:
err.helpfile is:
err.helpcontext is: 0
err.lastdllerror is: 0
err.scriptline is: 16
err.retcode is: 0

>Exit code: 0 Time: 0.314

en el segundo script sale esto

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\AUTOMATION\Desktop\CM15A-2.au3"
err.number is: -2147319785
err.windescription: Field name not defined in the record.

err.description is:
err.source is:
err.helpfile is:
err.helpcontext is: 0
err.lastdllerror is: 0
err.scriptline is: 16
err.retcode is: 0

>Exit code: 0 Time: 0.315


creo que basicamente sale lo mismo en ambos script , pero como se supone que yo no lo tengo que ejecutar , si el automaticamente se ejecutaria
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

Bueno creo que vamos bien. ahora haras lo siguiente.

este código lo pondrás en el IDE autoit y lo ejecutaras

Código: Seleccionar todo

Global $oX10=0
Ejemplo()

Func Ejemplo()


; Monitor de Error
Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

; Creamos el Objeto
$oX10 = ObjCreate("X10.ActiveHome")
If @error Then Return

ConsoleWrite("Es Objeto: " & IsObj($oX10) & @crlf)

; Evento
Local $oX10Events = ObjEvent($oX10, "X10Event_", "_DIActiveHomeEvents")
If @error Then Return

ConsoleWrite("Se creó el evento: " & IsObj($oX10Events) & @crlf)


Local $status= $oX10.SendAction("sendplc", "E7 on")
sleep(1000)
consolewrite("Estado: " & $status & @crlf)

;Loop
While True
   Sleep(10)
WEnd

EndFunc


Func X10Event_RecvAction($bszAction, $bszParm1, $bszParm2, $bszParm3, $bszParm4, $bszParm5, $bszReserved)

   ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
         "$bszAction= " & $bszAction & @CRLF & _
         "$bszParm1= " & $bszParm1 & @CRLF & _
         "$bszParm2= " & $bszParm2 & @CRLF & _
         "$bszParm3= " & $bszParm3 & @CRLF & _
         "$bszParm4= " & $bszParm4 & @CRLF & _
         "$bszParm5= " & $bszParm5 & @CRLF & _
         "$bszReserved= " & $bszReserved & @CRLF & _
         "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)

;~          Aqui el codigo de lo que quieres hacer prueba asi a ver si te funciona

         If $bszParm2="DEVICESTART" then
         $oX10.SendAction("sendplc", "E7 off")
		 ConsoleWrite("DEVICESTART= true" & @crlf)
         EndIf



EndFunc   ;==>X10Event__X10RecvEventRecvAction


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
   ; Do anything here.
   ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
         "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
         "err.description is: " & @TAB & $oError.description & @CRLF & _
         "err.source is: " & @TAB & $oError.source & @CRLF & _
         "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
         "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
         "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
         "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
         "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
    EndFunc   ;==>_ErrFunc
luego vas a conectar el dispositivo a ver si te da el evento y dime que muestra en la salida del autoit.
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

amigo buenas noticias , respondio algo , mira esto fue lo que mostro y trabajo

lo que hice fue , la luz estaba prendida , desconecte el interface y me mostro esto

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\AUTOMATION\Desktop\CM15A-3.au3"
Es Objeto: 1
Se creó el evento: 1
Estado: 0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$bszAction= recvrf
$bszParm1= a6
$bszParm2= DeviceStop
$bszParm3= -1
$bszParm4= 20140122153446
$bszParm5=
$bszReserved=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$bszAction= recvrf
$bszParm1= a6
$bszParm2= DeviceStart
$bszParm3= 0
$bszParm4= 20140122153610
$bszParm5=
$bszReserved=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

hasta aqui fue cuando lo desconecte ...........

DEVICESTART= true
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$bszAction= RecvPlc
$bszParm1= e4
$bszParm2= ExtCode
$bszParm3= 49
$bszParm4= 62
$bszParm5=
$bszReserved=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$bszAction= RecvPlc
$bszParm1= e4
$bszParm2= Off
$bszParm3=
$bszParm4=
$bszParm5=
$bszReserved=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


y lo otro lo mostro cuando lo conecte el interface , y me apago la luz

wowowo
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

Joya. entonces ahora explica bien que vamos a lograr? que tiene que hacer exactamente. explica detalladamente.

saludos :smt027
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

bueno yo pienso que hay dos maneras

1- que el script estuviera siempre corriendo , ahora como esta asi
2 , seria mejor que si el script se abriera automaticamente cuando el detecta que el interface se conecto , osea se abre , hace su funcion , manda el comando de apagar la luz y luego se cierra el script , para no tenerlo corriendo todo el tiempo
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

Se puede hacer como sea que si se inicia o si esta permanente. ahorita cuando me desocupe me armo algo para que pruebes (ando en el trabajo :S)
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

no problema mi amigo , tomate tu tiempo , yo no estoy apurado
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

Bueno Esto fue lo que se me ocurrió.

Código: Seleccionar todo

;Variable Global EL objeto
Global $oX10 = 0
Global $Loop = True

Ejemplo()

Func Ejemplo()


	; Monitor de Error
	Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

	; Creamos el Objeto
	$oX10 = ObjCreate("X10.ActiveHome")
	If @error Then Return 0 ;Si hay Error Terminamos la Aplicación


	If IsObj($oX10) Then
		ConsoleWrite("El Objeto se Creó Correctamente :)" & @CRLF)
	Else
		ConsoleWrite("No se Pudo Crear el Objeto :(" & @CRLF)
		Return 0
	EndIf

	; Evento
	Local $oX10Events = ObjEvent($oX10, "X10Event_", "_DIActiveHomeEvents")
	If @error Then Return 0;Si hay Error Terminamos la Aplicación

	If IsObj($oX10Events) Then
		ConsoleWrite("El Evento se Creó Correctamente :)" & @CRLF)
	Else
		ConsoleWrite("No se Pudo Crear el Evento :(" & @CRLF)
		Return 0
	EndIf



	;Loop Esperamos Hasta Conseguir el Evento "DEVICESTART"
	Do
		Sleep(10)
		If Not ($Loop) Then ConsoleWrite("La Aplicación Ha finalizado" & @CRLF)
	Until $Loop = False

EndFunc   ;==>Ejemplo


Func X10Event_RecvAction($bszAction, $bszParm1, $bszParm2, $bszParm3, $bszParm4, $bszParm5, $bszReserved)

	ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
			"$bszAction= " & $bszAction & @CRLF & _
			"$bszParm1= " & $bszParm1 & @CRLF & _
			"$bszParm2= " & $bszParm2 & @CRLF & _
			"$bszParm3= " & $bszParm3 & @CRLF & _
			"$bszParm4= " & $bszParm4 & @CRLF & _
			"$bszParm5= " & $bszParm5 & @CRLF & _
			"$bszReserved= " & $bszReserved & @CRLF & _
			"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)

;~       Codigo Para Comprobar y terminar La Aplicación
	If $bszParm2 = "DEVICESTART" Then
		$oX10.SendAction("sendplc", "E7 off")
		ConsoleWrite('Evento "DEVICESTART" Encontrado' & @CRLF)
		$Loop = False
	EndIf



EndFunc   ;==>X10Event_RecvAction


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
	; Do anything here.
	ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
			"err.windescription:" & @TAB & $oError.windescription & @CRLF & _
			"err.description is: " & @TAB & $oError.description & @CRLF & _
			"err.source is: " & @TAB & $oError.source & @CRLF & _
			"err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
			"err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
			"err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
			"err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
			"err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

La aplicacion La ejecutas. Si consigue el evento "DEVICESTART" se enviara la señal "SendAction("sendplc", "E7 off")" y terminara la aplicación. mientras no se consiga el evento no termina la aplicación. pruebala a ver que tal.


saludos
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

de funcionar , funciona , pero si cierro la aplicacion , ya no vuelve a llamarla verdad ? ,

osea , si abro el .exe , luego ocurre el evento , se apaga la luz , perfecto , pero veo que el .exe , se cierra solo , ya luego , tocara volverlo a abrir manual no ?
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

Si correcto.

bueno si quieres mantenerlo entonces hace esto:
ahi modifique para que no se cierro. si quieres cerrarla presiona la tecla Esc

Código: Seleccionar todo

;Variable Global EL objeto
Global $oX10 = 0
Global $Loop = True
;Hotkey para terminar la Aplicacion presionado la tecla Esc
HotKeySet("{ESC}", "Salir")
Ejemplo()

Func Ejemplo()


   ; Monitor de Error
   Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

   ; Creamos el Objeto
   $oX10 = ObjCreate("X10.ActiveHome")
   If @error Then Return 0 ;Si hay Error Terminamos la Aplicación


   If IsObj($oX10) Then
      ConsoleWrite("El Objeto se Creó Correctamente :)" & @CRLF)
   Else
      ConsoleWrite("No se Pudo Crear el Objeto :(" & @CRLF)
      Return 0
   EndIf

   ; Evento
   Local $oX10Events = ObjEvent($oX10, "X10Event_", "_DIActiveHomeEvents")
   If @error Then Return 0;Si hay Error Terminamos la Aplicación

   If IsObj($oX10Events) Then
      ConsoleWrite("El Evento se Creó Correctamente :)" & @CRLF)
   Else
      ConsoleWrite("No se Pudo Crear el Evento :(" & @CRLF)
      Return 0
   EndIf



   ;Loop Esperamos Hasta Conseguir el Evento "DEVICESTART"
   Do
      Sleep(10)
      If Not ($Loop) Then ConsoleWrite("La Aplicación Ha finalizado" & @CRLF)
   Until $Loop = False

EndFunc   ;==>Ejemplo


Func X10Event_RecvAction($bszAction, $bszParm1, $bszParm2, $bszParm3, $bszParm4, $bszParm5, $bszReserved)

   ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_X10RecvEventRecvAction--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
         "$bszAction= " & $bszAction & @CRLF & _
         "$bszParm1= " & $bszParm1 & @CRLF & _
         "$bszParm2= " & $bszParm2 & @CRLF & _
         "$bszParm3= " & $bszParm3 & @CRLF & _
         "$bszParm4= " & $bszParm4 & @CRLF & _
         "$bszParm5= " & $bszParm5 & @CRLF & _
         "$bszReserved= " & $bszReserved & @CRLF & _
         "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)

;~       Codigo Para Comprobar y terminar La Aplicación
   If $bszParm2 = "DEVICESTART" Then
      $oX10.SendAction("sendplc", "E7 off")
      ConsoleWrite('Evento "DEVICESTART" Encontrado' & @CRLF)
      ;$Loop = False
   EndIf



EndFunc   ;==>X10Event_RecvAction

Func Salir ()
	$Loop=False
EndFunc


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
   ; Do anything here.
   ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
         "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
         "err.description is: " & @TAB & $oError.description & @CRLF & _
         "err.source is: " & @TAB & $oError.source & @CRLF & _
         "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
         "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
         "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
         "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
         "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

saludos
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

debe ser imposible que se abra cuando lo necesite y que se cierre luego de hacer su trabajo , sino , esta bien asi , al menos trabaja perfecto
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por Dany »

SI digamos que si. porque sino dependería de otro script. o del el mismo. siempre estaría activo uno.


saludos

de nada. :P


:smt027
  • ............................................Imagen
    ......................................Imagen
mikeeps2
Hacker del Foro
Mensajes: 103
Registrado: 24 May 2008, 16:34

Re: Alguie sabe sobre el systema de automatizacion X10

Mensaje por mikeeps2 »

dany , dejame explicarte cual es la finalidad de este script , bueno el x10 sabes que tiene algunas cosas en contra que no se porque no las han areglado , bueno una de ellas es los modulos de lampara ,LM465 , tienen internamente en el circuito una funcion que cuando el modulo se queda sin electricidad , tiene una sensibilidad de cuando vuelve la electricidad , se activa solo el modulo y se prende la luz , bueno en los modelos viejos , se le hacia un invento adentro de una resistencia o diodo , pero los modelos nuevos , como el que tengo yo , ya cambiaron el circuito , y eso no se puede hacer , entonces un sr de un forum que sabe muchisimo de x10 me dijo la manera es por software , pero tienes que ver como tu computadora recibe el evento del interface CM15A cuando se queda sin electricidad y cuando vuelve , entonces ese evento se usaria para mandarle la orden que cuando venga la electricidad el modulo solo se prenderia , y el script este manda la orden que lo apague , sino estaria todo el dia prendida la lampara por gusto ........
Responder