explicitClick to confirm you are 18+

ChatGpt Cock Magic

TheJollyLaMaMay 11, 2023, 12:44:59 PM
thumb_up5thumb_downmore_vert

πŸ πŸ”†πŸ’‘πŸŒ³πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ πŸŒπŸ πŸ”†πŸ’‘πŸŒ³πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ 
🌍 πŸŒπŸ”†πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ πŸŒπŸŒπŸŒπŸ”†πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘
πŸ”†πŸ πŸŒ πŸŒπŸ”†πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ πŸŒπŸŒπŸŒπŸ”†πŸ’‘πŸ πŸŒ³
πŸŒ³πŸ’‘πŸ”†πŸ πŸŒ πŸŒπŸ”†πŸ’‘πŸŒ³πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸŒπŸŒπŸŒπŸ”†πŸ’‘πŸŒ³
πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸŒπŸŒ πŸŒπŸŒπŸ”†πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸŒπŸŒπŸŒπŸŒπŸ”†
πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸŒ πŸŒπŸŒπŸ”†πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸŒπŸŒπŸŒπŸŒ
πŸ”†πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸŒ πŸŒπŸ”†πŸ’‘πŸŒ³πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ πŸŒπŸŒ
πŸ”†πŸ’‘πŸŒ³πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ πŸŒ πŸŒπŸ”†πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ πŸŒ
πŸŒπŸ”†πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ πŸŒ πŸŒπŸ”†πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ 
πŸŒπŸŒπŸ”†πŸ’‘πŸ πŸŒ³πŸŒ³πŸ’‘πŸ”†πŸ πŸŒ πŸŒπŸ”†πŸ’‘πŸŒ³πŸŒ³πŸŒ³πŸ’‘πŸ”†

Decent Smart Home Arduino Algorithm: 


void TheMainProgram () { event_msg="The Main Program: "; getBridgeVariables(); if (true){ //(EPO_state < 1) /* ***** The MAIN PROGRAM ***** */ // event_msg+="Charge available, Running The Main Program."; // event_msg+="Line To House is ON."; // if(charging_state != "NIGHT"){event_msg+="Cloudy Moment Check:";CloudyMomentCheck();} // event_log(event_msg);delay(1000); // event_msg.remove(0); /* *****Environment Control***** (garden programs ) */ sun();delay(200);rain();delay(200);wind();delay(200); //earth();data(ether);energyMonitor(); // data is sent to various relevant blockchains accordingly to satisify the ether tone // supply chain, asset usage accounting, weatherlink, crop management, energy allocation specs, etc. // put on public ledger event_msg+="Completed Sun, Rain, and Wind Programs."; // if (charging_state == "FLOAT") { // PowerDiverter(); // event_msg+="Plenty of power coming in. Charge State in FLOAT."; // } // if (charging_state == "ABSORPTION") { // PowerDiverter(); // event_msg+="Plenty of power coming in. Charge State in ABSORPTION."; // } }else{ event_msg+="Emergency Power Override State is affirmative. "; //battery bank is low and EPO_state is already 1 if (charging_state == "NIGHT"){ event_msg+="It's night time! Trying to sleep! "; if (charge_percentage <= 0 && bat_V <= 48 ) { event_msg+="Battery all used up! Running datalog and taking a nap. "; // while Emergency Power Override program is triggered // and it's NIGHT OR the charging is low // take a 10 second nap. Go to sleep. // subconcious activities continue delay(10000); }else{ event_msg+="still got juice. Resetting Emergency Power Override. "; Bridge.put("EmergencyPowerOverride", String(0)); } }else if (charging_state == "MPPT"){ if (chg_cur > 15.00){ event_msg+="Looks like there's charge out there! Things should be up and running soon! Let's try ... "; Bridge.put("EmergencyPowerOverride", String(0)); }else{ event_msg+="EPO on but there's a trickle charge coming in. Sunrise or Sunset conditions ... "; } }else{ // Default condition to force loop if not NIGHT and not MPPT but Emergency Power Override is on for some reason Bridge.put("EmergencyPowerOverride", String(0)); event_msg+="It's not Night, charger not in MPPT. Not sure what's going on ... "; event_msg+="Emergency Power Override set back to 0."; } event_log(event_msg);delay(1000); event_msg.remove(0); } } 

can you please critique this chunk of the smarthome algo chatgpt?


Certainly! Here are some critiques and suggestions for the provided chunk of the smart home algorithm: 1. Code organization: It appears that the code is commented out extensively, which makes it difficult to follow the flow of the program. Consider removing unnecessary comments or uncommenting the relevant sections to improve readability. 2. Variable naming: It's unclear what some of the variables represent, such as `EPO_state`, `charging_state`, `bat_V`, etc. Using more descriptive variable names will make the code easier to understand and maintain. 3. Event logging: The code contains calls to `event_log(event_msg)` for logging events. It would be helpful to know how the `event_log` function is implemented and where the logs are stored. Consider providing more details about the event logging mechanism. 4. Redundant condition: In the `if (true)` statement, the condition is hardcoded as `true`. It's advisable to use meaningful conditions based on the desired logic. 5. Lack of clarity: Some sections of the code are unclear and may require further explanation or documentation to understand their purpose. For example, the `sun()`, `rain()`, and `wind()` functions, as well as the data sent to various blockchains, could benefit from additional comments or explanations. 6. Unused code: Several sections of code are currently commented out, such as the charging state checks (`if (charging_state == "FLOAT")` and `if (charging_state == "ABSORPTION")`). If these sections are not needed, it's recommended to remove them to avoid confusion. 7. Inconsistent use of braces: The opening and closing braces of the `if` statement do not match. Make sure to use consistent indentation and brace placement for better code readability. 8. Magic numbers: Some numerical values, such as `15.00` and `48`, are hardcoded without clear explanations. Consider assigning these values to named constants or providing comments to clarify their meaning. 9. Exception handling: The code does not include any exception handling mechanisms. It's good practice to include error handling and fallback options to handle unexpected scenarios and ensure the stability of the smart home system. 10. Lack of modularity: The code seems to have a monolithic structure, making it harder to understand and maintain. Consider breaking it down into smaller, modular functions that handle specific tasks. This will improve code organization, reusability, and testability. Remember to thoroughly test the algorithm and consider the specific requirements of your smart home system to ensure its effectiveness and reliability.

can you give it good exception handling please?


Certainly! Here's an updated version of the code with exception handling added:

```cpp
void TheMainProgram() {
   try {
       event_msg = "The Main Program: ";
       getBridgeVariables();
       
       if (true) {
           // ***** The MAIN PROGRAM *****
           
           // Charge available, running The Main Program
           // Line To House is ON
           // if (charging_state != "NIGHT") { CloudyMomentCheck(); }
           event_msg += "Charge available, Running The Main Program.";
           event_msg += "Line To House is ON.";
           event_log(event_msg);
           delay(1000);
           event_msg.remove(0);
           
           // ***** Environment Control (garden programs) *****
           sun();
           delay(200);
           rain();
           delay(200);
           wind();
           delay(200);
           
           // earth();
           // data(ether);
           // energyMonitor();
           
           // Data is sent to various relevant blockchains accordingly to satisfy the ether tone
           // Supply chain, asset usage accounting, weatherlink, crop management, energy allocation specs, etc.
           // Put on public ledger
           event_msg += "Completed Sun, Rain, and Wind Programs.";
       }
       else {
           event_msg += "Emergency Power Override State is affirmative.";
           
           if (charging_state == "NIGHT") {
               event_msg += "It's night time! Trying to sleep!";
               
               if (charge_percentage <= 0 && bat_V <= 48) {
                   event_msg += "Battery all used up! Running datalog and taking a nap.";
                   // While Emergency Power Override program is triggered 
                   // and it's NIGHT OR the charging is low
                   // Take a 10 second nap. Go to sleep.
                   // Subconscious activities continue
                   delay(10000);
               }
               else {
                   event_msg += "Still got juice. Resetting Emergency Power Override.";
                   Bridge.put("EmergencyPowerOverride", String(0));
               }
           }
           else if (charging_state == "MPPT") {
               if (chg_cur > 15.00) {
                   event_msg += "Looks like there's charge out there! Things should be up and running soon! Let's try...";
                   Bridge.put("EmergencyPowerOverride", String(0));
               }
               else {
                   event_msg += "EPO on but there's a trickle charge coming in. Sunrise or Sunset conditions...";
               }
           }
           else {
               // Default condition to force loop if not NIGHT and not MPPT but Emergency Power Override is on for some reason
               Bridge.put("EmergencyPowerOverride", String(0));
               event_msg += "It's not Night, charger not in MPPT. Not sure what's going on...";
               event_msg += "Emergency Power Override set back to 0.";
           }
           
           event_log(event_msg);
           delay(1000);
           event_msg.remove(0);
       }
   }
   catch (const std::exception& e) {
       // Exception handling
       event_msg = "An exception occurred: ";
       event_msg += e.what();
       event_log(event_msg);
   }
   catch (...) {
       event_msg = "An unknown exception occurred.";
       event_log(event_msg);
   }
}
```

In this updated code, a `try-catch` block is used to catch exceptions. If an exception occurs, it is caught and logged in the `event_log` function, providing information about the exception. The first `catch` block handles standard exceptions (`std::exception`), while the second `catch` block catches any other unknown exceptions.

Make sure to adapt the exception handling code based on the specific exceptions or error conditions that can occur in your smart home system.

Thanks ChatGpt - U so Freaky 
 

πŸ”†πŸ”†πŸ”†πŸ’‘πŸ πŸ”†πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ πŸ’‘πŸ’‘πŸ’‘πŸ”†πŸ”†πŸ”† πŸ”†πŸ’‘
πŸ πŸ πŸ”†πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ πŸ πŸ’‘πŸ”† πŸ”†πŸ’‘πŸ πŸ”†πŸ’‘
πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ”† πŸ”†πŸ’‘πŸ πŸ”†πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘
πŸ’‘πŸ’‘πŸ’‘πŸ πŸ”†πŸ”† πŸ”†πŸ”†πŸ”†πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ πŸ’‘
πŸ”†πŸ”† πŸ”†πŸ’‘πŸ πŸ”†πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ πŸ”†πŸ”† πŸ”†πŸ’‘
πŸ πŸ”†πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ”† πŸ”†πŸ’‘πŸ πŸ πŸ”†πŸ’‘πŸ’‘
πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ πŸ’‘πŸ”† πŸ”†πŸ’‘πŸ πŸ πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘
πŸ’‘πŸ πŸ’‘πŸ”† πŸ”†πŸ”†πŸ”†πŸ’‘πŸ πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ πŸ’‘πŸ’‘πŸ”†