From faba6b022b86f066d95b1cfdf752573724d5fbcd Mon Sep 17 00:00:00 2001
From: chenlh <2008get@163.com>
Date: 星期五, 29 八月 2025 19:08:13 +0800
Subject: [PATCH] 常规提交

---
 src/scene.cpp |   74 ++++++++++++++++++++++++-------------
 1 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/src/scene.cpp b/src/scene.cpp
index e0cf1b2..13a930b 100644
--- a/src/scene.cpp
+++ b/src/scene.cpp
@@ -4,6 +4,7 @@
  *  Created on: 2025年7月21日
  *      Author: 86189
  */
+#include <stdio.h>
 #include <cstdlib>
 #include <cstring>
 #include "config.h"
@@ -14,7 +15,7 @@
 #include "moduleexport.h"
 #include "crc.h"
 
-s32 Scene::str_delim(const s8* str, u8 logic_channel[])
+s32 Scene::str_delim(const s8* str, u16 logic_channel[])
 {
 	s8 pstr[32];
 	s8 * ptr;
@@ -30,7 +31,8 @@
 
 		ptr = strtok(NULL, "-");
 		end = atoi(ptr);
-		while (start<=end)
+		if(start==end) return 0;
+		while (start <= end)
 		{
 			logic_channel[i++] = start++;
 		}
@@ -49,24 +51,27 @@
 
 
 
-s32 Scene::convert_to_bin(s8* bin)
+s32 Scene::convert_to_bin(u8* bin)
 {
 	s32 i ,j;
 	struct FlowChartHead* flowchart = (struct FlowChartHead*)bin;
 	u32 size =  sizeof(struct FlowChartHead);
 	s32 ninports,noutports;
-	u8 rxBufID[64],txBufID[64];
+	u16 rxBufID[64],txBufID[64];
+	u32 dsp_index ;
 
 	u16 dsp_input_num[2] ={0,0};
 	u16 dsp_output_num[2] ={0,0};
 
 	s32 crc = 0xFFFFFFFF;
-
 	if (!bin) return 0;
 
+	struct Module *m  = (struct Module *)(bin + size);
+	printf("proc list size %d\n", proc_list.size());
+
 	for (i=0; i< proc_list.size(); i++) {
-		struct Module *m  = (struct Module *)(bin + size);
-		struct proc_field * p = &proc_list[i];
+		Module *m  = (struct Module *)(bin + size);
+		proc_field * p = &proc_list[i];
 
 		ninports = str_delim(p->inportstr, rxBufID) ;
 		noutports = str_delim(p->outportstr , txBufID) ;
@@ -79,7 +84,7 @@
 		if(p->proc_type == PROC_DUCKER || p->proc_type == PROC_CONTINUNOUS_SPL) {
 			//insert a mixer.
 			struct Module *mixer  = (struct Module *)(bin + size);
-			u8 channelID[64];
+			u16 channelID[64];
 
 			mixer->mDsp = 0;
 			mixer->mID = p->proc_id + 320;
@@ -95,20 +100,27 @@
 			mixer->mTxNum = 1;
 			memcpy(bin + size , &rxBufID[1], mixer->mTxNum*sizeof(u16)); size += mixer->mTxNum*sizeof(u16);
 		}
+		if(hw_adapter->get_system_is_dual_dsp()){
+			dsp_index = p->dsp_index ;
+		}
+		else {
+			dsp_index = 0;
+		}
+
 
 		m  = (struct Module *)(bin + size);
 		for(j = 0 ; j< ninports ;j ++) {
-			if(rxBufID[j] > dsp_input_num[p->dsp_index]) {
-				dsp_input_num[p->dsp_index] = rxBufID[j];
+			if(rxBufID[j] > dsp_input_num[dsp_index]) {
+				dsp_input_num[dsp_index] = rxBufID[j];
 			}
 		}
 		for(j = 0 ; j< noutports ;j ++) {
-			if(txBufID[j] > dsp_output_num[p->dsp_index]) {
-				dsp_output_num[p->dsp_index] = txBufID[j];
+			if(txBufID[j] > dsp_output_num[dsp_index]) {
+				dsp_output_num[dsp_index] = txBufID[j];
 			}
 		}
 
-		m->mDsp = 0;
+		m->mDsp = dsp_index;
 		m->mID = p->proc_id;
 		m->mType = p->proc_type;
 		m->mTag = p->tag;
@@ -120,28 +132,38 @@
 		memcpy(bin + size , rxBufID, m->mRxNum*sizeof(u16)); size += m->mRxNum*sizeof(u16);
 		m->mTxNum = noutports;
 		memcpy(bin + size , txBufID, m->mTxNum*sizeof(u16)); size += m->mTxNum*sizeof(u16);
+
+		if(p->physic_type == ModuleInterfaceType::PHY_INPUT) {
+			PhyPort* phy_id = (PhyPort*)(bin + size);
+			for(j = 0 ; j< ninports ;j ++, phy_id++) {
+				phy_id->mIntType = 0;
+				phy_id->mPhyID = hw_adapter->get_physical_channel(1, j);
+			}
+			size += ninports*sizeof(PhyPort);
+		}
+		else if(p->physic_type == ModuleInterfaceType::PHY_OUTPUT){
+			PhyPort* phy_id = (PhyPort*)(bin + size);
+			for(j = 0 ; j< noutports ;j ++, phy_id++) {
+				phy_id->mIntType = 0;
+				phy_id->mPhyID = hw_adapter->get_physical_channel(0, j);
+			}
+			size += noutports*sizeof(PhyPort);
+		}
 	}
 
-	ninports = dsp_input_num[0]>dsp_output_num[0]?dsp_input_num[0]:dsp_output_num[0];
-	noutports = dsp_input_num[1]>dsp_output_num[1]?dsp_input_num[1]:dsp_output_num[1];
-
-	if(0) {
-		flowchart->dsp_buffer_num[0] = ninports;
-		flowchart->dsp_buffer_num[1] = noutports;
-	}
-	else {
-		flowchart->dsp_buffer_num[0] = ninports>noutports?ninports:noutports;
+	//dual_dsp for 2 DSP,else 1 DSP.
+	for (i =0 ;i < hw_adapter->get_system_is_dual_dsp() + 1 ;i ++) {
+		flowchart->dsp_buffer_num[i] = std::max(dsp_input_num[i], dsp_output_num[i]);
 	}
 
 	flowchart->module_num = proc_list.size();
-	flowchart->crcLsb = 0;
-	flowchart->crcMsb = 0;
 	flowchart->compress = 0;
+	flowchart->version = 1;
+	flowchart->crc = 0;
 
 	crc = CRC::crc32((const u8*)bin, size);
 
-	flowchart->crcLsb = crc & 0xffff;
-	flowchart->crcMsb = crc >> 16;
+	flowchart->crc = crc;
 	return size;
 }
 

--
Gitblit v1.9.3