// File: /workspace/github_cpp_makefile_star2_O2/Eba-M[P]E3DC-Control/RscpExampleMain.cpp
// Function: wolfstatus()
int wolfstatus()
{
    time_t now;
    time(&now);
    static time_t wolf_t;
    //           Test zur Abfrage des Tesmota Relais
    if (strcmp(e3dc_config.mqtt_ip,"0.0.0.0")!=0&&e3dc_config.WPWolf)
    {
        
        
        if (WP_status < 2)
        {
            if (wolf.size()==0)
            {
                wo.wert = 0;
                wo.t = 0;
                wo.status = "";
                wo.feld = "Vorlauftemperatur";
                wo.AK = "VL";
                wpvl = wolf.size();
                wolf.push_back(wo);
                /*                wo.feld = "Sammlertemperatur";
                 wo.AK = "ST";
                 wolf.push_back(wo);
                 */                wo.feld = "Kesseltemperatur";
                wo.AK = "KT";
                wpkt = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Kesseltemperatur 2";
                wo.AK = "KT2";
                wpkt2 = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Rücklauftemperatur";
                wo.AK = "RL";
                wprl = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Heizleistung";
                wo.AK = "HL";
                wphl = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Leistungsaufnahme (WP + EHZ)";
                wo.AK = "PW";
                wppw = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Aktuelle Leistungsvorgabe Verdichter";
                wo.AK = "ALV";
                wpalv = wolf.size();
                wolf.push_back(wo);
                wo.feld = "EEV K"; // Ventil auf Kühlen = Abtaubetrieb
                wo.AK = "EEV K";
                wo.wert = 0;
                wpeevk = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Heizkreisdurchfluss";
                wo.AK = "HD";
                wolf.push_back(wo);
                wo.feld = "Zulufttemperatur";
                wo.AK = "ZL";
                wo.wert = -99;
                wpzl = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Sauggastemperatur";
                wo.AK = "SGT";
                wolf.push_back(wo);
                wo.feld = "Ablufttemperatur";
                wpal = wolf.size();
                wo.AK = "AL";
                wo.wert = -99;
                wolf.push_back(wo);
                wo.feld = "Verdichterfrequenz";
                wo.AK = "VFQ";
                wo.wert = -5;
                wpswk = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Betriebsart Heizgerät";
                wo.AK = "BHG";
                wpbhg = wolf.size();
                wolf.push_back(wo);
                wo.feld = "Verdichterstatus";
                wo.AK = "VS";
                vdstatus = wolf.size();
                wolf.push_back(wo);
            }
            
            
            wolf_fp = NULL;
            sprintf(buf,"mosquitto_sub -h %s -t Wolf/+/#",e3dc_config.mqtt_ip);
//            if (e3dc_config.debug)
            printf("Wo0a");
            wolf_fp = popen(buf, "r");
            if (wolf_fp != NULL)
            {
                //            if (e3dc_config.debug)
                printf("Wo0b");
                int fd = fileno(wolf_fp);
                int flags = fcntl(fd, F_GETFL, 0);
                flags |= O_NONBLOCK;
                fcntl(fd, F_SETFL, flags);
                //            if (e3dc_config.debug)
            }
            printf("Wo0c");
            
            WP_status = 2;
            wolf_t = now;
        }
        if (now-wolf_t > 300)
        {
//            if (e3dc_config.debug)
                printf("Wo1b\n");
//            if (wolf_fp != NULL)
//                status = pclose(wolf_fp);
//            if (e3dc_config.debug)
            printf("Wo1c");
            wolf_fp = NULL;
            WP_status = 1;
        }
        if (e3dc_config.debug) printf("Wo1\n");
        if (wolf_fp != NULL)
        {
//            if (e3dc_config.debug)
                printf("Wo%i",now-wolf_t);
            
            while (fgets(path, 4096, wolf_fp) != NULL)
            {
                if (e3dc_config.debug) printf("Wo2");
                
                const cJSON *item = NULL;
                cJSON *wolf_json = cJSON_Parse(path);
                wolf_t = now;
                for(int x1=0;x1<wolf.size();x1++)
                {
                    char * c = &wolf[x1].feld[0];
                    item = cJSON_GetObjectItemCaseSensitive(wolf_json, c );
                    if (item != NULL)
                    {
                        wolf[x1].wert = item->valuedouble;
                        wolf[x1].t = now;
                        if (item->valuestring!= NULL)
                            wolf[x1].status = item->valuestring;
                        
                        if ((wolf[x1].feld=="Verdichterstatus")||
                            (wolf[x1].feld=="Betriebsart Heizgerät"))
                        {
                            item = item->child;
                            wolf[x1].wert = item->valuedouble;
                            item = item->next;
                            wolf[x1].status = item->valuestring;
                        }
                    }
                }
                
                cJSON_Delete(wolf_json);
                iPower_WP = wolf[wppw].wert*1000;
                if (wolf[wphl].wert>0)
                    iHeat_WP = wolf[wphl].wert*1000;
                else
                    iHeat_WP = 0;
                if (iPower_WP==0&&ALV>0&&tasmota_status[0]==0) // keine EVU sperre
                    iPower_WP = 700;
                else
                    if (iPower_WP>0&&ALV==0)
                    {
                        iPower_WP = 0;
                        iHeat_WP = 0;
                    }
            }
        }
    }
    if (e3dc_config.debug) printf("Wo1d\n");
    if (wolf_fp == NULL) WP_status = 1;
//    else            status = pclose(wolf_fp);
    if (e3dc_config.debug) printf("Wo1e\n");

    return WP_status;
        

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsp, %rdi
callq 0x2250
movabsq $0x302e302e302e30, %rax # imm = 0x302E302E302E30
cmpq %rax, 0x3087b(%rip)     # 0x36954
je 0x684a
cmpb $0x1, 0x30d66(%rip)     # 0x36e4c
jne 0x684a
cmpl $0x2, 0x30255(%rip)     # 0x36348
jge 0x65d9
movq 0x30320(%rip), %rax     # 0x36420
cmpq 0x30311(%rip), %rax     # 0x36418
jne 0x6524
andl $0x0, 0x31d44(%rip)     # 0x37e58
leaq 0x31cd5(%rip), %rbx     # 0x37df0
andq $0x0, 0x31ccd(%rip)     # 0x37df0
leaq 0x31d0e(%rip), %rdi     # 0x37e38
leaq 0x27139(%rip), %rsi     # 0x2d26a
callq 0x2530
leaq 0x31cbb(%rip), %r15     # 0x37df8
leaq 0x2596a(%rip), %rsi     # 0x2baae
movq %r15, %rdi
callq 0x2530
leaq 0x31cc5(%rip), %r12     # 0x37e18
leaq 0x25966(%rip), %rsi     # 0x2bac0
movq %r12, %rdi
callq 0x2530
leaq 0x302af(%rip), %rbp     # 0x36418
movq 0x302b0(%rip), %rax     # 0x36420
subq 0x302a1(%rip), %rax     # 0x36418
cqto
pushq $0x70
popq %rcx
idivq %rcx
movq %rcx, %r14
movl %eax, 0x31a60(%rip)     # 0x37be8
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x25929(%rip), %rsi     # 0x2bac3
movq %r15, %rdi
callq 0x2530
leaq 0x2592b(%rip), %rsi     # 0x2bad4
movq %r12, %rdi
callq 0x2530
movq 0x30268(%rip), %rax     # 0x36420
subq 0x30259(%rip), %rax     # 0x36418
cqto
idivq %r14
movl %eax, 0x31a36(%rip)     # 0x37c00
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x258fb(%rip), %rsi     # 0x2bad7
movq %r15, %rdi
callq 0x2530
leaq 0x258ff(%rip), %rsi     # 0x2baea
movq %r12, %rdi
callq 0x2530
movq 0x30226(%rip), %rax     # 0x36420
subq 0x30217(%rip), %rax     # 0x36418
cqto
idivq %r14
movl %eax, 0x319f8(%rip)     # 0x37c04
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x258d0(%rip), %rsi     # 0x2baee
movq %r15, %rdi
callq 0x2530
leaq 0x258d5(%rip), %rsi     # 0x2bb02
movq %r12, %rdi
callq 0x2530
movq 0x301e4(%rip), %rax     # 0x36420
subq 0x301d5(%rip), %rax     # 0x36418
cqto
idivq %r14
movl %eax, 0x3199e(%rip)     # 0x37bec
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x258a5(%rip), %rsi     # 0x2bb05
movq %r15, %rdi
callq 0x2530
leaq 0x258a3(%rip), %rsi     # 0x2bb12
movq %r12, %rdi
callq 0x2530
movq 0x301a2(%rip), %rax     # 0x36420
subq 0x30193(%rip), %rax     # 0x36418
cqto
idivq %r14
movl %eax, 0x31960(%rip)     # 0x37bf0
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x25873(%rip), %rsi     # 0x2bb15
movq %r15, %rdi
callq 0x2530
leaq 0x25881(%rip), %rsi     # 0x2bb32
movq %r12, %rdi
callq 0x2530
movq 0x30160(%rip), %rax     # 0x36420
subq 0x30151(%rip), %rax     # 0x36418
cqto
idivq %r14
movl %eax, 0x31922(%rip)     # 0x37bf4
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x25851(%rip), %rsi     # 0x2bb35
movq %r15, %rdi
callq 0x2530
leaq 0x25867(%rip), %rsi     # 0x2bb5a
movq %r12, %rdi
callq 0x2530
movq 0x3011e(%rip), %rax     # 0x36420
subq 0x3010f(%rip), %rax     # 0x36418
cqto
idivq %r14
movl %eax, 0x318f8(%rip)     # 0x37c0c
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x25838(%rip), %r13     # 0x2bb5e
movq %r15, %rdi
movq %r13, %rsi
callq 0x2530
movq %r12, %rdi
movq %r13, %rsi
callq 0x2530
andl $0x0, 0x31b15(%rip)     # 0x37e58
movq 0x300d6(%rip), %rax     # 0x36420
subq 0x300c7(%rip), %rax     # 0x36418
cqto
idivq %r14
movq %r14, %r13
movl %eax, 0x318b5(%rip)     # 0x37c14
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x257f3(%rip), %rsi     # 0x2bb64
movq %r15, %rdi
callq 0x2530
leaq 0x257f8(%rip), %rsi     # 0x2bb78
movq %r12, %rdi
callq 0x2530
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x257e1(%rip), %rsi     # 0x2bb7b
movq %r15, %rdi
callq 0x2530
leaq 0x257e3(%rip), %rsi     # 0x2bb8c
movq %r12, %rdi
callq 0x2530
movl $0xc2c60000, %r14d      # imm = 0xC2C60000
movl %r14d, 0x31a9a(%rip)    # 0x37e58
movq 0x3005b(%rip), %rax     # 0x36420
subq 0x3004c(%rip), %rax     # 0x36418
cqto
idivq %r13
movl %eax, 0x31831(%rip)     # 0x37c08
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x257a6(%rip), %rsi     # 0x2bb8f
movq %r15, %rdi
callq 0x2530
leaq 0x257a9(%rip), %rsi     # 0x2bba1
movq %r12, %rdi
callq 0x2530
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x25793(%rip), %rsi     # 0x2bba5
movq %r15, %rdi
callq 0x2530
movq 0x2ffff(%rip), %rax     # 0x36420
subq 0x2fff0(%rip), %rax     # 0x36418
cqto
idivq %r13
movl %eax, 0x317dd(%rip)     # 0x37c10
leaq 0x2577c(%rip), %rsi     # 0x2bbb6
movq %r12, %rdi
callq 0x2530
movl %r14d, 0x31a0f(%rip)    # 0x37e58
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x2575e(%rip), %rsi     # 0x2bbb9
movq %r15, %rdi
callq 0x2530
leaq 0x25762(%rip), %rsi     # 0x2bbcc
movq %r12, %rdi
callq 0x2530
movl $0xc0a00000, 0x319dc(%rip) # imm = 0xC0A00000
movq 0x2ff9d(%rip), %rax     # 0x36420
subq 0x2ff8e(%rip), %rax     # 0x36418
cqto
idivq %r13
movl %eax, 0x31763(%rip)     # 0x37bf8
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x25729(%rip), %rsi     # 0x2bbd0
movq %r15, %rdi
callq 0x2530
leaq 0x25731(%rip), %rsi     # 0x2bbe7
movq %r12, %rdi
callq 0x2530
movq 0x2ff5b(%rip), %rax     # 0x36420
subq 0x2ff4c(%rip), %rax     # 0x36418
cqto
idivq %r13
movl %eax, 0x31741(%rip)     # 0x37c18
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
leaq 0x25702(%rip), %rsi     # 0x2bbeb
movq %r15, %rdi
callq 0x2530
leaq 0x25704(%rip), %rsi     # 0x2bbfc
movq %r12, %rdi
callq 0x2530
movq 0x2ff19(%rip), %rax     # 0x36420
subq 0x2ff0a(%rip), %rax     # 0x36418
cqto
idivq %r13
movl %eax, 0x318b3(%rip)     # 0x37dcc
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x124a6
andq $0x0, 0x31894(%rip)     # 0x37dc0
leaq 0x3193d(%rip), %rbx     # 0x37e70
leaq 0x256c5(%rip), %rsi     # 0x2bbff
leaq 0x30413(%rip), %rdx     # 0x36954
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2050
leaq 0x256cd(%rip), %rdi     # 0x2bc1f
xorl %eax, %eax
callq 0x2040
leaq 0x272f8(%rip), %rsi     # 0x2d858
movq %rbx, %rdi
callq 0x20a0
movq %rax, 0x31851(%rip)     # 0x37dc0
testq %rax, %rax
je 0x65b1
leaq 0x256a9(%rip), %rdi     # 0x2bc24
xorl %eax, %eax
callq 0x2040
movq 0x31837(%rip), %rdi     # 0x37dc0
callq 0x22d0
movl %eax, %ebx
pushq $0x3
popq %rsi
movl %eax, %edi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2170
orl $0x800, %eax            # imm = 0x800
pushq $0x4
popq %rsi
movl %ebx, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x2170
leaq 0x25671(%rip), %rdi     # 0x2bc29
xorl %eax, %eax
callq 0x2040
movl $0x2, 0x2fd7f(%rip)     # 0x36348
movq (%rsp), %rax
movq %rax, 0x3188c(%rip)     # 0x37e60
movq %rax, %rcx
jmp 0x65e4
movq (%rsp), %rcx
movq 0x3187c(%rip), %rax     # 0x37e60
subq %rax, %rcx
cmpq $0x12d, %rcx            # imm = 0x12D
jl 0x661c
leaq 0x267a2(%rip), %rdi     # 0x2cd99
callq 0x2440
leaq 0x2562b(%rip), %rdi     # 0x2bc2e
xorl %eax, %eax
callq 0x2040
andq $0x0, 0x317ae(%rip)     # 0x37dc0
movl $0x1, 0x2fd2c(%rip)     # 0x36348
cmpb $0x1, 0x30822(%rip)     # 0x36e45
jne 0x6631
leaq 0x26772(%rip), %rdi     # 0x2cd9e
callq 0x2440
cmpq $0x0, 0x31787(%rip)     # 0x37dc0
je 0x684a
movq (%rsp), %rsi
subq 0x31816(%rip), %rsi     # 0x37e60
leaq 0x255e2(%rip), %rdi     # 0x2bc33
xorl %eax, %eax
callq 0x2040
leaq 0x31891(%rip), %rbx     # 0x37ef0
leaq 0x25585(%rip), %r15     # 0x2bbeb
leaq 0x25563(%rip), %r12     # 0x2bbd0
movq 0x3174c(%rip), %rdx     # 0x37dc0
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x2470
testq %rax, %rax
je 0x684a
cmpb $0x1, 0x307b4(%rip)     # 0x36e45
jne 0x66a1
leaq 0x2559e(%rip), %rdi     # 0x2bc38
xorl %eax, %eax
callq 0x2040
movq %rbx, %rdi
callq 0x28719
movq %rax, %r13
movq (%rsp), %rax
movq %rax, 0x317a9(%rip)     # 0x37e60
pushq $0x48
popq %rbx
xorl %r14d, %r14d
movq 0x2fd5c(%rip), %rax     # 0x36420
movq 0x2fd4d(%rip), %rcx     # 0x36418
subq %rcx, %rax
cqto
pushq $0x70
popq %rsi
idivq %rsi
cmpq %r14, %rax
jbe 0x678a
movq -0x40(%rcx,%rbx), %rsi
movq %r13, %rdi
callq 0x28e9b
testq %rax, %rax
je 0x677e
movq %rax, %rbp
cvtsd2ss 0x30(%rax), %xmm0
movq 0x2fd14(%rip), %rdi     # 0x36418
movss %xmm0, 0x20(%rdi,%rbx)
movq (%rsp), %rax
movq %rax, -0x48(%rdi,%rbx)
movq 0x20(%rbp), %rsi
testq %rsi, %rsi
je 0x672b
addq %rbx, %rdi
callq 0x2530
movq 0x2fced(%rip), %rdi     # 0x36418
addq %rbx, %rdi
addq $-0x40, %rdi
movq %r15, %rsi
callq 0x124d2
testb %al, %al
jne 0x6759
movq 0x2fcd3(%rip), %rax     # 0x36418
leaq (%rax,%rbx), %rdi
addq $-0x40, %rdi
movq %r12, %rsi
callq 0x124d2
testb %al, %al
je 0x677e
movq 0x10(%rbp), %rax
cvtsd2ss 0x30(%rax), %xmm0
movq 0x2fcaf(%rip), %rdi     # 0x36418
movss %xmm0, 0x20(%rdi,%rbx)
addq %rbx, %rdi
movq (%rax), %rax
movq 0x20(%rax), %rsi
callq 0x2530
incq %r14
addq $0x70, %rbx
jmp 0x66bd
movq %r13, %rdi
callq 0x27f56
movslq 0x3145b(%rip), %rax     # 0x37bf4
movq 0x2fc78(%rip), %rcx     # 0x36418
imulq $0x70, %rax, %rax
movss 0x68(%rcx,%rax), %xmm0
movss 0x24b66(%rip), %xmm1    # 0x2b318
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x32730(%rip)     # 0x38ef0
movslq 0x31429(%rip), %rdx     # 0x37bf0
imulq $0x70, %rdx, %rdx
movss 0x68(%rcx,%rdx), %xmm0
ucomiss 0x24b60(%rip), %xmm0    # 0x2b338
mulss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
movl $0x0, %edx
cmovbel %edx, %ecx
movl %ecx, 0x32706(%rip)     # 0x38ef4
movl 0x2fb58(%rip), %ecx     # 0x3634c
testl %eax, %eax
jne 0x681b
testl %ecx, %ecx
jle 0x681b
cmpl $0x0, 0x2fb2d(%rip)     # 0x36330
jne 0x681b
movl $0x2bc, 0x326e1(%rip)   # imm = 0x2BC
leaq 0x316da(%rip), %rbx     # 0x37ef0
jmp 0x666d
testl %eax, %eax
setg %al
testl %ecx, %ecx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
leaq 0x316bf(%rip), %rbx     # 0x37ef0
jne 0x666d
andl $0x0, 0x326b2(%rip)     # 0x38ef0
andl $0x0, 0x326af(%rip)     # 0x38ef4
jmp 0x666d
cmpb $0x1, 0x305f4(%rip)     # 0x36e45
jne 0x685f
leaq 0x26548(%rip), %rdi     # 0x2cda2
callq 0x2440
cmpq $0x0, 0x31559(%rip)     # 0x37dc0
jne 0x6873
movl $0x1, 0x2fad5(%rip)     # 0x36348
cmpb $0x1, 0x305cb(%rip)     # 0x36e45
jne 0x6888
leaq 0x26524(%rip), %rdi     # 0x2cda7
callq 0x2440
movl 0x2faba(%rip), %eax     # 0x36348
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq