Announcement

Collapse
No announcement yet.

Help converting C struct to PB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help converting C struct to PB

    I need help converting the following to something more PowerBasic:

    Code:
    typedef struct tagAER_TASK_STATUS
    
    {
    
    union 
    
    { 
    
    DWORD dwMask; 
    
    struct 
    
    { 
    
    unsigned ProgramAssociated:1;         // 0  
    
    unsigned ProgramActive:1;             // 1  
    
    unsigned ProgramExecuting:1;          // 2  
    
    unsigned ImmediateCodeExecuting:1;    // 3  
    
    unsigned ReturnMotionExecuting:1;     // 4  
    
    unsigned ProgramAborted:1;            // 5  
    
    unsigned SingleStepInto:1;            // 6  
    
    unsigned SingleStepOver:1;            // 7  
    
    unsigned ProgramReset:1;              // 8  
    
    unsigned PendingAxesStop:1;           // 9  
    
    unsigned EStopActive:1;               // 10  
    
    unsigned FeedHoldActive:1;            // 11  
    
    unsigned CallBackHoldActive:1;        // 12  
    
    unsigned CallBackResponding:1;        // 13  
    
    unsigned SpindleActive:MAX_SPINDLES;  // 14->17  
    
    unsigned ProbeCycle:1;                // 18  
    
    unsigned Retrace:1;                   // 19  
    
    unsigned Spare1:1;                    // 20  
    
    unsigned InterruptMotionActive:1;     // 21  
    
    unsigned SlewActive:1;                // 22  
    
    unsigned CornerRounding:1;            // 23  
    
    unsigned ROReq1Active:1;              // 24  
    
    unsigned Spare2:1;                    // 25  
    
    unsigned CannedFunctionActive:1;      // 26  
    
    unsigned CannedFunctionExecuting:1;   // 27  
    
    unsigned Spare3:1;                    // 28  
    
    unsigned Spare4:1;                    // 29  
    
    unsigned Spare5:1;                    // 30  
    
    unsigned Spare6:1;                    // 31  
    
    } Bit; 
    
    } DW1;
    Thanks in advance,
    Ryan
    Thank you,
    Ryan M. Cross

  • #2
    Code:
    %MAX_SPINDLES = 4
      
    Type STRUCT_AER_TASK_STATUS
      ProgramAssociated         As Bit * 1 In Dword
      ProgramActive             As Bit * 1
      ProgramExecuting          As Bit * 1
      ImmediateCodeExecuting    As Bit * 1
      ReturnMotionExecuting     As Bit * 1
      ProgramAborted            As Bit * 1
      SingleStepInto            As Bit * 1
      SingleStepOver            As Bit * 1
      ProgramReset              As Bit * 1
      PendingAxesStop           As Bit * 1
      EStopActive               As Bit * 1
      FeedHoldActive            As Bit * 1
      CallBackHoldActive        As Bit * 1
      CallBackResponding        As Bit * 1
      SpindleActive             As Bit * %MAX_SPINDLES
      ProbeCycle                As Bit * 1
      Retrace                   As Bit * 1
      Spare1                    As Bit * 1
      InterruptMotionActive     As Bit * 1
      SlewActive                As Bit * 1
      CornerRounding            As Bit * 1
      ROReq1Active              As Bit * 1
      Spare2                    As Bit * 1
      CannedFunctionActive      As Bit * 1
      CannedFunctionExecuting   As Bit * 1
      Spare3                    As Bit * 1
      Spare4                    As Bit * 1
      Spare5                    As Bit * 1
      Spare6                    As Bit * 1
    End Type
     
    Union AER_TASK_STATUS
      DwMask As Dword
      STRUCT_AER_TASK_STATUS
    End Union
    ------------------
    Regards,
    Peter

    [This message has been edited by Peter Lameijn (edited March 05, 2007).]
    Regards,
    Peter

    Comment


    • #3
      I made a mistake this is what I was actually asking for, I just didn't copy and paste. I tried doing it myself from your example, let me know how wrong I am:
      Code:
      typedef struct tagAER_TASK_STATUS
      {
      
      union 
      { 
      DWORD dwMask; 
      struct 
      { 
      unsigned ProgramAssociated:1;         // 0  
      unsigned ProgramActive:1;             // 1  
      unsigned ProgramExecuting:1;          // 2  
      unsigned ImmediateCodeExecuting:1;    // 3  
      unsigned ReturnMotionExecuting:1;     // 4  
      unsigned ProgramAborted:1;            // 5  
      unsigned SingleStepInto:1;            // 6  
      unsigned SingleStepOver:1;            // 7  
      unsigned ProgramReset:1;              // 8  
      unsigned PendingAxesStop:1;           // 9  
      unsigned EStopActive:1;               // 10  
      unsigned FeedHoldActive:1;            // 11  
      unsigned CallBackHoldActive:1;        // 12  
      unsigned CallBackResponding:1;        // 13  
      unsigned SpindleActive:MAX_SPINDLES;  // 14->17  
      unsigned ProbeCycle:1;                // 18  
      unsigned Retrace:1;                   // 19  
      unsigned Spare1:1;                    // 20  
      unsigned InterruptMotionActive:1;     // 21  
      unsigned SlewActive:1;                // 22  
      unsigned CornerRounding:1;            // 23  
      unsigned ROReq1Active:1;              // 24  
      unsigned Spare2:1;                    // 25  
      unsigned CannedFunctionActive:1;      // 26  
      unsigned CannedFunctionExecuting:1;   // 27  
      unsigned Spare3:1;                    // 28  
      unsigned Spare4:1;                    // 29  
      unsigned Spare5:1;                    // 30  
      unsigned Spare6:1;                    // 31  
      } Bit; 
      } DW1; 
      
      union 
      { 
      DWORD dwMask; 
      struct 
      { 
      unsigned Spare1:1;                    // 0  
      unsigned Spare2:1;                    // 1  
      unsigned Spare3:1;                    // 2  
      unsigned Spare4:1;                    // 3  
      unsigned MSOChange:1;                 // 4  
      unsigned SpindleFeedHeld:1;           // 5  
      unsigned Spare:1;                     // 6  
      unsigned CutterEnabling:1;            // 7  
      unsigned CutterDisabling:1;           // 8  
      unsigned CutterOffsetsEnablingPos:1;  // 9  
      unsigned CutterOffsetsEnablingNeg:1;  // 10  
      unsigned CutterOffsetsDisabling:1;    // 11  
      unsigned MFOChange:1;                 // 12  
      unsigned InterruptFaultPending:1;     // 13  
      unsigned InterruptCallBackPending:1;  // 14  
      unsigned OnGosubPending:1;            // 15  
      unsigned ProgramAbortPending:1;       // 16  
      unsigned CannedFunctionPending:1;     // 17  
      unsigned Spare6:1;                    // 18  
      unsigned Spare7:1;                    // 19  
      unsigned Spare8:1;                    // 20  
      unsigned Spare9:1;                    // 21  
      unsigned Spare10:1;                   // 22  
      unsigned Spare11:1;                   // 23  
      unsigned Spare12:1;                   // 24  
      unsigned Spare13:1;                   // 25  
      unsigned Spare14:1;                   // 26  
      unsigned Spare15:1;                   // 27  
      unsigned Spare16:1;                   // 28  
      unsigned Spare17:1;                   // 29  
      unsigned Spare18:1;                   // 30  
      unsigned Spare19:1;                   // 31  
      } Bit; 
      } DW2; 
      
      union 
      { 
      DWORD dwMask; 
      struct 
      { 
      unsigned RotationActive:1;            // 0  
      unsigned RThetaPolarActive:1;         // 1  
      unsigned RThetaCylindricalActive:1;   // 2  
      unsigned ScalingActive:1;             // 3  
      unsigned OffsetFixtureActive:1;       // 4  
      unsigned ProfileActive:1;             // 5  
      unsigned MotionTypePtToPt:1;          // 6  
      unsigned MotionTypeInterp:1;          // 7  
      unsigned MotionTypeProfilePoint:1;    // 8  
      unsigned MotionContinuous:1;          // 9  
      unsigned MotionNoAccel:1;             // 10  
      unsigned Spare1:1;                    // 11  
      unsigned CutterOffsetsActivePos:1;    // 12  
      unsigned CutterActiveLeft:1;          // 13  
      unsigned CutterActiveRight:1;         // 14  
      unsigned CutterOffsetsActiveNeg:1;    // 15  
      unsigned NormalcyActiveLeft:1;        // 16  
      unsigned NormalcyActiveRight:1;       // 17  
      unsigned NormalcyAlignment:1;         // 18  
      unsigned MotionTypeCW:1;              // 19  
      unsigned MotionTypeCCW:1;             // 20  
      unsigned LimitFeedRateActive:1;       // 21  
      unsigned LimitMFOActive:1;            // 22  
      unsigned Coord1Plane1:1;              // 23  
      unsigned Coord1Plane2:1;              // 24  
      unsigned Coord1Plane3:1;              // 25  
      unsigned Coord2Plane1:1;              // 26  
      unsigned Coord2Plane2:1;              // 27  
      unsigned Coord2Plane3:1;              // 28  
      unsigned Spare2:1;                    // 29  
      unsigned MirrorActive:1;              // 30  
      unsigned Spare3:1;                    // 31  
      } Bit; 
      } DW3; 
      } AER_TASK_STATUS;
      Here's mine:

      Code:
      Type STRUCT_AER_TASK_STATUS_DW1
        ProgramAssociated         As Bit * 1 In Dword
        ProgramActive             As Bit * 1
        ProgramExecuting          As Bit * 1
        ImmediateCodeExecuting    As Bit * 1
        ReturnMotionExecuting     As Bit * 1
        ProgramAborted            As Bit * 1
        SingleStepInto            As Bit * 1
        SingleStepOver            As Bit * 1
        ProgramReset              As Bit * 1
        PendingAxesStop           As Bit * 1
        EStopActive               As Bit * 1
        FeedHoldActive            As Bit * 1
        CallBackHoldActive        As Bit * 1
        CallBackResponding        As Bit * 1
        SpindleActive             As Bit * %MAX_SPINDLES
        ProbeCycle                As Bit * 1
        Retrace                   As Bit * 1
        Spare1                    As Bit * 1
        InterruptMotionActive     As Bit * 1
        SlewActive                As Bit * 1
        CornerRounding            As Bit * 1
        ROReq1Active              As Bit * 1
        Spare2                    As Bit * 1
        CannedFunctionActive      As Bit * 1
        CannedFunctionExecuting   As Bit * 1
        Spare3                    As Bit * 1
        Spare4                    As Bit * 1
        Spare5                    As Bit * 1
        Spare6                    As Bit * 1
      End Type
      
      Type STRUCT_AER_TASK_STATUS_DW2
        Spare1				   As Bit * 1 In Dword
        Spare2             	   As Bit * 1
        Spare3                    As Bit * 1
        Spare4                    As Bit * 1  
        MSOChange                 As Bit * 1
        SpindleFeedHeld           As Bit * 1
        Spare                     As Bit * 1 
        CutterEnabling            As Bit * 1
        CutterDisabling           As Bit * 1
        CutterOffsetsEnablingPos  As Bit * 1 
        CutterOffsetsEnablingNeg  As Bit * 1
        CutterOffsetsDisabling    As Bit * 1
        MFOChange                 As Bit * 1
        InterruptFaultPending     As Bit * 1 
        InterruptCallBackPending  As Bit * 1
        OnGosubPending            As Bit * 1 
        ProgramAbortPending       As Bit * 1 
        CannedFunctionPending     As Bit * 1
        Spare6                    As Bit * 1 
        Spare7                    As Bit * 1 
        Spare8                    As Bit * 1
        Spare9                    As Bit * 1
        Spare10                   As Bit * 1
        Spare11                   As Bit * 1
        Spare12                   As Bit * 1
        Spare13                   As Bit * 1 
        Spare14                   As Bit * 1
        Spare15                   As Bit * 1
        Spare16                   As Bit * 1
        Spare17                   As Bit * 1
        Spare18                   As Bit * 1
        Spare19                   As Bit * 1
      End Type
      
      Type STRUCT_AER_TASK_STATUS_DW3
        RotationActive	        As Bit * 1 In Dword
        RThetaPolarActive	        As Bit * 1
        RThetaCylindricalActive   As Bit * 1
        ScalingActive	        As Bit * 1 
        OffsetFixtureActive	   As Bit * 1
        ProfileActive	        As Bit * 1
        MotionTypePtToPt	        As Bit * 1
        MotionTypeInterp	        As Bit * 1
        MotionTypeProfilePoint	   As Bit * 1
        MotionContinuous	        As Bit * 1 
        MotionNoAccel	        As Bit * 1
        Spare1	                  As Bit * 1
        CutterOffsetsActivePos	   As Bit * 1
        CutterActiveLeft	        As Bit * 1
        CutterActiveRight	        As Bit * 1
        CutterOffsetsActiveNeg	   As Bit * 1 
        NormalcyActiveLeft	   As Bit * 1 
        NormalcyActiveRight	   As Bit * 1
        NormalcyAlignment	        As Bit * 1
        MotionTypeCW	             As Bit * 1
        MotionTypeCCW	        As Bit * 1
        LimitFeedRateActive	   As Bit * 1 
        LimitMFOActive	        As Bit * 1 
        Coord1Plane1	             As Bit * 1
        Coord1Plane2	             As Bit * 1
        Coord1Plane3	             As Bit * 1
        Coord2Plane1	             As Bit * 1 
        Coord2Plane2	             As Bit * 1 
        Coord2Plane3	             As Bit * 1
        Spare2	                  As Bit * 1
        MirrorActive	             As Bit * 1 
        Spare3	                  As Bit * 1
      End Type
       
      Union AER_TASK_STATUS
        DwMask As Dword
        STRUCT_AER_TASK_STATUS_DW1
        STRUCT_AER_TASK_STATUS_DW2
        STRUCT_AER_TASK_STATUS_DW3
      End Union
      Thanks again.
      Thank you,
      Ryan M. Cross

      Comment


      • #4
        I think this is what you need:
        Code:
        Union UNION_DW1
          DwMask       As Dword
          ATS          As STRUCT_AER_TASK_STATUS_DW1
        End Union
         
        Union UNION_DW2
          DwMask       As Dword
          ATS          AS STRUCT_AER_TASK_STATUS_DW2
        End Union
         
        Union UNION_DW3
          DwMask       As Dword
          ATS          As STRUCT_AER_TASK_STATUS_DW3
        End Union
         
        Type AER_TASK_STATUS
          DW1 As UNION_DW1
          DW2 As UNION_DW2
          DW3 As UNION_DW3
        End Type
        ------------------
        Regards,
        Peter



        [This message has been edited by Peter Lameijn (edited March 05, 2007).]
        Regards,
        Peter

        Comment


        • #5
          thank you very much
          Thank you,
          Ryan M. Cross

          Comment

          Working...
          X