a.binder 5 anni fa
parent
commit
5d7b93da12

+ 13 - 0
SE/stuff/P5_Automation_can-dev/P5_Automation_can-dev.xpr

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="22.0">
+    <meta>
+        <filters directoryPatterns="" filePatterns="\QP5_Automation_can-dev.xpr\E" positiveFilePatterns="" showHiddenFiles="false"/>
+        <options/>
+    </meta>
+    <projectTree name="P5_Automation_can-dev.xpr">
+        <folder name="Arduino">
+            <folder path="../../../../Arduino/"/>
+        </folder>
+        <folder path="."/>
+    </projectTree>
+</project>

+ 133 - 0
SE/stuff/P5_Automation_can-dev/Slave_Ports_Status.cpp

@@ -0,0 +1,133 @@
+#include "Slave_Ports_Status.h"
+
+/*Slave_Ports_Status::Slave_Ports_Status(Client& client) : m_client(client) {
+    m_accountName = NULL;
+    m_appKeyName = NULL;
+    m_appKeyValue = NULL;
+    m_path = NULL;
+    m_nextChar = NULL;
+    m_nextState = END;
+}
+*/
+
+/*
+Slave_Ports_Status::Slave_Ports_Status(Client& client) : m_client(client) {
+    m_accountName = NULL;
+    m_appKeyName = NULL;
+    m_appKeyValue = NULL;
+    m_path = NULL;
+    m_nextChar = NULL;
+    m_nextState = END;
+}
+*/
+/*
+
+void Slave_Ports_Status::push() { //
+
+
+}
+*/
+
+
+
+Slave_Ports_Status::Slave_Ports_Status(){
+    Serial.print("#35 Slave_Ports_Status::Slave_Ports_Status():");
+    _count = 0 ;
+    //Slave_Ports_Status_T Slave_Ports_Status_A[10];
+}
+
+
+
+/*
+inline int Slave_Ports_Status::add(Slave_Ports_Status_T item)
+{
+  
+  Serial.print("Add item...  _count["); Serial.print(item.Port_ID);
+  
+   Serial.print("] 0 ["); Serial.print(item.Port_ID);
+   Serial.print("1 ["); Serial.print(item._Slave_ID);
+   Serial.print("2 ["); Serial.print(item.PortTypes);
+   Serial.print("3 ["); Serial.print(item.Address);
+   Serial.print("4 ["); Serial.print(item.LocalPort);
+   Serial.print("5 ["); Serial.print(item.Exp_state);
+   Serial.print("6 ["); Serial.print(item.Exp_state_ttl);
+   Serial.print("7 ["); Serial.print(item.Broadcast_state);
+   Serial.println("]"); 
+   
+   return 1 ;
+}
+*/
+
+ void Slave_Ports_Status::add_port(
+                int  Port_ID,
+                int  _Slave_ID,
+                int  PortTypes,
+                int  Address,
+                int  LocalPort,
+                int  Exp_state,
+                int  Exp_state_ttl,
+                int  Broadcast_state
+                )
+{
+  
+  Serial.print("add_port   _count["); Serial.print(_count);
+   Serial.print("] Port_ID["); Serial.print(Port_ID);
+   Serial.print("] _Slave_ID[0x"); Serial.print( _Slave_ID, HEX );
+   Serial.print("] PortTypes["); Serial.print(PortTypes, HEX);
+   Serial.print("] Address["); Serial.print(Address, HEX);
+   Serial.print("] LocalPort["); Serial.print(LocalPort, HEX);
+   Serial.print("] Exp_state["); Serial.print(Exp_state, HEX);
+   Serial.print("] Exp_state_ttl["); Serial.print(Exp_state_ttl, HEX);
+   Serial.print("] Broadcast_state["); Serial.print(Broadcast_state, HEX);
+   Serial.println("]"); 
+    //Slave_Ports_Status_A[_count + 1].Port_ID = Port_ID ;
+    
+    
+    this->Slave_Ports_Status_A[_count + 1].Port_ID = Port_ID ;
+    this->Slave_Ports_Status_A[_count + 1]._Slave_ID = _Slave_ID ;
+    this->Slave_Ports_Status_A[_count + 1].PortTypes = PortTypes ;
+    this->Slave_Ports_Status_A[_count + 1].Address = Address ;
+    this->Slave_Ports_Status_A[_count + 1].LocalPort = LocalPort ;
+    this->Slave_Ports_Status_A[_count + 1].Exp_state = Exp_state ;
+    this->Slave_Ports_Status_A[_count + 1].Broadcast_state = Broadcast_state ;
+  
+    this->_count ++;
+  
+}
+
+
+bool Slave_Ports_Status::add_empty()
+{
+  Serial.println("add_empty");
+}
+
+
+void Slave_Ports_Status::list_ports()
+{
+  Serial.print("list_ports   _count["); Serial.print(_count); Serial.println("] ");
+    int i;
+    for(i=1;i<=_count;i++) {
+ 
+         Serial.print(" #IND["); Serial.print(i); 
+         Serial.print("] Port_ID["); Serial.print(Slave_Ports_Status_A[i].Port_ID, HEX);
+         Serial.print("] _Slave_ID[0x"); Serial.print( Slave_Ports_Status_A[i]._Slave_ID, HEX );
+         Serial.print("] PortTypes["); Serial.print(Slave_Ports_Status_A[i].PortTypes, HEX);
+         Serial.print("] Address["); Serial.print(Slave_Ports_Status_A[i].Address, HEX);
+         Serial.print("] LocalPort["); Serial.print(Slave_Ports_Status_A[i].LocalPort, HEX);
+         Serial.print("] Exp_state["); Serial.print(Slave_Ports_Status_A[i].Exp_state, HEX);
+         Serial.print("] Exp_state_ttl["); Serial.print(Slave_Ports_Status_A[i].Exp_state_ttl, HEX);
+         Serial.print("] Broadcast_state["); Serial.print(Slave_Ports_Status_A[i].Broadcast_state, HEX);
+         Serial.println("]"); 
+         
+   }
+   
+   
+}
+
+
+
+Slave_Ports_Status::~Slave_Ports_Status(){
+     delete[] Slave_Ports_Status_A;
+    //Serial.print("#40 free ~Slave_Ports_Status");
+}
+

+ 153 - 0
SE/stuff/P5_Automation_can-dev/Slave_Ports_Status.h

@@ -0,0 +1,153 @@
+
+#ifndef SLAVE_PORTS_STATUS_H
+#define SLAVE_PORTS_STATUS_H
+
+
+#include <Arduino.h>
+
+
+            
+            #ifndef voidfuncptr_t
+            #define voidfuncptr_t voidfuncptr_t
+            typedef void (*voidfuncptr_t)(void); // void function pointer typedef
+            #endif
+            
+            
+            
+            #ifndef vfp_vpu32b_t
+            #define vfp_vpu32b_t vfp_vpu32b_t
+            typedef void (*vfp_vpu32b_t)(void*, uint32_t, bool);
+            #endif
+
+
+ struct Slave_Ports_Status_S {
+  int  Port_ID ; //global id for device //const char * const _Protocol;
+  int  _Slave_ID; //Device which orginated port   //remote id - use FF for broadcast
+  int  PortTypes;  //0xFF  =  1111 1111 s
+                                          /*
+                                          {
+                                      bit 1 - PWM port
+                                      bit 2 - on I2C managed port
+                                      bit 3 - expanded port with LocalPort address
+                                      bit 4 - not allocated
+                                      bit 2 - not allocated
+                                      bit 5 - not allocated
+                                      bit 6 - not allocated
+                                      bit 7 - not allocated
+                                      bit 8 - not allocated
+                                    } 
+                                           */
+ // byte has_Address;
+  int  Address ;
+ // byte has_Local_Port;
+  int  LocalPort;
+  int  Exp_state;                  /*0xFF  =  1111 1111
+                                    0x00  =  0000 0000  = OFF = 0V
+                                    0x01  =  0000 0001  = ON = PWM max
+                                    {
+                                      bit 1 - OFF = 0V
+                                      bit 2 - ON = PWM max
+                                      bit 3 - not allocated
+                                      bit 4 - not allocated
+                                      bit 2 - not allocated
+                                      bit 5 - not allocated
+                                      bit 6 - not allocated
+                                      bit 7 - not allocated
+                                      bit 8 - not allocated
+                                    }*/
+  int  Exp_state_ttl;  // 0x00 = odswiezyc
+  int  Broadcast_state; //0x00 - not broadcast; 0x01
+} ;
+
+typedef struct Slave_Ports_Status_S Slave_Ports_Status_T;
+
+struct Slave_Ports_Status_LIST_S {
+       Slave_Ports_Status_T;
+};
+typedef struct Slave_Ports_Status_LIST_S Slave_Ports_Status_LIST_T;
+
+
+enum class Mode : uint8_t
+{
+  Normal     = 0x00,
+  Sleep      = 0x20,
+  Loopback   = 0x40,
+  ListenOnly = 0x60,
+  Config     = 0x80
+};
+
+
+
+class Slave_Ports_Status
+{
+
+
+private:
+    int _count;
+    Slave_Ports_Status *_data;
+    Slave_Ports_Status_LIST_T *Slave_Ports_Status_LIST_A;
+   
+//public:
+  //  static Slave_Ports_Status *first;
+    //static Slave_Ports_Status *_data;
+public:
+         Slave_Ports_Status_T *Slave_Ports_Status_A;
+        //  void push(Slave_Ports_Status_S const &item);
+          //void push();
+          //Slave_Ports_Status();
+          //  bool setMode();
+          //voidfuncptr_t func;					// address of coroutine function
+          Slave_Ports_Status();
+          
+         /* inline int add(
+            Slave_Ports_Status_LIST_T Slave_Ports_Status_LIST_A , 
+            Slave_Ports_Status_T Slave_Ports_Status_A
+            ) {
+            };
+            */
+          void add_port(
+                int  Port_ID,
+                int  _Slave_ID,
+                int  PortTypes,
+                int  Address,
+                int  LocalPort,
+                int  Exp_state,
+                int  Exp_state_ttl,
+                int  Broadcast_state
+                );
+          bool add_empty();
+          void list_ports();
+          ~Slave_Ports_Status();
+};
+
+
+/*
+class Slave_Ports_Status  {
+     private:
+    int _front, _back, _count;
+    T *_data;
+    int _maxitems;
+  public:
+    Queue(int maxitems = 256) { 
+      _front = 0;
+      _back = 0;
+      _count = 0;
+      _maxitems = maxitems;
+      _data = new T[maxitems + 1];   
+    }
+    ~Queue() {
+      delete[] _data;  
+    }
+    inline int count();
+    inline int front();
+    inline int back();
+ //   void push(const T &item);
+ //   T peek();
+ //   T pop();
+ //   void clear();
+ //   T pop_item(const T &item);
+}        
+
+*/
+
+#endif

+ 3 - 0
SE/stuff/P5_Automation_can-dev/_Slave_Ports.cpp

@@ -0,0 +1,3 @@
+//#include "_Slave_Ports.h"
+//#include <string.h>
+//#include <SoftwareSerial.h>

+ 7 - 0
SE/stuff/P5_Automation_can-dev/_Slave_Ports_LOCAL_LIST.h

@@ -0,0 +1,7 @@
+
+Slave_Ports_Status  Slave_Ports_Status_C;
+
+
+Slave_Ports_Status_C.add_port( 1, Active_ControllerID, 0x01, 0x00, 1, 0x01, 0x01, 0x01);
+Slave_Ports_Status_C.add_port( 2, Active_ControllerID, 0x01, 0x00, 1, 0x01, 0x01, 0x01);
+