@name DataSignal Test Receive
@inputs CS:wirelink
@outputs 
@persist 
@trigger 

#TEMPLATE

if(first() | dsClk())
{
    CS[2041] = 1
}

dsJoinGroup("Radio")
dsSetScope(2)

CS:writeString("Receive Scope: " + dsGetScope(),0,0)
CS:writeString("Receive Group: " + dsGetGroups()[1,string],0,1)

Type = dsGetType()

if(Type)
{
    CS:writeString("Received:",0,3)
    if(Type == "string")
    {
        CS:writeString(dsGetString(),0,4)
        soundPlay("hax",0,dsGetString())
        CS:writeString("Duration: " + soundDuration(dsGetString()),0,16)
    }
    elseif(Type == "number")
    {
        CS:writeString(dsGetNumber():toString(),0,4)
    }
    elseif(Type == "quaternion")
    {
        CS:writeString(dsGetQuaternion():toString(),0,4)
    }
    elseif(Type == "complex")
    {
        CS:writeString(dsGetComplex():toString(),0,4)
    }
    elseif(Type == "vector2")
    {
        CS:writeString(dsGetVector2():toString(),0,4)
    }
    elseif(Type == "vector")
    {
        CS:writeString(dsGetVector():toString(),0,4)
    }
    elseif(Type == "vector4")
    {
        CS:writeString(dsGetVector4():toString(),0,4)
    }
    elseif(Type == "angle")
    {
        CS:writeString(dsGetAngle():toString(),0,4)
    }
    elseif(Type == "array")
    {
        #CS:writeString(dsGetArray(),0,4)
    }
    elseif(Type == "table")
    {
        #CS:writeString(dsGetTable(),0,4)
    }
    elseif(Type == "matrix2")
    {
        #CS:writeString(dsGetMatrix2(),0,4)
    }
    elseif(Type == "matrix")
    {
        #CS:writeString(dsGetMatrix(),0,4)
    }
    elseif(Type == "matrix4")
    {
        #CS:writeString(dsGetMatrix4(),0,4)
    }
    
    CS:writeString("Received Type: " + Type,0,5)
    CS:writeString("Received Singal: " + dsClkName(),0,6)
    CS:writeString("Received Group: " + dsGetGroup(),0,7)
    CS:writeString("Sender:",0,8)
    CS:writeString(dsGetSender():toString(),0,9)
}
