Hallo Gunnar,
wird schon :). Ich gehe jetzt mal von aus das Du kein FS20 benutzt, warum löscht Du es dann nicht.
Mach mal folgendes.
[ol]
[li]alle Variablen die du nicht benötigst löschen[/li][/ol]
Für das Chromo bleiben 4 Integer Variablen übrig, Programm, Rot, Grün, Blau
Ich ändere dir das Script und dann bitte dein altes durch das ersetzen.
Wenn Du auf einen Slider(Farbe) klickst, muss der Wert im Objektbaum unter der entsprechenden Farbe erscheinen.
Mach am besten auch noch einen Shot von deinem Objektbaum.
<?
/*
*******************************
IP-SYMCON Event Scripting
*******************************
File : Chromoflex.ips.php
Trigger : $IPS_VALUE
Interval :
*/
if($IPS_SENDER == "WebFront")
{
SetValue($IPS_VARIABLE, $IPS_VALUE);
}
define ("Comport", 28269);
$Startbyte = "\xCA"; // StartByte (Muss nicht verändert werden)
$Adresse = "\x00\x00\x00"; // Adresse 0,0,0 = Broadcast
switch ($IPS_VALUE)
{
case "260":
break;
case "261":
break;
case "262":
break;
/*Programmnummer aufrufen 0-7 und 9. Es erfolgt erst ein Reset,
danach wird das Programm mit einer kleinen Verzögerung aufgerufen, diese muss sein, sonst startet das Programm nicht.
Programm = 200+3*Programmnummer. Hier als Beispiel Nr.3, 200 + 3 * 3 = 209 entspricht 0xD1*/
case "263": // Eigenes Programm(Alarm)
Reseten(); // Funktion aufrufen
IPS_Sleep(750); // 750ms warten, ansonsten starten die Programme nicht(Timing)
$cmd = chr(0).chr(3).chr(0x7D).chr(0x15).chr(0).chr(0xD1); //Programm. 0xD1 startet Programm 3
$txt = $Adresse.$cmd;
$crc = CRC16r($Startbyte.$txt);
$txt = str_replace(chr(0xCB), chr(0xCB).chr(0x01), $txt);
$txt = str_replace(chr(0xCA), chr(0xCB).chr(0x00), $txt);
COMPort_SendText(Comport, $Startbyte.$txt.$crc);
return;
break;
case "265": // Weiß
SetValue(36832 , 255);
SetValue(54808, 255);
SetValue(54179, 255);
break;
case "266": // Gelb
SetValue(36832 , 255);
SetValue(54808, 255);
SetValue(54179, 0);
break;
case "267": // Violett
SetValue(36832 , 255);
SetValue(54808, 0);
SetValue(54179, 255);
break;
case "268": // Chromoflex ausschalten(Standby) alle Werte auf 0
SetValue(36832 , 0);
SetValue(54808, 0);
SetValue(54179, 0);
break;
case "269": // Nach Reset startet das Default Programm
Reseten(); // Funktion aufrufen
break;
default:
SetValue(39876, 264);
break;
}
// Werte einlesen
$Rot = GetValue(36832);
$Gruen = GetValue(54808);
$Blau = GetValue(54179);
// Status setzen
$cmd = chr(0).chr(2).chr(0x7E).chr(0x12).chr(0x01);
$txt = $Adresse.$cmd;
$crc = CRC16r($Startbyte.$txt);
$txt = str_replace(chr(0xCB), chr(0xCB).chr(0x01), $txt);
$txt = str_replace(chr(0xCA), chr(0xCB).chr(0x00), $txt);
COMPort_SendText(Comport, $Startbyte.$txt.$crc);
/*
// Track setzen
$cmd = chr(0).chr(3).chr(0x7E).chr(0x11).chr(0x01).chr(0x01);
$txt = $Adresse.$cmd;
$crc = CRC16r($Startbyte.$txt);
$txt = str_replace(chr(0xCB), chr(0xCB).chr(0x01), $txt);
$txt = str_replace(chr(0xCA), chr(0xCB).chr(0x00), $txt);
COMPort_SendText(Comport, $Startbyte.$txt.$crc);
/*
//INKREMENTIERUNG FESTLEGEN -> 255 = sofort, 1 = 2,55ms für Änderungen von 0 auf 255
define('Rot', 255);
define('Gruen', 255);
define('Blau', 255);
$cmd = chr(0).chr(5).chr(0x7E).chr(8).chr(Rot).chr(Gruen).chr(Blau).chr(0x64);
$txt = $Adresse.$cmd;
$crc = CRC16r($Startbyte.$txt);
$txt = str_replace(chr(0xCB), chr(0xCB).chr(0x01), $txt);
$txt = str_replace(chr(0xCA), chr(0xCB).chr(0x00), $txt);
COMPort_SendText(Comport, $Startbyte.$txt.$crc);
*/
//Farben setzen ==> Set
$cmd = chr(0).chr(4).chr(0x7E).chr(4).chr($Rot).chr($Gruen).chr($Blau);
$txt = $Adresse.$cmd;
$crc = CRC16r($Startbyte.$txt);
$txt = str_replace(chr(0xCB), chr(0xCB).chr(0x01), $txt);
$txt = str_replace(chr(0xCA), chr(0xCB).chr(0x00), $txt);
COMPort_SendText(Comport, $Startbyte.$txt.$crc);
//Level setzen
$cmd = chr(0).chr(4).chr(0x7E).chr(0).chr($Rot).chr($Gruen).chr($Blau);
$txt = $Adresse.$cmd;
$crc = CRC16r($Startbyte.$txt);
$txt = str_replace(chr(0xCB), chr(0xCB).chr(0x01), $txt);
$txt = str_replace(chr(0xCA), chr(0xCB).chr(0x00), $txt);
COMPort_SendText(Comport, $Startbyte.$txt.$crc);
// Funktion zur Checksummenberechnung by HJH
function CRC16r($s) // CRC16 reverse
{
$CRCreg = 0xffff << 1; // Startwert
$PLYreg = 0xA001 << 1; // Polynom
$len = strlen($s);
for ($cp=0; $cp<$len; $cp++)
{
$CRCreg ^= ord($s[$cp]) << 1;
for ($bp=0; $bp<8; $bp++)
{
$CRCreg >>= 1;
if ($CRCreg & 0x01) $CRCreg ^= $PLYreg;
}
}
$crc = $CRCreg >> 1;
$crcLo = $crc & 0xff;
$crcHi = $crc >> 8;
return chr($crcHi).chr($crcLo);
}
// Funktion Reseten
function Reseten()
{
SetValue(36832 , 0);
SetValue(54808, 0);
SetValue(54179, 0);
$cmd = chr(0).chr(0).chr(0xFE);
$txt = "\x00\x00\x00".$cmd;
$crc = CRC16r("\xCA".$txt);
$txt = str_replace(chr(0xCB), chr(0xCB).chr(0x01), $txt);
$txt = str_replace(chr(0xCA), chr(0xCB).chr(0x00), $txt);
COMPort_SendText(Comport,"\xCA".$txt.$crc);
}
?>