FSTATUS SmaGetCableInfo(struct oib_port *port, NodeData *nodep, uint32_t lid, uint8_t portnum, uint16_t addr, uint8_t len, uint8_t *data) { STL_SMP smp; FSTATUS fstatus; uint32_t amod = (addr & 0x07ff)<<19 | (len & 0x3f)<<13 | (portnum & 0xff); STL_CABLE_INFO *pCableInfo; MemoryClear(&smp, sizeof(smp)); DBGPRINT("Sending SMA Get(CableInfo %u) to LID 0x%x Node 0x%016"PRIx64"\n", portnum, lid, nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", STL_NODE_DESCRIPTION_ARRAY_SIZE, (char*)nodep->NodeDesc.NodeString); fstatus = stl_sma_send_recv_mad(port, lid, MMTHD_GET, STL_MCLASS_ATTRIB_ID_CABLE_INFO, amod, &smp); if (FSUCCESS == fstatus) { if (smp.common.u.DR.s.Status != MAD_STATUS_SUCCESS) { DBGPRINT("SMA response with bad status: 0x%x\n", smp.common.u.DR.s.Status); fstatus = FERROR; } else { pCableInfo = (STL_CABLE_INFO*)stl_get_smp_data(&smp); BSWAP_STL_CABLE_INFO(pCableInfo); memcpy(data, pCableInfo->Data, len+1); } } return fstatus; }
/* Get Port counters from PMA at portp for given PortNum * Retry and handle redirection as needed * portp is the port to issue PMA request to (can be port 0 of switch), it need */ FSTATUS STLPmGetPortStatus(struct oib_port *port, PortData *portp, uint8 portNum, STL_PortStatusData_t *pPortStatus) { STL_PERF_MAD req; STL_PERF_MAD resp; STL_PORT_STATUS_REQ* p = (STL_PORT_STATUS_REQ *)&(req.PerfData); FSTATUS fstatus; MemoryClear(&req, sizeof(req)); // rest of fields should be ignored for a Get, zero'ed above p->PortNumber = portNum; p->VLSelectMask = 0x8001; // only do VLs 15 and 0 for now, we will ignore VL counters for now BSWAP_STL_PORT_STATUS_REQ(p); DBGPRINT("Sending STL PM Get(PortStatus %d) to LID 0x%04x Node 0x%016"PRIx64"\n", portNum, portp->pathp->DLID, portp->nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", NODE_DESCRIPTION_ARRAY_SIZE, (char*)portp->nodep->NodeDesc.NodeString); fstatus = stl_pm_send_recv(port, portp, MMTHD_GET, STL_PM_ATTRIB_ID_PORT_STATUS, 0x01000000, &req, &resp); if (FSUCCESS != fstatus) goto fail; BSWAP_STL_PORT_STATUS_RSP((STL_PORT_STATUS_RSP*)resp.PerfData); *pPortStatus = *(STL_PortStatusData_t*)resp.PerfData; DBGPRINT("SendPkts=0x%16"PRIx64"\n", pPortStatus->PortXmitPkts); fail: return fstatus; }
Word Burger::DisplayDirectX9Software8::Init(Word uWidth,Word uHeight,Word /* uDepth */,Word uFlags) { Word uResult = DisplayDirectX9::Init(uWidth,uHeight,32,uFlags); if (!uResult) { m_uDepth = 8; // // Create the vertex buffer for software rendering // if (AllocateResources()!=D3D_OK) { uResult = 10; } else { m_Renderer.SetClip(0,0,static_cast<int>(uWidth),static_cast<int>(uHeight)); Word8 TempPalette[768]; MemoryClear(TempPalette,sizeof(TempPalette)); TempPalette[765]=255; TempPalette[766]=255; TempPalette[767]=255; //SetPalette(pSelf,TempPalette); FillVertexBuffer(); } } return uResult; }
/* Get STL Class Port Info from PMA at portp * Retry and handle redirection as needed * portp is the port to issue PMA request to (can be port 0 of switch) * The portp is updated with the CLASS_PORT_INFO redirect and PMA CapMask */ FSTATUS STLPmGetClassPortInfo(struct oib_port *port, PortData *portp) { STL_PERF_MAD req; STL_PERF_MAD resp; FSTATUS fstatus; if (portp->PmaGotClassPortInfo) return FSUCCESS; // if we already have, no use asking again MemoryClear(&req, sizeof(req)); DBGPRINT("Sending PM Get(ClassPortInfo) to LID 0x%04x Node 0x%016"PRIx64"\n", portp->pathp->DLID, portp->nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", NODE_DESCRIPTION_ARRAY_SIZE, (char*)portp->nodep->NodeDesc.NodeString); fstatus = stl_pm_send_recv(port, portp, MMTHD_GET, PM_ATTRIB_ID_CLASS_PORTINFO, 0, &req, &resp); if (FSUCCESS != fstatus) goto fail; fstatus = ProcessPmaClassPortInfo(portp, (STL_CLASS_PORT_INFO*)&(resp.PerfData), portp->pathp); fail: return fstatus; }
/* Get Linear FDB Table from SMA at lid * Retry as needed */ FSTATUS SmaGetLinearFDBTable(struct oib_port *port, NodeData *nodep, uint32_t lid, uint16 block, STL_LINEAR_FORWARDING_TABLE *pFDB) { STL_SMP smp; FSTATUS fstatus; uint32_t modifier; MemoryClear(&smp, sizeof(smp)); // rest of fields should be ignored for a Get, zero'ed above DBGPRINT("Sending SMA Get(LFT %u) to LID 0x%x Node 0x%016"PRIx64"\n", block, lid, nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", STL_NODE_DESCRIPTION_ARRAY_SIZE, (char*)nodep->NodeDesc.NodeString); modifier = 0x01000000 + (uint32_t)block; fstatus = stl_sma_send_recv_mad(port, lid, MMTHD_GET, STL_MCLASS_ATTRIB_ID_LINEAR_FWD_TABLE, modifier, &smp); if (FSUCCESS == fstatus) { if (smp.common.u.DR.s.Status != MAD_STATUS_SUCCESS) { DBGPRINT("SMA response with bad status: 0x%x\n", smp.common.u.DR.s.Status); fstatus = FERROR; } else { *pFDB = *(STL_LINEAR_FORWARDING_TABLE*)stl_get_smp_data(&smp); BSWAP_STL_LINEAR_FORWARDING_TABLE(pFDB); } } return fstatus; }
FSTATUS SmaGetSCVLMappingTable(struct oib_port *port, NodeData *nodep, uint32_t lid, uint8_t port_num, STL_SCVLMAP *pSCVLMap, uint16_t attr) { STL_SMP smp; FSTATUS fstatus; uint32 attrmod = (1<<24) | port_num; MemoryClear(&smp, sizeof(smp)); DBGPRINT("Sending SMA Get(SCVLMap %u) to LID 0x%x Node 0x%016"PRIx64"\n", port_num, lid, nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", STL_NODE_DESCRIPTION_ARRAY_SIZE, (char*)nodep->NodeDesc.NodeString); fstatus = stl_sma_send_recv_mad(port, lid, MMTHD_GET, attr, attrmod, &smp); if (FSUCCESS == fstatus) { if (smp.common.u.DR.s.Status != MAD_STATUS_SUCCESS) { DBGPRINT("SMA response with bad status: 0x%x\n", smp.common.u.DR.s.Status); fstatus = FERROR; } else { *pSCVLMap = *(STL_SCVLMAP*)stl_get_smp_data(&smp); BSWAP_STL_SCVLMAP(pSCVLMap); } } return fstatus; }
/* Get VLArb Table from SMA at lid * Retry as needed # Part has changed in STL, due to the table changes */ FSTATUS SmaGetVLArbTable(struct oib_port *port, NodeData *nodep, uint32_t lid, uint8_t portNum, uint8 part, STL_VLARB_TABLE *pVLArbTable) { STL_SMP smp; FSTATUS fstatus; uint32 attrmod = (1<<24) | (part<<16) | portNum; MemoryClear(&smp, sizeof(smp)); // rest of fields should be ignored for a Get, zero'ed above DBGPRINT("Sending SMA Get(VLArb %u %u) to LID 0x%x Node 0x%016"PRIx64"\n", part, portNum, lid, nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", STL_NODE_DESCRIPTION_ARRAY_SIZE, (char*)nodep->NodeDesc.NodeString); fstatus = stl_sma_send_recv_mad(port, lid, MMTHD_GET, STL_MCLASS_ATTRIB_ID_VL_ARBITRATION, attrmod, &smp); if (FSUCCESS == fstatus) { if (smp.common.u.DR.s.Status != MAD_STATUS_SUCCESS) { DBGPRINT("SMA response with bad status: 0x%x\n", smp.common.u.DR.s.Status); fstatus = FERROR; } else { *pVLArbTable = *(STL_VLARB_TABLE*)stl_get_smp_data(&smp); BSWAP_STL_VLARB_TABLE(pVLArbTable, part); } } return fstatus; }
/* Get SC2SC Mapping Table from SMA at lid * Retry as needed */ FSTATUS SmaGetSCSCMappingTable(struct oib_port *port, NodeData *nodep, uint32_t lid, uint8_t in_port, uint8_t out_port, STL_SCSCMAP *pSCSCMap) { STL_SMP smp; FSTATUS fstatus; uint32 attrmod = (1 << 24) | (in_port<<8) | out_port; MemoryClear(&smp, sizeof(smp)); // rest of fields should be ignored for a Get, zero'ed above DBGPRINT("Sending SMA Get(SCSCMap %u %u) to LID 0x%x Node 0x%016"PRIx64"\n", in_port, out_port, lid, nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", STL_NODE_DESCRIPTION_ARRAY_SIZE, (char*)nodep->NodeDesc.NodeString); fstatus = stl_sma_send_recv_mad(port, lid, MMTHD_GET, STL_MCLASS_ATTRIB_ID_SC_SC_MAPPING_TABLE, attrmod, &smp); if (FSUCCESS == fstatus) { if (smp.common.u.DR.s.Status != MAD_STATUS_SUCCESS) { DBGPRINT("SMA response with bad status: 0x%x\n", smp.common.u.DR.s.Status); fstatus = FERROR; } else { *pSCSCMap = *(STL_SCSCMAP*)stl_get_smp_data(&smp); BSWAP_STL_SCSCMAP(pSCSCMap); } } return fstatus; }
/* Get PortInfo from SMA at lid * Retry as needed */ FSTATUS SmaGetPortInfo(struct oib_port *port, NodeData *nodep, uint32_t lid, uint8_t portNum, STL_PORT_INFO *pPortInfo) { STL_SMP smp; FSTATUS fstatus; uint32 amod = 0x01000000 | portNum; MemoryClear(&smp, sizeof(smp)); // rest of fields should be ignored for a Get, zero'ed above DBGPRINT("Sending SMA Get(PortInfo %u) to LID 0x%x Node 0x%016"PRIx64"\n", portNum, lid, nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", STL_NODE_DESCRIPTION_ARRAY_SIZE, (char*)nodep->NodeDesc.NodeString); fstatus = stl_sma_send_recv_mad(port, lid, MMTHD_GET, STL_MCLASS_ATTRIB_ID_PORT_INFO, amod, &smp); if (FSUCCESS == fstatus) { if (smp.common.u.DR.s.Status != MAD_STATUS_SUCCESS) { DBGPRINT("SMA response with bad status: 0x%x\n", smp.common.u.DR.s.Status); fstatus = FERROR; } else { *pPortInfo = *(STL_PORT_INFO*)stl_get_smp_data(&smp); BSWAP_STL_PORT_INFO(pPortInfo); } } return fstatus; }
/* last - first must be <= 3 */ FSTATUS DmGetServiceEntries(struct oib_port *port, IB_PATH_RECORD *pathp, uint8 slot, uint8 first, uint8 last, IOC_SERVICE *pIocServices) { DM_MAD mad; FSTATUS fstatus; IOC_SERVICE *p; MemoryClear(&mad, sizeof(mad)); DBGPRINT("Sending DM Get(ServiceEntries, %u, %u-%u) to LID 0x%04x\n", slot, first, last, pathp->DLID); fstatus = dm_send_recv(port, pathp, DM_ATTRIB_ID_SERVICE_ENTRIES, DM_ATTRIB_MODIFIER_SERVICE_ENTRIES(slot, first, last), &mad); if (FSUCCESS != fstatus) goto fail; p = (IOC_SERVICE*)mad.DMData; for (; first <= last; first++, pIocServices++,p++) { *pIocServices = *p; BSWAP_DM_IOC_SERVICE(pIocServices); } fail: return fstatus; }
/* Get Buffer Control Table from SMA at lid * Retry as needed * pBCT must be large enough to hold all BufferControlTables */ FSTATUS SmaGetBufferControlTable(struct oib_port *port, NodeData *nodep, uint32_t lid, uint8_t startPort, uint8_t endPort, STL_BUFFER_CONTROL_TABLE pBCT[]) { STL_SMP smp; FSTATUS fstatus = FERROR; uint8_t maxcount = STL_NUM_BFRCTLTAB_BLOCKS_PER_LID_SMP; uint8_t block; MemoryClear(&smp, sizeof(smp)); DBGPRINT("Sending SMA Get(BufferControlTable %u %u) to LID 0x%x Node 0x%016"PRIx64"\n", startPort, endPort, lid, nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", STL_NODE_DESCRIPTION_ARRAY_SIZE, (char*)nodep->NodeDesc.NodeString); for (block = startPort; block <= endPort; block += maxcount) { uint8_t n = MIN(maxcount, (endPort - block)+1); uint32_t am = (n << 24) | block; fstatus = stl_sma_send_recv_mad(port, lid, MMTHD_GET, STL_MCLASS_ATTRIB_ID_BUFFER_CONTROL_TABLE, am, &smp); if (FSUCCESS == fstatus) { if (smp.common.u.DR.s.Status != MAD_STATUS_SUCCESS) { DBGPRINT("SMA response with bad status: 0x%x\n", smp.common.u.DR.s.Status); fstatus = FERROR; } else { int numPorts = (smp.common.AttributeModifier >> 24) & 0xff; int i; uint8_t * data = stl_get_smp_data(&smp); STL_BUFFER_CONTROL_TABLE *table = (STL_BUFFER_CONTROL_TABLE *)data; for (i = 0; i < numPorts; i++) { BSWAP_STL_BUFFER_CONTROL_TABLE(table); memcpy(&pBCT[block-startPort+i], table, sizeof(STL_BUFFER_CONTROL_TABLE)); // Handle the dissimilar sizes of Buffer Table and 8-byte pad alignment data += STL_BFRCTRLTAB_PAD_SIZE; table = (STL_BUFFER_CONTROL_TABLE *)(data); } } } } return fstatus; }
void* MemoryAllocate2AndClearRel( IN uint32 Bytes, IN uint32 flags, IN uint32 Tag ) { void *pBuffer; if( (pBuffer = MEMORY_ALLOCATE_PRIV( Bytes, flags, Tag )) != NULL ) { MemoryClear( pBuffer, Bytes ); } return pBuffer; }
/////////////////////////////////////////////////////////////////////////////// // ReqMgrInitState // // Description: // This function performs basic request manager initialization. This // function cannot fail. // // Inputs: // pReqMgr - Pointer to a request manager structure. // // Outputs: // None. // // Returns: // None. // /////////////////////////////////////////////////////////////////////////////// void ReqMgrInitState( IN REQ_MGR* const pReqMgr ) { ASSERT( pReqMgr ); // Clear the structure. MemoryClear( pReqMgr, sizeof(REQ_MGR) ); // Initialize the state of the request queue. QueueInitState( &pReqMgr->m_RequestQueue ); // Initialize the state of the free request stack. GrowPoolInitState( &pReqMgr->m_RequestPool ); }
FSTATUS DmGetIouInfo(struct oib_port *port, IB_PATH_RECORD *pathp, IOUnitInfo *pIouInfo) { DM_MAD mad; FSTATUS fstatus; MemoryClear(&mad, sizeof(mad)); DBGPRINT("Sending DM Get(IouInfo) to LID 0x%04x\n", pathp->DLID); fstatus = dm_send_recv(port, pathp, DM_ATTRIB_ID_IOUNIT_INFO, 0, &mad); if (FSUCCESS != fstatus) goto fail; *pIouInfo = *(IOUnitInfo*)mad.DMData; BSWAP_DM_IOUNIT_INFO(pIouInfo); fail: return fstatus; }
void* MemoryAllocate2AndClearDbg( IN const char *pFileName, IN int32 nLine, IN uint32 Bytes, IN uint32 flags, IN uint32 Tag ) { void *pBuffer; if( (pBuffer = MemoryAllocate2Dbg( pFileName, nLine, Bytes, flags, Tag )) != NULL ) { MemoryClear( pBuffer, Bytes ); } return pBuffer; }
FSTATUS DmGetIocProfile(struct oib_port *port, IB_PATH_RECORD *pathp, uint8 slot, IOC_PROFILE *pIocProfile) { DM_MAD mad; FSTATUS fstatus; MemoryClear(&mad, sizeof(mad)); DBGPRINT("Sending DM Get(IocProfile, %u) to LID 0x%04x\n", slot, pathp->DLID); fstatus = dm_send_recv(port, pathp, DM_ATTRIB_ID_IOCONTROLLER_PROFILE, slot, &mad); if (FSUCCESS != fstatus) goto fail; *pIocProfile = *(IOC_PROFILE*)mad.DMData; BSWAP_DM_IOC_PROFILE(pIocProfile); fail: return fstatus; }
/* Clear port counters issued to PMA at portp. * portp is the port to issue the PMA request to (can be port 0, * thought lastPortIndex MUST be 0 in this case - see below). * * If lastPortIndex > 0, then it's assumed portp is * switch port 0, and send a ClearPortCounters for all ports up to lastPortIndex. * Otherwise assume this is an HFI, and only clear the port at portp. * Retry and handle redirection as needed * If thresholds is non-NULL, only counters with non-zero threshold are cleared * otherwise all counters are cleared */ FSTATUS STLPmClearPortCounters(struct oib_port *port, PortData *portp, uint8 lastPortIndex, uint32 counterselect) { STL_PERF_MAD req; STL_PERF_MAD resp; STL_CLEAR_PORT_STATUS* p = (STL_CLEAR_PORT_STATUS *)&(req.PerfData); FSTATUS fstatus; uint8_t i; char debugStr[64] = {'\0'}; MemoryClear(&req, sizeof(req)); for (i = 0; i < (lastPortIndex / 64); ++i) p->PortSelectMask[3 - i] = ~(0ULL); if (lastPortIndex) p->PortSelectMask[3 - i] = (1ULL<<(lastPortIndex + 1)) - 1; // All ports up to lastPortIndex masked. else p->PortSelectMask[3] = 1<<portp->PortNum; // HFI Case. p->CounterSelectMask.AsReg32 = counterselect; if (g_verbose_file) { if (lastPortIndex) sprintf(debugStr, "port range [%d-%d]", portp->PortNum, lastPortIndex); else sprintf(debugStr, "port %d", portp->PortNum); } DBGPRINT("Sending PM Set(PortStatus %s, Sel=0x%04x) to LID 0x%04x Node 0x%016"PRIx64"\n", debugStr, p->CounterSelectMask.AsReg32, portp->pathp->DLID, portp->nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", NODE_DESCRIPTION_ARRAY_SIZE, (char*)portp->nodep->NodeDesc.NodeString); BSWAP_STL_CLEAR_PORT_STATUS_REQ(p); fstatus = stl_pm_send_recv(port, portp, MMTHD_SET, STL_PM_ATTRIB_ID_CLEAR_PORT_STATUS, 1<<24, &req, &resp); if (FSUCCESS != fstatus) { //DBGPRINT("stl_pm_send_recv fstatus=%s\n", iba_fstatus_msg(fstatus)); goto fail; } fail: return fstatus; }
FSTATUS iba_sd_leave_mcgroup( CLIENT_HANDLE SdClientHandle, IB_GID *pMGID ) { FSTATUS Status; MC_GROUP_ID McGroupId; _DBG_ENTER_LVL(_DBG_LVL_FUNC_TRACE, iba_sd_leave_mcgroup); MemoryClear(&McGroupId, sizeof(McGroupId)); McGroupId.JoinVersion = 1; McGroupId.McRID.MGID = *pMGID; Status = McLeaveGroup(SdClientHandle, &McGroupId); _DBG_LEAVE_LVL( _DBG_LVL_FUNC_TRACE ); return Status; }
void IOHelper::ReadPGMFile(char* filename, ImageGray& img) { //Read File FILE* file = fopen(filename, "rb+"); assert(file!=NULL); assert(fseek(file, 0, SEEK_END)==0); U32 length = ftell(file); assert(length>0); fseek(file, 0, SEEK_SET); U8* bufferRead = new U8[length]; MemoryClear(bufferRead, length); U32 len = fread(bufferRead, 1, length, file); assert(len==length); fclose(file); //Read Image itr_vision::FormatPGM FormatPGMObj; itr_vision::IFormat::ImageInfo imageInfo; assert(FormatPGMObj.GetInfo(bufferRead, length, imageInfo)==itr_vision::IFormat::Success); img.Allocate(imageInfo.Width, imageInfo.Height); assert(FormatPGMObj.ToImage(bufferRead,length,img)==itr_vision::IFormat::Success); delete[] bufferRead; }
static FSTATUS send_mad(MADT_HANDLE umadtHandle, IB_PATH_RECORD *pathp, uint32 qpn, uint32 qkey, MAD* mad) { FSTATUS status; MadtStruct *Mad; MadAddrStruct Addr; uint32 count = 1; MadWorkCompletion *Wc; DBGPRINT("getting buffer to send Mad\n"); status = iba_umadt_get_sendmad(umadtHandle, &count, &Mad); if (status != FSUCCESS) { return status; } DBGPRINT("sending Mad\n"); Mad->Context = 0; // TBD - for async in future MemoryClear(&Mad->Grh, sizeof(Mad->Grh)); /* only in recv */ MemoryCopy(&Mad->IBMad, mad, sizeof(*mad)); GetGsiAddrFromPath(pathp, qpn, qkey, &Addr); status = iba_umadt_post_send(umadtHandle, Mad, &Addr); if (status != FSUCCESS) { fprintf(stderr, "%s: Failed to send mad: (status=0x%x): %s\n", g_Top_cmdname, status, FSTATUS_MSG(status)); (void)iba_umadt_release_sendmad(umadtHandle, Mad); return status; } status = iba_umadt_wait_any_compl(umadtHandle, SEND_COMPLETION, SEND_WAIT_TIME); if (status == FSUCCESS) { status = iba_umadt_poll_send_compl(umadtHandle, &Mad, &Wc); if (status == FSUCCESS) { DBGPRINT("MAD Sent\n"); (void)iba_umadt_release_sendmad(umadtHandle, Mad); } } return status; }
/* Get Multicast FDB Table from SMA at lid * Retry as needed */ FSTATUS SmaGetMulticastFDBTable(struct oib_port *port, NodeData *nodep, uint32_t lid, uint32 block, uint8 position, STL_MULTICAST_FORWARDING_TABLE *pFDB) { STL_SMP smp; FSTATUS fstatus; MemoryClear(&smp, sizeof(smp)); // rest of fields should be ignored for a Get, zero'ed above DBGPRINT("Sending SMA Get(MFT %u %u) to LID 0x%x Node 0x%016"PRIx64"\n", block, position, lid, nodep->NodeInfo.NodeGUID); DBGPRINT(" Name: %.*s\n", STL_NODE_DESCRIPTION_ARRAY_SIZE, (char*)nodep->NodeDesc.NodeString); //@TODO: Enable multi-block requests from just a single block request fstatus = stl_sma_send_recv_mad(port, lid, MMTHD_GET, STL_MCLASS_ATTRIB_ID_MCAST_FWD_TABLE, (0x1<<24) | (0x3 & position)<<22 | (block & 0xfffff), &smp); if (FSUCCESS == fstatus) { if (smp.common.u.DR.s.Status != MAD_STATUS_SUCCESS) { DBGPRINT("SMA response with bad status: 0x%x\n", smp.common.u.DR.s.Status); fstatus = FERROR; } else { *pFDB = *(STL_MULTICAST_FORWARDING_TABLE*)stl_get_smp_data(&smp); BSWAP_STL_MULTICAST_FORWARDING_TABLE(pFDB); } } return fstatus; }
bool LoadPSIDFile(const char *file) { // Open file FILE *f = fopen(file, "rb"); if (f == NULL) return false; // Clear C64 RAM MemoryClear(); psid_loaded = false; // Load and check header uint8_t header[PSID_MAX_HEADER_LENGTH]; memset(header, 0, PSID_MAX_HEADER_LENGTH); size_t actual = fread(header, 1, PSID_MAX_HEADER_LENGTH, f); if (actual < PSID_MIN_HEADER_LENGTH || !IsPSIDHeader(header)) { fclose(f); return false; } // Extract data from header number_of_songs = read_psid_16(header, PSID_NUMBER); if (number_of_songs == 0) number_of_songs = 1; current_song = read_psid_16(header, PSID_DEFSONG); if (current_song) current_song--; if (current_song >= number_of_songs) current_song = 0; init_adr = read_psid_16(header, PSID_INIT); play_adr = read_psid_16(header, PSID_MAIN); play_adr_from_irq_vec = (play_adr == 0); speed_flags = read_psid_32(header, PSID_SPEED); strncpy(module_name, (char *)(header + PSID_NAME), 32); strncpy(author_name, (char *)(header + PSID_AUTHOR), 32); strncpy(copyright_info, (char *)(header + PSID_COPYRIGHT), 32); module_name[32] = 0; author_name[32] = 0; copyright_info[32] = 0; // Seek to start of module data fseek(f, read_psid_16(header, PSID_LENGTH), SEEK_SET); // Find load address uint16_t load_adr = read_psid_16(header, PSID_START); if (load_adr == 0) { // Load address is at start of module data uint8_t lo = fgetc(f); uint8_t hi = fgetc(f); load_adr = (hi << 8) | lo; } if (init_adr == 0) // Init routine address is equal to load address init_adr = load_adr; // Load module data to C64 RAM fread(ram + load_adr, 1, RAM_SIZE - load_adr, f); fclose(f); // Select default song SelectSong(current_song); // Everything OK psid_loaded = true; return true; }
FSTATUS BmaLoad( IN IBT_COMPONENT_INFO *ComponentInfo ) { FSTATUS status = FSUCCESS; extern uint32 BmaDbg; #ifdef IB_TRACE extern uint32 BmaTrace; #endif _DBG_ENTER_LVL(_DBG_LVL_MAIN, BMALoad); _DBG_INIT; __DBG_LEVEL__ = BmaDbg; #ifdef IB_TRACE __DBG_TRACE_LEVEL__ = BmaTrace; #endif #if defined(IB_DEBUG) || defined(DBG) MsgOut ("Bma:DebugFlags = 0x%8x\n", __DBG_LEVEL__); #endif #if defined(VXWORKS) _DBG_PRINT(_DBG_LVL_MAIN, (" InfiniBand Baseboard Management Class agent. Built %s %s\n",\ __DATE__, __TIME__ )); #else _DBG_PRINT(_DBG_LVL_MAIN, (" InfiniBand Baseboard Management Class agent. Built %s %s\n",\ _DBG_PTR(__DATE__), _DBG_PTR(__TIME__) )); #endif _TRC_REGISTER(); // // Establish dispatch entry points for the functions supported. // MemoryClear( ComponentInfo, sizeof(IBT_COMPONENT_INFO) ); ComponentInfo->AddDevice = BmaAddDevice; ComponentInfo->RemoveDevice = BmaRemoveDevice; ComponentInfo->Unload = BmaUnload; // // Read any registry parameters for the driver which may be present. // //BmaReadRegistryParameters(); // // This function is called to initialize the GSA subsystem. This must be // called only once and if the function does not return success, the // caller must unload the component containing GSA or else not use the // GSA functionality since GSA will not be available. // // We are being asked to do a one-time initialization. Here we initialize // the list of channel adapters as well as initialize the list of service // classes as well as initialize the spin locks guarding these lists. // // // Allocate space for Global data // g_BmaGlobalInfo = (BMA_GLOBAL_INFO*)MemoryAllocateAndClear( sizeof(BMA_GLOBAL_INFO), FALSE, BMA_TAG ); if ( NULL != g_BmaGlobalInfo ) { // // initialize global data // g_BmaGlobalInfo->binitsuccess = FALSE; SpinLockInitState( &g_BmaGlobalInfo->DevListLock ); if( !SpinLockInit( &g_BmaGlobalInfo->DevListLock ) ) { _DBG_ERROR(( "Unable to initialize spin locks!\n" )); status = FINSUFFICIENT_RESOURCES; goto fail_lock; } // // Recv Queue and Thread // CmdThreadInitState(&g_BmaGlobalInfo->RecvThread); if ( ! CmdThreadCreate(&g_BmaGlobalInfo->RecvThread, THREAD_PRI_HIGH, "Bma", (CMD_THREAD_CALLBACK)BmaThreadCallback, (CMD_THREAD_CALLBACK)BmaFreeCallback, (void*)g_BmaGlobalInfo)) { _DBG_ERROR(("BmaMain: Unable to Create RecvThread\n")); status = FINSUFFICIENT_RESOURCES; goto fail_thread; } // initialize this general service class manager with GSI status = iba_gsi_register_class(MCLASS_BM, IB_BM_CLASS_VERSION, GSI_REGISTER_RESPONDER, // Register as a Responder FALSE, // No SAR cap needed g_BmaGlobalInfo, // Context BmaSendCallback, BmaRecvCallback, &g_BmaGlobalInfo->GsaHandle); if (status != FSUCCESS) { CmdThreadDestroy(&g_BmaGlobalInfo->RecvThread); fail_thread: SpinLockDestroy( &g_BmaGlobalInfo->DevListLock ); fail_lock: MemoryDeallocate(g_BmaGlobalInfo); g_BmaGlobalInfo = NULL; _DBG_ERROR(("BmaMain: Unable to register with GSA!!! <status %d>\n", status)); _DBG_LEAVE_EXT(_DBG_LVL_FUNC_TRACE); return status; } } else { status = FINSUFFICIENT_RESOURCES; _DBG_PRINT(_DBG_LVL_MAIN,("Not enough memory!\n")); } _DBG_LEAVE_LVL(_DBG_LVL_MAIN); return status; }
FSTATUS SMALoad( IN IBT_COMPONENT_INFO *ComponentInfo ) { FSTATUS status = FSUCCESS; _DBG_ENTER_LVL(_DBG_LVL_MAIN, SmaLoad); _DBG_INIT; _TRC_REGISTER(); #if !defined(VXWORKS) _DBG_PRINT(_DBG_LVL_MAIN, (" InfiniBand Subnet Management Agent. Built %s %s\n",\ __DATE__, __TIME__ )); #else _DBG_PRINT(_DBG_LVL_MAIN, (" InfiniBand Subnet Management Agent. Built %s %s\n",\ _DBG_PTR(__DATE__), _DBG_PTR(__TIME__) )); #endif // Establish dispatch entry points for the functions supported. MemoryClear( ComponentInfo, sizeof(IBT_COMPONENT_INFO) ); ComponentInfo->AddDevice = SmaAddDevice; ComponentInfo->RemoveDevice = SmaRemoveDevice; ComponentInfo->Unload = SMAUnload; // Read Global settings for the driver which may be set in a // OS specific way. SmaInitGlobalSettings(); // Allocate space for Global data g_Sma = (SMA_GLOBAL_INFO*)MemoryAllocate2AndClear(sizeof(SMA_GLOBAL_INFO), IBA_MEM_FLAG_PREMPTABLE, SMA_MEM_TAG); if ( NULL == g_Sma ) { _DBG_ERROR(("MemAlloc failed for g_Sma!\n")); goto done; } // initialize global data g_Sma->NumCa = 0; g_Sma->CaObj = NULL; g_Sma->WorkReqRecv = g_Sma->WorkReqSend = NULL; g_Sma->SmUserTbl = NULL; g_Sma->NumUser = 0; // SpinLockInitState( &g_Sma->Lock ) // SpinLockInit( &g_Sma->Lock ) // Init Storage area for MADs g_Sma->Bin.NumBlocks = 0; g_Sma->Bin.Head = g_Sma->Bin.Tail = NULL; g_Sma->Bin.MemList = NULL; g_Sma->Bin.CurrentIndex = 0; // set start mem index // Locks SpinLockInitState( &g_Sma->CaListLock ); SpinLockInit( &g_Sma->CaListLock ); SpinLockInitState( &g_Sma->Bin.Lock ); SpinLockInit( &g_Sma->Bin.Lock ); MutexInitState( &g_Sma->Bin.Mutex ); MutexInit( &g_Sma->Bin.Mutex ); SpinLockInitState( &g_Sma->RQ.Lock ); SpinLockInit( &g_Sma->RQ.Lock ); // Init Global Ibt user group for notifications IbtInitNotifyGroup(NotifyIbtCallback); // Allocate memory for Global GRH since the SMA does not need a GRH. // This memory will automatically get mapped to all CA registrations. g_Sma->GlobalGrh = CreateGlobalMemList( 0, sizeof(IB_GRH), 0, FALSE ); if ( NULL == g_Sma->GlobalGrh ) { status = FINSUFFICIENT_RESOURCES; goto failmemlist; } g_Sma->GlobalGrh->VirtualAddr = MemoryAllocate2AndClear(sizeof(IB_GRH), IBA_MEM_FLAG_PREMPTABLE, SMA_MEM_TAG); if ( NULL == g_Sma->GlobalGrh->VirtualAddr ) { status = FINSUFFICIENT_RESOURCES; goto failgrhvirt; } g_Sma->GlobalGrh->AccessControl.AsUINT16 = 0; g_Sma->GlobalGrh->AccessControl.s.LocalWrite = 1; g_Sma->GlobalGrh->CaMemIndex = 0; // Increment index for future allocations g_Sma->Bin.CurrentIndex++; done: _DBG_LEAVE_LVL(_DBG_LVL_MAIN); return status; failgrhvirt: MemoryDeallocate( g_Sma->GlobalGrh ); failmemlist: IbtDestroyNotifyGroup(); SpinLockDestroy( &g_Sma->RQ.Lock ); MutexDestroy( &g_Sma->Bin.Mutex ); SpinLockDestroy( &g_Sma->Bin.Lock ); SpinLockDestroy( &g_Sma->CaListLock ); MemoryDeallocate( g_Sma ); goto done; }
Word Burger::FileBMP::Save(OutputMemoryStream *pOutput,const Image *pImage,Word bCompress) { // Temp buffer Word8 Filler[16]; Image::ePixelTypes eType = pImage->GetType(); // Only 24 and 8 bit formats are supported if ((eType!=Image::PIXELTYPE8BIT) && (eType!=Image::PIXELTYPE555) && (eType!=Image::PIXELTYPE1555) && (eType!=Image::PIXELTYPE888) && (eType!=Image::PIXELTYPE8888)) { return 10; } // Save the signature (14 bytes) pOutput->Append("BM"); WordPtr uFileLengthMark = pOutput->GetSize(); pOutput->Append(static_cast<Word32>(0)); // Write the file length (Change later) pOutput->Append(m_uReserved1); // Write the reserved entries pOutput->Append(m_uReserved2); // Save the image description block and maybe the palette Word32 uMark = 14+40+1024; Word uDepth = 8; if (eType!=Image::PIXELTYPE8BIT) { bCompress = FALSE; // No compression is allowed!!! uMark = 14+40; // No palette if (eType==Image::PIXELTYPE888) { uDepth = 24; } else if (eType==Image::PIXELTYPE8888) { uDepth = 32; } else { uDepth = 16; } } Word uWidth = pImage->GetWidth(); Word uHeight = pImage->GetHeight(); WordPtr uStride = pImage->GetStride(); pOutput->Append(uMark); // Header with palette size pOutput->Append(static_cast<Word32>(40)); // Data info size pOutput->Append(static_cast<Word32>(uWidth)); // Image size pOutput->Append(static_cast<Word32>(uHeight)); pOutput->Append(static_cast<Word16>(1)); // Bit planes pOutput->Append(static_cast<Word16>(uDepth)); // Bit depth pOutput->Append(static_cast<Word32>(bCompress ? BMP_RLE8 : BMP_RGB)); // Data type WordPtr uOutputMark = pOutput->GetSize(); pOutput->Append(static_cast<Word32>(0)); // Output length pOutput->Append(static_cast<Word32>(m_iXPixelsPerMeter)); // Pixels per meter pOutput->Append(static_cast<Word32>(m_iYPixelsPerMeter)); pOutput->Append(static_cast<Word32>(m_uColorsUsed)); // Colors used pOutput->Append(static_cast<Word32>(m_uColorsImportant)); // Colors important // Output the supported types! 8 Bit, 24 and 32 bit MemoryClear(Filler,sizeof(Filler)); const Word8 *pData = pImage->GetImage()+((uHeight-1)*uStride); WordPtr uSizeMark; if (eType==Image::PIXELTYPE8BIT) { // 8 bit paletted! // Write out the palette first RGBAWord8_t *pPalette = m_Palette; // First save the palette Word i = 256; do { pOutput->Append(pPalette->m_uBlue); // Blue pOutput->Append(pPalette->m_uGreen); // Green pOutput->Append(pPalette->m_uRed); // Red pOutput->Append(pPalette->m_uAlpha); // Extra ++pPalette; } while (--i); // All done? // Adjust the start mark for the pixel data to skip past the inserted palette uSizeMark = pOutput->GetSize(); // Compressed? if (bCompress) { do { CompressRLE8(pOutput,pData,uWidth,uHeight==1); // Compress a line pData = pData-uStride; // Next line up } while (--uHeight); // All done? } else { // Raw! Word uPadding = (0-uWidth)&3; // 0,3,2,1 do { pOutput->Append(pData,uWidth); // Save a line to disk pOutput->Append(Filler,uPadding); // Filler pData = pData-uStride; // Next line up } while (--uHeight); // All done? } } else { uSizeMark = pOutput->GetSize(); if (eType==Image::PIXELTYPE888) { Word uPadding = (0-(uWidth*3))&3; // Padding after each pixel do { Word j = uWidth; // Get count const Word8 *pWork = pData; do { pOutput->Append(pWork[2]); // Save out the scan line pOutput->Append(pWork[1]); pOutput->Append(pWork[0]); pWork=pWork+3; // Next triplet } while (--j); // Next pixel pOutput->Append(Filler,uPadding); // Filler pData = pData-uStride; // Next line up } while (--uHeight); // All done? } else if (eType==Image::PIXELTYPE8888) { // 8888 format do { Word j = uWidth; // Get count const Word8 *pWork = pData; do { pOutput->Append(pWork[2]); // Save out the scan line pOutput->Append(pWork[1]); pOutput->Append(pWork[0]); pOutput->Append(pWork[3]); pWork=pWork+4; // Next triplet } while (--j); // Next pixel pData = pData-uStride; // Next line up } while (--uHeight); // All done? } else { Word uPadding = (0-(uWidth*2))&3; // Padding after each pixel // 1555 or x555 format do { Word j = uWidth; // Get count const Word8 *pWork = pData; do { pOutput->Append(static_cast<Word16>(reinterpret_cast<const Word16 *>(pWork)[0]&0x7FFFU)); // Save out the scan line pWork=pWork+2; // Next triplet } while (--j); // Next pixel pOutput->Append(Filler,uPadding); // Filler pData = pData-uStride; // Next line up } while (--uHeight); // All done? } } // Wrap up the file WordPtr uTell = pOutput->GetSize(); // Write the length of the total file // +2 is for "BM" Word32 uLittleData = LittleEndian::Load(static_cast<Word32>((uTell-uFileLengthMark)+2)); pOutput->Overwrite(&uLittleData,sizeof(Word32),uFileLengthMark); // Write the length of the packed data uLittleData = LittleEndian::Load(static_cast<Word32>(uTell-uSizeMark)); pOutput->Overwrite(&uLittleData,sizeof(Word32),uOutputMark); return FALSE; }
Burger::Image * Burger::FileBMP::Load(InputMemoryStream *pInput) { Word8 ID[4]; const char *pBadNews = NULL; Image *pImage = NULL; Word32 uHeaderSize = 0; Word32 uInfoSize = 0; // Start with processing the 14 byte header of the BMP file if (pInput->BytesRemaining()<14) { pBadNews = "Insufficient data for BMP file header."; } else { // Read the 14 byte header pInput->Get(ID,2); Word32 uFileSize = pInput->GetWord32(); m_uReserved1 = pInput->GetShort(); m_uReserved2 = pInput->GetShort(); uHeaderSize = pInput->GetWord32(); if ((ID[0]!='B') || (ID[1]!='M')) { pBadNews = "No 'BM' id string found."; } else if (uFileSize != (pInput->BytesRemaining()+14)) { pBadNews = "File size entry doesn't match the file length."; } else if (uHeaderSize < (14+40)) { pBadNews = "Header size is smaller than 54 bytes."; } else { // Skip past the extra data, if any if (pInput->BytesRemaining()<40) { pBadNews = "Insufficient data for BMP info header."; } } } // If no error, process the 40 byte info record Word32 uWidth = 0; Word32 uHeight = 0; Word32 uBitPlanes = 0; Word32 uBitDepth = 0; Word32 uCompression = BMP_RGB; if (!pBadNews) { // Pull in the 40 byte header uInfoSize = pInput->GetWord32(); uWidth = pInput->GetWord32(); uHeight = pInput->GetWord32(); uBitPlanes = pInput->GetShort(); uBitDepth = pInput->GetShort(); uCompression = pInput->GetWord32(); /* Word32 uSizeImage = */ pInput->GetWord32(); m_iXPixelsPerMeter = static_cast<Int32>(pInput->GetWord32()); m_iYPixelsPerMeter = static_cast<Int32>(pInput->GetWord32()); m_uColorsUsed = pInput->GetWord32(); m_uColorsImportant = pInput->GetWord32(); if ((uBitDepth != 8) && (uBitDepth != 16) && (uBitDepth != 24) && (uBitDepth != 32)) { Debug::Warning("Can't process %u bits per pixel, only 8, 16, 24 or 32.",static_cast<unsigned int>(uBitDepth)); return NULL; } if ((uCompression!=BMP_RGB) && (uCompression!=BMP_RLE8)) { pBadNews = "Compression algorithm is not supported."; } else if ((uBitDepth!=8) && (uCompression!=BMP_RGB)) { // No compression on 24 bit pBadNews = "Non 8 bit image file is compressed."; } else if (!uWidth) { pBadNews = "Image width is zero."; } else if (!uHeight) { pBadNews = "Image height is zero."; } else if (uBitPlanes!=1) { pBadNews = "Bit plane count is not one."; } else if (uInfoSize<40) { pBadNews = "Header size is less than 40 bytes in size."; } } // Process the palette if (!pBadNews && (uBitDepth==8)) { pInput->SetMark(14+uInfoSize); if (pInput->BytesRemaining()<1024) { pBadNews = "Insufficient data for BMP palette."; } else { MemoryClear(m_Palette,sizeof(m_Palette)); Word i = 256; RGBAWord8_t *pWork = m_Palette; do { pWork->m_uBlue = pInput->GetByte(); // Read in the palette pWork->m_uGreen = pInput->GetByte(); pWork->m_uRed = pInput->GetByte(); pWork->m_uAlpha = pInput->GetByte(); ++pWork; } while (--i); } } if (!pBadNews) { Image::ePixelTypes eType; if (uBitDepth==8) { eType = Image::PIXELTYPE8BIT; } else if (uBitDepth==16) { eType = Image::PIXELTYPE555; } else if (uBitDepth==24) { eType = Image::PIXELTYPE888; } else { eType = Image::PIXELTYPE8888; } pImage = Image::New(uWidth,uHeight,eType); if (!pImage) { pBadNews = "Out of memory."; } else { pImage->ClearBitmap(); } } // At this point, if pBadNews wasn't set, assume // that an Image was allocated and data is ready to be processed if (!pBadNews) { WordPtr uStride = pImage->GetStride(); // Get the pointer to the BOTTOM scan line to flip // the image Word8 *pData = pImage->GetImage()+((uHeight-1)*uStride); if (uCompression==BMP_RLE8) { Word i = uHeight; do { pBadNews = DecompressRLE8(pData,uWidth,pInput); if (pBadNews) { // Error? break; } pData = pData-uStride; // Next line up } while (--i); // All done? } else { Word i = uHeight; if (uBitDepth==8) { Word uBMPPadding = (0-uWidth)&3; do { pInput->Get(pData,uWidth); // Copy the line pInput->SkipForward(uBMPPadding); // Handle padding pData = pData-uStride; // Next line up } while(--i); } else if (uBitDepth==16) { Word uBMPPadding = (0-(uWidth*2))&3; do { Word j = uWidth; // Pixel count Word8 *pDest = pData; do { reinterpret_cast<Word16 *>(pDest)[0] = static_cast<Word16>(pInput->GetShort()&0x7FFF); pDest=pDest+2; // Next pixel } while (--j); // Count down pInput->SkipForward(uBMPPadding); // Handle padding pData = pData-uStride; // Next line up } while(--i); } else if (uBitDepth==24) { Word uBMPPadding = (0-(uWidth*3))&3; do { Word j = uWidth; // Pixel count Word8 *pDest = pData; do { pDest[2] = pInput->GetByte(); // Blue pDest[1] = pInput->GetByte(); // Green pDest[0] = pInput->GetByte(); // Red pDest=pDest+3; // Next pixel } while (--j); // Count down pInput->SkipForward(uBMPPadding); // Handle padding pData = pData-uStride; // Next line up } while(--i); } else { // RGBA do { Word j = uWidth; // Pixel count Word8 *pDest = pData; do { pDest[2] = pInput->GetByte(); // Blue pDest[1] = pInput->GetByte(); // Green pDest[0] = pInput->GetByte(); // Red pDest[3] = pInput->GetByte(); // Alpha pDest=pDest+4; // Next pixel } while (--j); // Count down pData = pData-uStride; // Next line up } while(--i); } } } // If there was an error, clean up if (pBadNews) { Debug::Warning(pBadNews); Delete(pImage); pImage = NULL; } return pImage; }
//#pragma vector=RESET_VECTOR //#define PROGRAMDEBUG 1 int main(void) { INT16U i,temp,second; INT16U count,oldDI; INT8U RUN; //RUNRECORD runlog; unsigned char old__second; unsigned char old__minute; unsigned char old__hour; unsigned char old__day; unsigned char minute_counter=0; //unsigned char hour_counter=0; unsigned int DI_Convert=0; char checkcode[6]="vh11+\0"; char DI_C[4]="DI=\0"; char d[5]; unsigned int Prog_Circle=0; //unsigned char cps[]="DataTime=\0"; INT8U DI_Alter=0; INT8U Save_Hourdata=0; INT8U Save_Daydata=0; //INT8U a[16]="123456789ABCDEF"; //INT8U b[17]; // INT8U c[3]={0xf8,0x10,0x10}; INT8U checknum[7]; /*********************************************** device initializing ************************************************/ CPU_init(); P4OUT |=BIT0; //flash rst GPRS_POWERON; RealData.R_D.DO=0; DIInput(); DOOutput(RealData.R_D.DO); init_lcd (); clrram(); LCD_light_ON; disp_img(0x01e0+960,30,64,zimo240128); //MemoryClear(Modbustore,sizeof(Modbustore)); Modbustore =0; MemoryClear(local_mma_H,sizeof(local_mma_H)); MemoryClear(local_mma_D,sizeof(local_mma_D)); MemoryClear(local_mma_M,sizeof(local_mma_M));//100504 MemoryClear(dev_mma_D,sizeof(dev_mma_D)); MemoryClear(dev_mma_H,sizeof(dev_mma_H)); MemoryClear(dev_mma_M,sizeof(dev_mma_M)); //100504 MemoryClear(Hour_COD_avg,sizeof(Hour_COD_avg)); MemoryClear(Hour_B01_avg,sizeof(Hour_B01_avg)); delay11(3200); //GPRS_POWEROFF; //test #ifdef PROGRAMDEBUG char c[3]={0x00,0,0}; char aa='A'; FlashBufferWrite(c,"abcdefg",7,0); //c[0]=0xf0; //FlashBuffertoMemory(c,0); Delay_N_mS(20000); c[0]=0; FlashBufferRead(c,checknum,5,0); checknum[0]=0; c[0]=0xf0; FlashMemorytoBuffer(c,0); c[0]=0; FlashBufferRead(c,checknum,5,0); checknum[0]=0; c[0]=0xf0; FlashMemoryRead(c,checknum,5); //FlashMemoryWrite(c,checkcode,5,0); Delay_N_mS(20000); //c[2]=0x05; //FlashMemoryWrite(c,&aa,1,0); Delay_N_mS(20000); c[2]=0; FlashMemoryRead(c,checknum,5); #endif //--------------------------- /**************************************************** system initializing ****************************************************/ AT24C64_RS(checknum,0x00,6); Delay_N_mS(2000); AT24C64_RS(checknum,0x00,6); if(strcmp(checknum,checkcode)!=0) { v_charge1302(); v_Set1302(); for(count=0;count<6;count++) SPARA.pw[count]=(count+1)|0x30; //初始密码123456 for(count=0;count<9;count++) { SPARA.mn[count]=(count+1)|0x30; //mn 12345678901234 ml_mn[count]=parameter.sys_parameter.mn[count]; } for(count=0;count<5;count++) { SPARA.mn[count+9]=count|0x30; ml_mn[count+9]=parameter.sys_parameter.mn[count+9]; } SPARA.st[0]='3'; //st 32 SPARA.st[1]='2'; ml_st[0]='3'; ml_st[1]='2'; for(count=0;count<9;count++) SPARA.sim[count]=(count+1)|0x30; //sim 123456789 SPARA.rd_interval[0]='3'; //实时数据上报时间 60秒 SPARA.rd_interval[1]='0'; SPARA.rd_interval[2]='0'; for(count=0;count<5;count++) SPARA.overtime[count]='0'; //超时时间 5秒 SPARA.overtime[4]='5'; SPARA.resendtime[0]='0'; //重发次数 3次 SPARA.resendtime[1]='3'; for(count=0;count<5;count++) SPARA.warntime[count]='0'; //报警时间 5 SPARA.warntime[4]='5'; for(count=0;count<4;count++) SPARA.reporttime[count]='0'; //上报时间 5 SPARA.reporttime[3]='5'; for(count=0;count<2;count++) SPARA.alarmtarge[count]=0x30+count; //仪表污染物编号 SPARA.alarmtarge[2]='\0'; SPARA.alarmtarge[3]='\0'; for(count=0;count<8;count++) { //ADPARA(count).po_id[0]='P'; //ADPARA(count).po_id[1]=0x31+count; //ADPARA(count).po_id[2]='\0'; ADPARA(count).po_id[0]='0'; ADPARA(count).po_id[1]='0'; ADPARA(count).po_id[2]='0'; ADPARA(count).ADUV.b=16.0; ADPARA(count).ADLV.b=0.0; ADPARA(count).U_Alarmlimt.b=10.0; ADPARA(count).L_Alarmlimt.b=0.0; ADPARA(count).rate.b=(16.0-0.0)/0x666; ADPARA(count).AI_Type=2; } for(count=0;count<6;count++) SPARA.Serial_Baud[count]=0; //LCD_Baud=0; for(checknum[0]=0;checknum[0]<6;checknum[0]++) for(count=0;count<16;count++) SPARA.PO_SerialNum[checknum[0]][count]=0xff; SPARA.PO_SerialNum[0][0]=0x05; for(count=0;count<6;count++) { SPARA.PO_Type[count]=0; Channel_Num[count]=0; } SPARA.PO_Type[0]=1; //水,哈希 Channel_Num[0]=1; SPARA.alarmtarge[10]=0;//baud rate SPARA.LCD_Backtime=1; AT24C64_W(parameter.sys_setting,0x10,sizeof(PARAMETER)); /*初始化历史数据标志组结构体,存储于Flash第一页(页地址0x00)*/ INT8U Rdaddr[3]={0,0,0}; INT16U pageaddr=0; HISDATAFLAGS Sighisdata; MemoryClear(&Sighisdata,sizeof(Sighisdata)); for(count=0;count<7;) { Sighisdata.page =0x10+count*31*24; Rdaddr[1]=(INT8U)(pageaddr>>8); Rdaddr[2]=(INT8U)(pageaddr); FlashBufferWrite(Rdaddr,&Sighisdata,sizeof(Sighisdata),FLASHBUFFER1); FlashBufferWrite(Rdaddr,&Sighisdata,sizeof(Sighisdata),FLASHBUFFER1); count++; pageaddr=count*120; } Rdaddr[0]=0; Rdaddr[1]=0; Rdaddr[2]=0; FlashBuffertoMemory(Rdaddr,FLASHBUFFER1); HISDATAFLAGS_D sig_d; pageaddr=0; MemoryClear(&sig_d,sizeof(sig_d)); for(count=0;count<13;) { sig_d.page =5400+count*31; Rdaddr[0]=0; Rdaddr[1]=((INT8U)(pageaddr>>8))|0x28; //page 5 Rdaddr[2]=(INT8U)(pageaddr); FlashBufferWrite(Rdaddr,&sig_d,sizeof(sig_d),FLASHBUFFER1); count++; pageaddr=count*80; } Rdaddr[0]=0; Rdaddr[1]=0x28; Rdaddr[2]=0; FlashBuffertoMemory(Rdaddr,FLASHBUFFER1); HISDATAFLAGS_R sig_r; MemoryClear(&sig_r,sizeof(sig_r)); pageaddr=0; for(count=0;count<3;) { sig_r.page =6000+count*24*12; Rdaddr[0]=0; Rdaddr[1]=((INT8U)(pageaddr>>8))|0x50; Rdaddr[2]=(INT8U)(pageaddr); FlashBufferWrite(Rdaddr,&sig_r,sizeof(sig_r),FLASHBUFFER1); count++; pageaddr=count*200; } Rdaddr[0]=0; Rdaddr[1]=0x50; // page 10 Rdaddr[2]=0; FlashBuffertoMemory(Rdaddr,FLASHBUFFER1); //运行日志存储于8190页(1FFE) RUNRECORD runlog; MemoryClear(&runlog,sizeof(runlog)); pageaddr=0; for(count=0;count<10;count++) { pageaddr=count*64; Rdaddr[0]=0xff; Rdaddr[1]=((INT8U)(pageaddr>>8))|0xf0; Rdaddr[2]=(INT8U)(pageaddr); FlashBufferWrite(Rdaddr,&runlog,sizeof(runlog),FLASHBUFFER1); } Rdaddr[0]=0xff; Rdaddr[1]=0xf0; Rdaddr[2]=0; FlashBuffertoMemory(Rdaddr,FLASHBUFFER1); //Sighisdata.page =0; //FlashBufferWrite(Rdaddr,&Sighisdata,sizeof(Sighisdata),FLASHBUFFER1); AT24C64_W(checkcode,0x00,6); }
void ModataUpload(INT8U ModM) { INT8U i,j,k; INT8U lm_j,lm_k; //limit INT16U lent; union { char a[4]; float b; }Mod_D; //INT8U cps[]="DataTime=\0"; INT8U Flag_N[2]="N\0"; INT8U NP=0; INT8U Negtive[2]="-\0"; INT8U ftstring[18]; switch(ModM) { case Mod_RealD: //Symbol.ccc=1; //Response(4); //Symbol.ccc=0; //strcat(CBAG.cbag_dynamic,cps); //strcat(CBAG.cbag_dynamic,System_Time); for(i=0;i<6;i++) { lm_j =Channel_Num[i]; for(j=0;j<lm_j;j++) { switch(SPARA.PO_Type[i]) { case 1: //water lm_k =1; break; case 2: //gas lm_k =4; break; default: lm_k =0; break; } for(k=0;k<lm_k;k++) { Mod_D.b =Modbustore[i][j][k]; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_PPR[k]); if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); //strcat(CBAG.cbag_dynamic,Mod_bagR); } if(lm_k!=0) { lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_PPR[4]); if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,Flag_N); } } /*if(lm_j!=0) Add_Send(); else MemoryClear(CBAG.cbag_dynamic,sizeof(CBAG.cbag_dynamic)); */ } break; case Mod_MinD: break; case Mod_HourD: for(i=0;i<6;i++) { lm_j =Channel_Num[i]; for(j=0;j<lm_j;j++) { switch(SPARA.PO_Type[i]) { case 1: //water lm_k =2; break; case 2: //gas lm_k =4; break; default: lm_k =0; break; } //for(k=0;k<lm_k;k++) if(lm_k!=0) { if(dev_mma_H[k].num==0) Mod_D.b =0; else Mod_D.b =dev_mma_H[k].min; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_Phase7); //min if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(dev_mma_H[k].num==0) dev_mma_H[k].avg =0; else dev_mma_H[k].avg =dev_mma_H[k].sum/dev_mma_H[k].num; Mod_D.b =dev_mma_H[k].avg; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_Phase8); if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(dev_mma_H[k].num==0) Mod_D.b =0; else Mod_D.b =dev_mma_H[k].max; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_Phase6); if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(SPARA.PO_Type[i]==2) { if((SPARA.PO_SerialNum[i][j]==8)||(SPARA.PO_SerialNum[i][j]==9)||(SPARA.PO_SerialNum[i][j]==10)||(SPARA.PO_SerialNum[i][j]==11)) { if(dev_mma_H[k].num==0) Mod_D.b =0; else Mod_D.b =dev_mma_H[k].sum; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_Phase18); insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); } } //strcat(CBAG.cbag_dynamic,Mod_bagR); //if(lm_k!=0) /*{ lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_PPR[4]); if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,Flag_N); }*/ } } } //MemoryClear(dev_mma_H,sizeof(dev_mma_H)); break; case Mod_DayD: for(i=0;i<6;i++) { lm_j =Channel_Num[i]; for(j=0;j<lm_j;j++) { switch(SPARA.PO_Type[i]) { case 1: //water lm_k =2; break; case 2: //gas lm_k =4; break; default: lm_k =0; break; } //for(k=0;k<lm_k;k++) if(lm_k!=0) { if(dev_mma_D[k].num==0) Mod_D.b =0; else Mod_D.b =dev_mma_D[k].min; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_Phase7); //min if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(dev_mma_D[k].num==0) dev_mma_D[k].avg =0; else dev_mma_D[k].avg =dev_mma_D[k].sum/dev_mma_D[k].num; Mod_D.b =dev_mma_H[k].avg; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_Phase8); if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(dev_mma_D[k].num==0) Mod_D.b =0; else Mod_D.b =dev_mma_D[k].max; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_Phase6); if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(SPARA.PO_Type[i]==2) { if((SPARA.PO_SerialNum[i][j]==8)||(SPARA.PO_SerialNum[i][j]==9)||(SPARA.PO_SerialNum[i][j]==10)||(SPARA.PO_SerialNum[i][j]==11)) { if(dev_mma_D[k].num==0) Mod_D.b =0; else Mod_D.b =dev_mma_D[k].sum; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_Phase18); insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); } } //strcat(CBAG.cbag_dynamic,Mod_bagR); //if(lm_k!=0) /*{ lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,Mod_PPR[4]); if(SPARA.PO_Type[i]==2) insert(CBAG.cbag_dynamic,MOD_Gas[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); else if(SPARA.PO_Type[i]==1) insert(CBAG.cbag_dynamic,MOD_Water[SPARA.PO_SerialNum[i][j]].PO_code,lent+2); strcat(CBAG.cbag_dynamic,Flag_N); }*/ } } } MemoryClear(dev_mma_D,sizeof(dev_mma_D)); break; default: break; } }
CommandStatusIdType CommandExecClear(char* OutParam) { MemoryClear(); return COMMAND_INFO_OK_ID; }
void ModataUpload(INT8U ModM) { union { char a[4]; float b; }Mod_D; //INT8U cps[]="DataTime=\0"; //INT8U Flag_N[2]="N\0"; INT8U NP=0; INT8U Negtive[2]="-\0"; INT8U rtdstr[11]=";011-Rtd=\0"; INT8U flagstr[13]=",011-Flag=N\0"; INT8U minstr[11]=";011-Min=\0"; INT8U avgstr[11]=",011-Avg=\0"; INT8U maxstr[11]=",011-Max=\0"; INT8U ftstring[18]; INT16U i; float totaltmp=0,total_b01_tmp=0; if(ModM==Mod_RealD) { Mod_D.b =Modbustore; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } strcat(CBAG.cbag_dynamic,rtdstr); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); strcat(CBAG.cbag_dynamic,flagstr); } else { MAX_MIN *maxminp; switch(ModM) { case Mod_MinD: maxminp =dev_mma_M; if(maxminp->num==0) Mod_D.b =0; else Mod_D.b =maxminp->min; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } //lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,minstr); //min strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(maxminp->num==0) maxminp->avg =0; else maxminp->avg =maxminp->sum/maxminp->num; //Mod_D.b =maxminp->avg; Mod_D.b =maxminp->max; //小时cod的平均值就等于它的测量值(环保局091026) if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } strcat(CBAG.cbag_dynamic,avgstr); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(maxminp->num==0) Mod_D.b =0; else Mod_D.b =maxminp->max; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } strcat(CBAG.cbag_dynamic,maxstr); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); //Hour_COD_avg[current_hour]=maxminp->max; break; case Mod_HourD: maxminp =dev_mma_H; if(maxminp->num==0) Mod_D.b =0; else Mod_D.b =maxminp->min; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } //lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,minstr); //min strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(maxminp->num==0) maxminp->avg =0; else maxminp->avg =maxminp->sum/maxminp->num; //Mod_D.b =maxminp->avg; Mod_D.b =maxminp->max; //小时cod的平均值就等于它的测量值(环保局091026) if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } strcat(CBAG.cbag_dynamic,avgstr); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(maxminp->num==0) Mod_D.b =0; else Mod_D.b =maxminp->max; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } strcat(CBAG.cbag_dynamic,maxstr); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); Hour_COD_avg[current_hour]=maxminp->max; break; case Mod_DayD: maxminp =dev_mma_D; if(maxminp->num==0) Mod_D.b =0; else Mod_D.b =maxminp->min; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } //lent =strlen(CBAG.cbag_dynamic); strcat(CBAG.cbag_dynamic,minstr); //min strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); for(i=0;i<24;i++) { totaltmp += Hour_B01_avg[i]*Hour_COD_avg[i]; total_b01_tmp +=Hour_B01_avg[i]; } if(total_b01_tmp!=0.0) { maxminp->avg=totaltmp/total_b01_tmp; } else { maxminp->avg=0; } Mod_D.b =maxminp->avg; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } strcat(CBAG.cbag_dynamic,avgstr); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); if(maxminp->num==0) Mod_D.b =0; else Mod_D.b =maxminp->max; if((Mod_D.a[3]&0x80)==0x80) { Mod_D.a[3]&=0x7f; NP=1; } float_to_string(Mod_D.b,ftstring); if(NP) { insert(ftstring,Negtive,1); } strcat(CBAG.cbag_dynamic,maxstr); strcat(CBAG.cbag_dynamic,ftstring); MemoryClear(ftstring,sizeof(ftstring)); MemoryClear(Hour_COD_avg,sizeof(Hour_COD_avg)); MemoryClear(Hour_B01_avg,sizeof(Hour_B01_avg)); break; default: maxminp =0; break; } } }